Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions swift/ui/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,11 @@ def update_input_model(cls,
if os.path.exists(local_args_path):
try:
if hasattr(arg_cls, 'resume_from_checkpoint'):
try:
# Use adapter vs full-model constructor by path type (avoids fragile exception message check).
if BaseArguments._check_is_adapter(model):
args = arg_cls(resume_from_checkpoint=model, load_data_args=True)
except Exception as e:
if 'using `--model`' in str(e): # TODO a dirty fix
args = arg_cls(model=model, load_data_args=True)
else:
raise e
else:
args = arg_cls(model=model, load_data_args=True)
Comment on lines +346 to +349
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using BaseArguments._check_is_adapter here is a great improvement for robustness. For consistency, consider also using this function in the else block (starting on line 350) which handles cases where arg_cls does not have resume_from_checkpoint. That block currently uses a more limited check (os.path.exists(os.path.join(model, 'adapter_config.json'))), and unifying the logic would make adapter detection consistent.

else:
if os.path.exists(os.path.join(model, 'adapter_config.json')):
args = arg_cls(adapters=model, load_data_args=True)
Expand Down