Hugging Face download
swaleio/[email protected]
Hugging Face download
Downloads repo from the Hugging Face Hub into the directory given by dest and
emits that local path for downstream tasks. The definition's exec.env delivers
the token input as HF_TOKEN for gated or private repos (an omitted token
resolves to an empty value, which the Hugging Face stack treats as no token). The
wrapper appends --revision when revision is set and splits include on commas
into repeated --include glob filters — so a single string input drives multiple
download patterns without word-splitting in args.
The Hub cache defaults to the per-task home directory, so it is discarded when the
task ends. hf stages every file through that cache before materializing it into
dest, which means a large download needs room for both. Set cache_dir to a
workspace path when a run downloads repeatedly: the blobs survive the task, later
downloads of the same revision reuse them, and the staging copies stop competing
with the task's own scratch capacity.
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
repo |
yes | — | Repo id to download, e.g. meta-llama/Llama-3.1-8B-Instruct. |
repo_type |
no | model |
Repository type: model, dataset, or space. |
revision |
no | main revision | Branch, tag, or commit to download. |
include |
no | everything | Comma-separated glob patterns (e.g. *.safetensors,*.json). |
cache_dir |
no | per-task home | Where the Hub cache lives. A workspace path (e.g. ${{env.WORKFLOW_STORAGE}}/hf-cache) survives the task and is reused by later downloads. |
dest |
yes | — | Absolute path to the download directory inside the container (e.g. ${{env.WORKFLOW_STORAGE}}/llama to share it with later tasks). |
token |
no | — | HF access token for gated/private repos (pass a secret). |
Outputs
| Output | Description |
|---|---|
path |
The local directory the content was downloaded to — the dest you passed (e.g. ${{env.WORKFLOW_STORAGE}}/llama). |
Compute
CPU. Data movement only — no GPU is needed, and scheduling it on a GPU compute type wastes money.
Example
name: Hugging Face download example
compute_type: cpu-4
entry_point: main
blocks:
main:
tasks:
weights:
name: Fetch weights
uses: swaleio/hf-download
args:
repo: meta-llama/Llama-3.1-8B-Instruct
include: "*.safetensors,*.json,tokenizer.*"
dest: ${{env.WORKFLOW_STORAGE}}/llama
token: ${{secrets.hf_token}}
Downstream tasks read the files at ${{env.WORKFLOW_STORAGE}}/llama, or reference the
resolved location via ${{tasks.weights.outputs.path}}.
For the workflow syntax these examples use, see the workflow definition reference in the Swale documentation.
Licensed under the MIT License.