@@ -87,7 +87,7 @@ def make_scf_task(*, workdir=".",
8787
8888 # --- build per-task override dict ---
8989 TASK_YAML = "_scf_task.yaml"
90- overrides = {"type" : "scf_task " }
90+ overrides = {"type" : "scf" , "scf_soft" : "pyscf " }
9191 if sys_str is not None :
9292 overrides ["systems" ] = sys_str
9393 if model_file :
@@ -275,21 +275,19 @@ def make_train_task(*, workdir=".",
275275 python = "python" , ** task_args ):
276276 """Create a training task as a BatchTask running via the unified 'deepks' CLI.
277277
278- All training parameters are folded into a per-task YAML (_train_task.yaml)
279- with type: train_task. The YAML is written to disk during preprocess()
280- (not via a shell one-liner), so the command is simply:
281- deepks _train_task.yaml
278+ The base train_input.yaml (from share) is read at construction time, merged
279+ with runtime overrides (train_paths, test_paths, type, restart, etc.), and
280+ written back to train_input.yaml in the workdir during preprocess(). No
281+ separate _train_task.yaml is created.
282282 """
283- link_share = task_args .pop ("link_share_files" , [])
283+ from deepks .io .utils import load_yaml , deep_update
284+
284285 link_prev = task_args .pop ("link_prev_files" , [])
286+ link_share = task_args .pop ("link_share_files" , [])
285287 forward_files = task_args .pop ("forward_files" , [])
286288 backward_files = task_args .pop ("backward_files" , [])
287289
288- # --- file links ---
289- if arg_file and source_arg is not None :
290- link_share .append ((source_arg , arg_file ))
291- if arg_file :
292- forward_files .append (arg_file )
290+ # --- file links (everything except train_input.yaml, which we write ourselves) ---
293291 if restart_model and source_model is not None :
294292 link_prev .append ((source_model , restart_model ))
295293 forward_files .append (restart_model )
@@ -305,24 +303,27 @@ def make_train_task(*, workdir=".",
305303 if save_model :
306304 backward_files .append (save_model )
307305
308- # --- build per-task YAML overrides ---
309- TASK_YAML = "_train_task.yaml"
310- overrides = {"type" : "train_task" }
306+ # --- read base train_input.yaml from source_arg (share folder) if available ---
307+ base_config = {}
308+ if source_arg is not None and os .path .exists (source_arg ):
309+ base_config = load_yaml (source_arg ) or {}
310+
311+ # --- build runtime overrides and merge into base ---
312+ overrides = {"type" : "train" }
311313 if data_train :
312- overrides ["train_paths " ] = os .path .join (data_train , "*" )
314+ overrides ["systems_train " ] = os .path .join (data_train , "*" )
313315 if data_test :
314- overrides ["test_paths " ] = os .path .join (data_test , "*" )
316+ overrides ["systems_test " ] = os .path .join (data_test , "*" )
315317 if restart_model :
316318 overrides ["restart" ] = restart_model
317319 if proj_basis :
318320 overrides ["proj_basis" ] = proj_basis
319321 if save_model :
320- overrides . setdefault ( "train_args" , {}) ["ckpt_file" ] = save_model
322+ overrides ["ckpt_file" ] = save_model
321323
322- # Write the YAML at construction time; BatchTask.preprocess() writes it to
323- # disk before the shell command runs — no fragile python -c one-liner needed.
324- task_yaml_content = dump_yaml_str (overrides )
325- command = f"{ SCF_CMD } { TASK_YAML } "
324+ merged = deep_update (dict (base_config ), overrides )
325+ task_yaml_content = dump_yaml_str (merged )
326+ command = f"{ SCF_CMD } { arg_file } "
326327
327328 return BatchTask (
328329 command ,
@@ -336,7 +337,7 @@ def make_train_task(*, workdir=".",
336337 link_prev_files = link_prev ,
337338 forward_files = forward_files ,
338339 backward_files = backward_files ,
339- write_files = {TASK_YAML : task_yaml_content },
340+ write_files = {arg_file : task_yaml_content },
340341 ** task_args
341342 )
342343
0 commit comments