Skip to content

Add session-scoped environment overrides#1717

Open
nico-martin wants to merge 10 commits into
mainfrom
feat/session-env
Open

Add session-scoped environment overrides#1717
nico-martin wants to merge 10 commits into
mainfrom
feat/session-env

Conversation

@nico-martin

Copy link
Copy Markdown
Collaborator

Adds session-scoped environment overrides for resource loading while keeping the global env object as the default. Callers can now pass options.env to pipelines, model/tokenizer/config loading, and model-registry helpers without mutating process-wide settings.

What Changed

  • Added options.env for session-scopable resource-loading settings: allowRemoteModels, remoteHost, remotePathTemplate, allowLocalModels, localModelPath, fetch, and hfToken.
  • Threaded scoped env values through pipeline loading, from_pretrained(...) APIs, metadata checks, expected-file discovery, cache checks, and registry helpers.
  • Uses the pipeline session env when loading image/audio URL inputs, with optional session env support in RawImage.read(...), RawImage.fromURL(...), and load_audio(...).
  • Added env.hfToken, defaulting from HF_TOKEN or HF_ACCESS_TOKEN, for Hugging Face Hub authorization headers.
  • Made env.remoteHost default from HF_ENDPOINT when present, otherwise https://huggingface.co/ (Respect HF_ENDPOINT for env.remoteHost #1713).
  • Added pipeline.env for the effective resolved environment and pipeline.sessionEnv for the provided overrides.

Deprecated Params

Some parameters were used to overwrite global env variables. With the new sessionEnv we could remove them (but should keep them until the next major release for compatibility reasons)

  • cache_dir: deprecated for environment-style configuration. Use global env.cacheDir for the default cache directory and options.env for session-scopable resource loading.
  • local_files_only: deprecated. Use options.env.allowRemoteModels = false for session-scoped remote loading control.

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

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.

2 participants