VladKha commited on
Commit
80cb072
·
verified ·
1 Parent(s): 71d9eb1

public base image (hf-image-estimate)

Browse files
Files changed (4) hide show
  1. Dockerfile +12 -13
  2. pyproject.toml +2 -2
  3. requirements-extras.txt +2 -0
  4. run-job.sh +12 -9
Dockerfile CHANGED
@@ -1,9 +1,9 @@
1
  # syntax=docker/dockerfile:1.6
2
  # PUBLIC base image for the cheap CPU ESTIMATE job (HF Jobs) — slim, no GPU stack.
3
  #
4
- # Same contract as demo/image/Dockerfile: ONLY open-source, generic dependencies — NO proprietary
5
- # code, and no names that reveal which models/techniques the pipeline uses. The Job's bootstrap
6
- # (/opt/run-job.sh) pulls the private wheel + demo modules at startup and runs run_job.py.
7
  #
8
  # This variant is CPU-ONLY and slim: it omits CUDA/torch and the GPU inference servers (the estimate
9
  # runs zero signals and starts no model server — run_job.py returns at the ESTIMATE_ONLY branch
@@ -12,10 +12,10 @@
12
  # estimate's wall-clock. A lightweight tokenizer loads via the Rust `tokenizers` backend, so no
13
  # torch is needed.
14
  #
15
- # Build: JOB_IMAGE_DIR=image-estimate JOB_IMAGE_BASE_PROVIDES=torch \
16
- # JOB_IMAGE_SPACE=<owner>/cpu-estimate-base make demo-deploy-job
17
- # (run-job.sh + the dataset_reviewer stub are shared from demo/image/; the omitted dep group is
18
- # applied automatically for this variant — see demo/deploy_job.py.)
19
 
20
  FROM python:3.12-slim
21
 
@@ -33,7 +33,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
33
  WORKDIR /app
34
 
35
  # Install the generic DEPENDENCIES only — the generated pyproject omits torch
36
- # (JOB_IMAGE_BASE_PROVIDES=torch) since the estimate needs no torch/CUDA. A stub package
37
  # (empty dataset_reviewer/__init__.py) lets `pip install .` resolve the deps WITHOUT shipping
38
  # proprietary source into this public image. At runtime the Job replaces the stub with the
39
  # real wheel; run-job.sh skips the technique-revealing runtime deps for ESTIMATE_ONLY (never
@@ -42,11 +42,10 @@ COPY pyproject.toml /app/pyproject.toml
42
  COPY dataset_reviewer /app/dataset_reviewer
43
  RUN --mount=type=cache,target=/root/.cache/pip pip install /app
44
 
45
- # Explicit pins for the bootstrap + demo modules (transitive above, pinned so the bootstrap
46
- # never depends on resolution order). telethon is the Telegram client the Job imports — not a
47
- # dataset_reviewer dep.
48
- RUN --mount=type=cache,target=/root/.cache/pip \
49
- pip install "huggingface_hub[hf_transfer]" python-dotenv "telethon==1.43.2"
50
 
51
  COPY run-job.sh /opt/run-job.sh
52
  RUN chmod +x /opt/run-job.sh
 
1
  # syntax=docker/dockerfile:1.6
2
  # PUBLIC base image for the cheap CPU ESTIMATE job (HF Jobs) — slim, no GPU stack.
3
  #
4
+ # Same contract as deploy/hf-image-llama-cpp/Dockerfile: ONLY open-source, generic dependencies — NO
5
+ # proprietary code, and no names that reveal which models/techniques the pipeline uses. The Job's
6
+ # bootstrap (/opt/run-job.sh) pulls the private wheel + job modules at startup and runs run_job.py.
7
  #
8
  # This variant is CPU-ONLY and slim: it omits CUDA/torch and the GPU inference servers (the estimate
9
  # runs zero signals and starts no model server — run_job.py returns at the ESTIMATE_ONLY branch
 
12
  # estimate's wall-clock. A lightweight tokenizer loads via the Rust `tokenizers` backend, so no
13
  # torch is needed.
14
  #
15
+ # Build: HF_JOB_IMAGE_DIR=hf-image-estimate HF_JOB_IMAGE_BASE_PROVIDES=torch \
16
+ # HF_JOB_IMAGE_SPACE=<owner>/cpu-estimate-base make deploy-hf-job
17
+ # (run-job.sh + the dataset_reviewer stub are shared from deploy/hf-image-common/; the omitted dep
18
+ # group is applied automatically for this variant — see deploy/deploy_hf_job.py.)
19
 
20
  FROM python:3.12-slim
21
 
 
33
  WORKDIR /app
34
 
35
  # Install the generic DEPENDENCIES only — the generated pyproject omits torch
36
+ # (HF_JOB_IMAGE_BASE_PROVIDES=torch) since the estimate needs no torch/CUDA. A stub package
37
  # (empty dataset_reviewer/__init__.py) lets `pip install .` resolve the deps WITHOUT shipping
38
  # proprietary source into this public image. At runtime the Job replaces the stub with the
39
  # real wheel; run-job.sh skips the technique-revealing runtime deps for ESTIMATE_ONLY (never
 
42
  COPY dataset_reviewer /app/dataset_reviewer
43
  RUN --mount=type=cache,target=/root/.cache/pip pip install /app
44
 
45
+ # Non-library job deps, single-sourced in job_deps.JOB_EXTRA_DEPS — deploy_hf_job.py
46
+ # stages the requirements file into this build context.
47
+ COPY requirements-extras.txt /app/requirements-extras.txt
48
+ RUN --mount=type=cache,target=/root/.cache/pip pip install -r /app/requirements-extras.txt
 
49
 
50
  COPY run-job.sh /opt/run-job.sh
51
  RUN chmod +x /opt/run-job.sh
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ version = "0.1.0"
4
  requires-python = ">=3.12"
5
  dependencies = [
6
  "datasets>=5.0.0",
7
- "datatrove[io]>=0.9.0",
8
  "duckdb>=1.4.4",
9
  "httpx",
10
  "jinja2>=3.1.6",
@@ -16,7 +16,7 @@ dependencies = [
16
  "rich>=14.3.3",
17
  "loguru",
18
  "python-dotenv",
19
- "huggingface-hub",
20
  "pandas",
21
  "pytz",
22
  "requests",
 
4
  requires-python = ">=3.12"
5
  dependencies = [
6
  "datasets>=5.0.0",
7
+ "datatrove[io] @ git+https://github.com/huggingface/datatrove.git@a035d36e8a13d22ce04e84b84f30b4ec45f9c48e",
8
  "duckdb>=1.4.4",
9
  "httpx",
10
  "jinja2>=3.1.6",
 
16
  "rich>=14.3.3",
17
  "loguru",
18
  "python-dotenv",
19
+ "huggingface-hub>=1.13,<1.17",
20
  "pandas",
21
  "pytz",
22
  "requests",
requirements-extras.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ huggingface_hub[hf_transfer]
2
+ telethon==1.43.2
run-job.sh CHANGED
@@ -1,20 +1,23 @@
1
  #!/usr/bin/env bash
2
- # HF Job bootstrap: pull the private dataset_reviewer wheel + demo modules +
3
- # runtime requirements from JOB_CODE_REPO (authenticated by HF_TOKEN), install the
4
- # wheel over the baked stub, install the technique-revealing deps kept out of the
5
- # public image, then run the headless pipeline. Each phase is timed so its cost is
6
- # visible in the Job log. Keeps proprietary code + model/technique names OUT of the
7
- # public base image.
8
  set -euo pipefail
9
 
10
- : "${JOB_CODE_REPO:?JOB_CODE_REPO is required}"
 
 
 
11
 
12
  t=$SECONDS
13
- echo "[bootstrap] downloading job code from ${JOB_CODE_REPO}"
14
  python3 - <<'PY'
15
  import os
16
  from huggingface_hub import snapshot_download
17
- snapshot_download(repo_id=os.environ["JOB_CODE_REPO"], repo_type="model", local_dir="/code")
18
  PY
19
  echo "[bootstrap] job code downloaded in $((SECONDS - t))s"
20
 
 
1
  #!/usr/bin/env bash
2
+ # HF Job bootstrap: pull the private dataset_reviewer wheel + job modules +
3
+ # runtime requirements from HF_JOB_CODE_REPO (authenticated by HF_TOKEN), install
4
+ # the wheel over the baked stub, install the technique-revealing deps kept out of
5
+ # the public image, then run the headless pipeline. Each phase is timed so its cost
6
+ # is visible in the Job log. Keeps proprietary code + model/technique names OUT of
7
+ # the public base image.
8
  set -euo pipefail
9
 
10
+ # JOB_CODE_REPO is the pre-rename env name; launchers older than the rename send only it.
11
+ : "${HF_JOB_CODE_REPO:=${JOB_CODE_REPO:-}}"
12
+ : "${HF_JOB_CODE_REPO:?HF_JOB_CODE_REPO is required}"
13
+ export HF_JOB_CODE_REPO
14
 
15
  t=$SECONDS
16
+ echo "[bootstrap] downloading job code from ${HF_JOB_CODE_REPO}"
17
  python3 - <<'PY'
18
  import os
19
  from huggingface_hub import snapshot_download
20
+ snapshot_download(repo_id=os.environ["HF_JOB_CODE_REPO"], repo_type="model", local_dir="/code")
21
  PY
22
  echo "[bootstrap] job code downloaded in $((SECONDS - t))s"
23