Skip to content

Commit cd4e7bf

Browse files
davanstrienclaude
andauthored
Detect Jobs via HF_JOB_ID and tag outputs hf_jobs (#209)
Jobs now sets HF_JOB_ID (same value as JOB_ID). Gate the "Produced on HF Jobs" claim, the live-server URLs and the bucket checks on HF_JOB_ID, which other environments do not set. Rename the card tag hf-jobs -> hf_jobs, the tag TRL and the Transformers Trainer write, so one Hub filter counts all Jobs outputs. AGENTS.md convention updated to match. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent bf5f495 commit cd4e7bf

38 files changed

Lines changed: 85 additions & 84 deletions

‎AGENTS.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ image, add a dependency to an image-mode recipe, or retire a recipe. The procedu
6464
no shared helper):
6565

6666
```python
67-
on_jobs = os.environ.get("JOB_ID") is not None # set by HF Jobs in-container
67+
on_jobs = os.environ.get("HF_JOB_ID") is not None # set by HF Jobs in-container
6868
hw = jobs_flavor() # e.g. "a10g-small"; "" if unknown
6969
origin = (
7070
f"Produced on [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs)"
@@ -92,10 +92,11 @@ image, add a dependency to an image-mode recipe, or retire a recipe. The procedu
9292
returns "" on any failure. Use `jobs_flavor() or "<default>"` for the reproduce command's `--flavor`.
9393

9494
Rules: the reproduce command is **`hf jobs uv run`** (never bare `uv run` — the card is the Jobs
95-
advertisement); the "Produced on HF Jobs" claim is **gated on `JOB_ID`** (a local run must not claim it);
95+
advertisement); the "Produced on HF Jobs" claim is **gated on `HF_JOB_ID`** (a local run must not claim it);
9696
credit goes to the **org**, never a personal name; no badges. Card frontmatter tags: always `uv-script`,
97-
plus **`hf-jobs` when `JOB_ID` is set** — these are the adoption meters
98-
(`list_datasets(tags="uv-script")` / `tags="hf-jobs"` count stamped public outputs).
97+
plus **`hf_jobs` when `HF_JOB_ID` is set** — these are the adoption meters
98+
(`list_datasets(tags="uv-script")` / `tags="hf_jobs"` count stamped public outputs). `hf_jobs` is the tag
99+
TRL and the Transformers Trainer also write, so one filter counts all of them.
99100
- GPU scripts check `torch.cuda.is_available()` and exit with a clear message. Write outputs to the Hub
100101
(`push_to_hub`) or a bucket (`-v hf://…`), never bare local paths (Jobs disk is ephemeral; local *input*
101102
dirs can be mounted with `-v ./dir:/mnt`, which syncs them to a bucket). Name by task, not tool.

‎build-atlas/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
viewer: false
3-
tags: [uv-script, hf-jobs, hf-buckets]
3+
tags: [uv-script, hf_jobs, hf-buckets]
44
---
55

66
<a href="https://huggingface.co/uv-scripts"><img src="https://huggingface.co/spaces/uv-scripts/README/resolve/main/lockup.svg" alt="uv scripts" width="180"></a>

‎classification/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
viewer: false
3-
tags: [uv-script, classification, fine-tuning, few-shot, zero-shot, decision-model, setfit, gliner2, kev, vllm, structured-outputs, image-classification, timm, hf-jobs]
3+
tags: [uv-script, classification, fine-tuning, few-shot, zero-shot, decision-model, setfit, gliner2, kev, vllm, structured-outputs, image-classification, timm, hf_jobs]
44
---
55

66
<a href="https://huggingface.co/uv-scripts"><img src="https://huggingface.co/spaces/uv-scripts/README/resolve/main/lockup.svg" alt="uv scripts" width="180"></a>

‎classification/classify-gliner2.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def build_reproduce_command(args) -> str:
300300

301301
def build_card(args, tasks, counts_by_task, total, seconds, zero_shot: bool) -> str:
302302
"""Dataset card with the canonical uv-scripts provenance stamp."""
303-
on_jobs = os.environ.get("JOB_ID") is not None
303+
on_jobs = os.environ.get("HF_JOB_ID") is not None
304304
hardware = jobs_flavor()
305305
if on_jobs:
306306
origin = "Produced on [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs)"
@@ -311,7 +311,7 @@ def build_card(args, tasks, counts_by_task, total, seconds, zero_shot: bool) ->
311311

312312
tags = ["uv-script", "gliner2", "text-classification"]
313313
if on_jobs:
314-
tags.append("hf-jobs")
314+
tags.append("hf_jobs")
315315
tag_lines = "\n".join(f"- {tag}" for tag in tags)
316316

317317
if zero_shot:

‎classification/train-classifier.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def build_card(
505505
input_dataset, output_repo, model_id, problem_type, label_names, metrics,
506506
thresholds, path_kind, args_summary,
507507
) -> str:
508-
on_jobs = os.environ.get("JOB_ID") is not None # set by HF Jobs in-container
508+
on_jobs = os.environ.get("HF_JOB_ID") is not None # set by HF Jobs in-container
509509
hw = jobs_flavor() # flavor name, e.g. "a10g-small"; "" on CPU
510510
origin = (
511511
"Produced on [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs)"
@@ -514,7 +514,7 @@ def build_card(
514514

515515
tags = ["uv-script", "text-classification"]
516516
if on_jobs:
517-
tags.append("hf-jobs")
517+
tags.append("hf_jobs")
518518
tag_lines = "\n".join(f"- {t}" for t in tags)
519519

520520
metric_rows = "\n".join(f"| {k} | {v:.4f} |" for k, v in metrics.items())

‎classification/train-gliner2.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def build_manifest(args, sampling_config: SamplingConfig, precision: str) -> dic
566566
"sampling_config": dataclasses.asdict(sampling_config),
567567
"precision": precision,
568568
"device": torch.cuda.get_device_name(0) if torch.cuda.is_available() else "cpu",
569-
"job_id": os.environ.get("JOB_ID"),
569+
"job_id": os.environ.get("HF_JOB_ID"),
570570
"versions": package_versions(),
571571
}
572572

@@ -912,8 +912,8 @@ def results_table(tasks: list, zero_shot, fine_tuned) -> str:
912912

913913

914914
def build_card(args, tasks, zero_shot, fine_tuned, train_size, train_seconds, carved_out, oom_steps) -> str:
915-
"""Model card following the uv-scripts conventions (org credit, Jobs claim gated on JOB_ID)."""
916-
on_jobs = os.environ.get("JOB_ID") is not None
915+
"""Model card following the uv-scripts conventions (org credit, Jobs claim gated on HF_JOB_ID)."""
916+
on_jobs = os.environ.get("HF_JOB_ID") is not None
917917
hardware = jobs_flavor()
918918
if on_jobs:
919919
provenance = "Produced on [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs)"
@@ -925,7 +925,7 @@ def build_card(args, tasks, zero_shot, fine_tuned, train_size, train_seconds, ca
925925

926926
tags = ["gliner2", "text-classification", "uv-script"]
927927
if on_jobs:
928-
tags.append("hf-jobs")
928+
tags.append("hf_jobs")
929929
tag_lines = "\n".join(f"- {tag}" for tag in tags)
930930

931931
caveats = []

‎classification/train-kev.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def mount_of(path, mounts_file=Path("/proc/self/mounts")):
142142

143143
def prepare_output(output_dir):
144144
"""Fail before any GPU time is spent if the results would be lost or mixed with an old run."""
145-
if os.environ.get("JOB_ID"):
145+
if os.environ.get("HF_JOB_ID"):
146146
# on Jobs, only a mounted bucket outlives the container (it shows as device "hf-mount")
147147
mount_point, fstype, device = mount_of(output_dir)
148148
if device != "hf-mount":

‎classification/train-setfit.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def build_reproduce_command(args) -> str:
559559
Outside Jobs, the hardware flavor is a suggested default rather than an exact record.
560560
"""
561561
flavor = "t4-small" if torch.cuda.is_available() else "cpu-basic"
562-
if os.environ.get("JOB_ID"):
562+
if os.environ.get("HF_JOB_ID"):
563563
flavor = jobs_flavor() or flavor
564564
parts = [
565565
f"hf jobs uv run --flavor {flavor} --secrets HF_TOKEN \\",
@@ -618,8 +618,8 @@ def build_reproduce_command(args) -> str:
618618

619619

620620
def build_card(args, label_names, metrics, per_class, train_seconds, eval_split) -> str:
621-
"""Model card following the uv-scripts conventions (org credit, Jobs claim gated on JOB_ID)."""
622-
on_jobs = os.environ.get("JOB_ID") is not None
621+
"""Model card following the uv-scripts conventions (org credit, Jobs claim gated on HF_JOB_ID)."""
622+
on_jobs = os.environ.get("HF_JOB_ID") is not None
623623
provenance = (
624624
"Produced on [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs) "
625625
"with [`uv-scripts/classification`](https://huggingface.co/datasets/uv-scripts/classification)."
@@ -629,7 +629,7 @@ def build_card(args, label_names, metrics, per_class, train_seconds, eval_split)
629629

630630
tags = ["setfit", "text-classification", "few-shot", "uv-script"]
631631
if on_jobs:
632-
tags.append("hf-jobs")
632+
tags.append("hf_jobs")
633633
tag_lines = "\n".join(f"- {tag}" for tag in tags)
634634

635635
metric_lines = "\n".join(f"| {name} | {value} |" for name, value in metrics.items())

‎classification/train-timm.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def usage_snippet(repo_id, task, threshold, in_chans):
810810

811811
def build_model_card(args, plan, metrics, best_epoch, argv):
812812
base_hub_id, license_name = base_model_license(args.model)
813-
on_jobs = os.environ.get("JOB_ID") is not None
813+
on_jobs = os.environ.get("HF_JOB_ID") is not None
814814
hw = jobs_flavor()
815815
origin = (
816816
(
@@ -825,7 +825,7 @@ def build_model_card(args, plan, metrics, best_epoch, argv):
825825
if plan["task"] == "multilabel":
826826
tags.append("multi-label-classification")
827827
if on_jobs:
828-
tags.append("hf-jobs")
828+
tags.append("hf_jobs")
829829

830830
frontmatter = ["---", "library_name: timm", "pipeline_tag: image-classification"]
831831
if license_name:

‎dataset-stats/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tags:
55
- dataset-statistics
66
- polars
77
- temporal-analysis
8-
- hf-jobs
8+
- hf_jobs
99
license: apache-2.0
1010
---
1111

0 commit comments

Comments
 (0)