Skip to content

fix: skip config.json network call when loading from local directory (#340)#363

Open
aarushisingh04 wants to merge 1 commit intogoogle-research:masterfrom
aarushisingh04:fix/force-download-hardcoded
Open

fix: skip config.json network call when loading from local directory (#340)#363
aarushisingh04 wants to merge 1 commit intogoogle-research:masterfrom
aarushisingh04:fix/force-download-hardcoded

Conversation

@aarushisingh04
Copy link
Copy Markdown

fixes #340 : _from_pretrained with a local directory path no longer makes unnecessary network calls.

fix

  • guard config.json download with if not os.path.isdir(model_id) so local loading makes zero network calls
  • use caller's model_id and pass through all download parameters (force_download, revision, cache_dir, etc.) consistently
  • default force_download to False to respect HF cache (matches HF ecosystem convention)

before

# always runs, even for local paths, crashes offline
_ = hf_hub_download(
    repo_id="google/timesfm-2.5-200m-pytorch",  # hardcoded
    filename="config.json",
    force_download=True,  # hardcoded
)

after

# only download config.json when loading from HF Hub
if not os.path.isdir(model_id):
    _ = hf_hub_download(
        repo_id=model_id,
        filename="config.json",
        force_download=force_download,
        # ... all other params passed through
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

load local models

1 participant