Skip to content

Commit

Permalink
Update deepmd/pt/entrypoints/main.py
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Chenqqian Zhang <[email protected]>
  • Loading branch information
Chengqian-Zhang and coderabbitai[bot] authored May 20, 2024
1 parent f60300a commit 09d2fec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deepmd/pt/entrypoints/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,14 @@ def main(args: Optional[Union[List[str], argparse.Namespace]] = None):
if FLAGS.list_model_branch:
assert (

Check warning on line 316 in deepmd/pt/entrypoints/main.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/entrypoints/main.py#L316

Added line #L316 was not covered by tests
FLAGS.finetune is not None
), "When using --list-model-branch, please use --finetune"
), "Error: The '--list-model-branch' option requires the '--finetune' argument to specify the model."
state_dict = torch.load(FLAGS.finetune, map_location=env.DEVICE)
if "model" in state_dict:
state_dict = state_dict["model"]
model_params = state_dict["_extra_state"]["model_params"]
finetune_from_multi_task = "model_dict" in model_params

Check warning on line 323 in deepmd/pt/entrypoints/main.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/entrypoints/main.py#L319-L323

Added lines #L319 - L323 were not covered by tests
# Pretrained model must be multitask mode
assert finetune_from_multi_task, "When using --list-model-branch, the pretrained model must be multitask model"
assert finetune_from_multi_task, "Error: The '--list-model-branch' option requires a multitask pretrained model. The provided model does not meet this criterion."
model_branch = list(model_params["model_dict"].keys())
log.info(f"Available model branches are {model_branch}")

Check warning on line 327 in deepmd/pt/entrypoints/main.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/entrypoints/main.py#L325-L327

Added lines #L325 - L327 were not covered by tests
else:
Expand Down

0 comments on commit 09d2fec

Please sign in to comment.