load code from file dict instead of folder (#641)

Co-authored-by: Xu <v-xuminrui@microsoft.com>
This commit is contained in:
Roland Minrui
2025-02-26 14:21:28 +08:00
committed by GitHub
parent 75bdce3631
commit 7ad0ee2250
3 changed files with 12 additions and 2 deletions
+1
View File
@@ -66,6 +66,7 @@ coverage.xml
# Django stuff:
*.log
/log/
log*/
local_settings.py
db.sqlite3
db.sqlite3-journal
+7
View File
@@ -219,6 +219,13 @@ class FBWorkspace(Workspace):
relative_path = file_path.relative_to(folder_path)
self.inject_files(**{str(relative_path): file_path.read_text()})
def inject_code_from_file_dict(self, workspace: FBWorkspace) -> None:
"""
Load the workspace from the file_dict
"""
for name, code in workspace.file_dict.items():
self.inject_files(**{name: code})
def copy(self) -> FBWorkspace:
"""
copy the workspace from the original one
@@ -267,7 +267,8 @@ class DSExpGen(ExpGen):
exp = DSExperiment(pending_tasks_list=[[task]], hypothesis=DSHypothesis(component))
if last_successful_exp:
exp.experiment_workspace.inject_code_from_folder(last_successful_exp.experiment_workspace.workspace_path)
# exp.experiment_workspace.inject_code_from_folder(last_successful_exp.experiment_workspace.workspace_path)
exp.experiment_workspace.inject_code_from_file_dict(last_successful_exp.experiment_workspace)
return exp
def gen(self, trace: DSTrace) -> DSExperiment:
@@ -449,7 +450,8 @@ class DSExpGen(ExpGen):
hypothesis, task, new_workflow_desc = _f(user_prompt)
exp = DSExperiment(pending_tasks_list=[[task]], hypothesis=hypothesis)
exp.experiment_workspace.inject_code_from_folder(sota_exp.experiment_workspace.workspace_path)
# exp.experiment_workspace.inject_code_from_folder(sota_exp.experiment_workspace.workspace_path)
exp.experiment_workspace.inject_code_from_file_dict(sota_exp.experiment_workspace)
if new_workflow_desc != "No update needed":
workflow_task = WorkflowTask(