Spaces:
Running on RTX PRO 6000
Running on RTX PRO 6000
Deploy simready-assets run 20261005-ee37df6 (GPU variant)
Browse files- pipeline/artifact_store.py +20 -0
- pipeline/bake.py +5 -7
- pipeline/hf_space.py +9 -8
pipeline/artifact_store.py
CHANGED
|
@@ -33,6 +33,12 @@ from .config import Config
|
|
| 33 |
|
| 34 |
ARTIFACT_AWS_ACCESS_KEY_ID_VAR = "SIMREADYCENTRAL_INDEX_STORE_AWS_ACCESS_KEY_ID"
|
| 35 |
ARTIFACT_AWS_SECRET_ACCESS_KEY_VAR = "SIMREADYCENTRAL_INDEX_STORE_AWS_SECRET_ACCESS_KEY"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
T = TypeVar("T")
|
| 38 |
|
|
@@ -75,6 +81,20 @@ def artifact_env() -> Dict[str, str]:
|
|
| 75 |
return env
|
| 76 |
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
@functools.lru_cache(maxsize=4)
|
| 79 |
def _client(region: str, key: str, secret: str):
|
| 80 |
return boto3.session.Session(
|
|
|
|
| 33 |
|
| 34 |
ARTIFACT_AWS_ACCESS_KEY_ID_VAR = "SIMREADYCENTRAL_INDEX_STORE_AWS_ACCESS_KEY_ID"
|
| 35 |
ARTIFACT_AWS_SECRET_ACCESS_KEY_VAR = "SIMREADYCENTRAL_INDEX_STORE_AWS_SECRET_ACCESS_KEY"
|
| 36 |
+
# A separate read-only IAM user for the HF Spaces: deploy-space* pushes these
|
| 37 |
+
# (never the read-write pair above) as the Space's ARTIFACT_AWS_* secrets, and
|
| 38 |
+
# bake's hf-space smoke tests run the images with them, so a Space never holds
|
| 39 |
+
# keys that can write to or delete from the bucket.
|
| 40 |
+
ARTIFACT_READONLY_AWS_ACCESS_KEY_ID_VAR = "SIMREADYCENTRAL_INDEX_STORE_READONLY_AWS_ACCESS_KEY_ID"
|
| 41 |
+
ARTIFACT_READONLY_AWS_SECRET_ACCESS_KEY_VAR = "SIMREADYCENTRAL_INDEX_STORE_READONLY_AWS_SECRET_ACCESS_KEY_ID"
|
| 42 |
|
| 43 |
T = TypeVar("T")
|
| 44 |
|
|
|
|
| 81 |
return env
|
| 82 |
|
| 83 |
|
| 84 |
+
def space_artifact_secrets() -> Dict[str, str]:
|
| 85 |
+
"""The read-only pair, under the names the HF Space container reads
|
| 86 |
+
(artifact_env()'s, inside the Space) β what a Space secret or a smoke
|
| 87 |
+
test's `docker run -e` sets."""
|
| 88 |
+
key = os.environ.get(ARTIFACT_READONLY_AWS_ACCESS_KEY_ID_VAR, "").strip()
|
| 89 |
+
secret = os.environ.get(ARTIFACT_READONLY_AWS_SECRET_ACCESS_KEY_VAR, "").strip()
|
| 90 |
+
if not key or not secret:
|
| 91 |
+
raise SystemExit(
|
| 92 |
+
f"{ARTIFACT_READONLY_AWS_ACCESS_KEY_ID_VAR} / {ARTIFACT_READONLY_AWS_SECRET_ACCESS_KEY_VAR} "
|
| 93 |
+
"must be set in the environment: the HF Space gets the artifact bucket's read-only keys."
|
| 94 |
+
)
|
| 95 |
+
return {ARTIFACT_AWS_ACCESS_KEY_ID_VAR: key, ARTIFACT_AWS_SECRET_ACCESS_KEY_VAR: secret}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
@functools.lru_cache(maxsize=4)
|
| 99 |
def _client(region: str, key: str, secret: str):
|
| 100 |
return boto3.session.Session(
|
pipeline/bake.py
CHANGED
|
@@ -20,7 +20,7 @@ from pathlib import Path
|
|
| 20 |
from typing import Dict, List, Optional
|
| 21 |
|
| 22 |
from . import hf_addressing
|
| 23 |
-
from .artifact_store import
|
| 24 |
from .config import (
|
| 25 |
BUILD_DIR,
|
| 26 |
REPO_ROOT,
|
|
@@ -568,12 +568,11 @@ def verify_baked(cfg: Config, tags: Dict[str, str], manifest: Dict) -> int:
|
|
| 568 |
# load, not just a process coming up. RESTORE_RUN_ID pins the restore
|
| 569 |
# to this run: latest.json may name another one (`upload --no-latest`).
|
| 570 |
token = cfg.siglip2_nvcf_env()["SIGLIP2_TRITON_SERVER_AUTH_TOKEN"]
|
| 571 |
-
aws =
|
| 572 |
result = subprocess.run(
|
| 573 |
["docker", "run", "--rm", "-d", "-p", "17860:7860",
|
| 574 |
"-e", f"SIGLIP2_TRITON_SERVER_AUTH_TOKEN={token}",
|
| 575 |
-
"-e", f"
|
| 576 |
-
"-e", f"SIMREADYCENTRAL_INDEX_STORE_AWS_SECRET_ACCESS_KEY={aws['AWS_SECRET_ACCESS_KEY']}",
|
| 577 |
"-e", f"RESTORE_RUN_ID={manifest['run_id']}",
|
| 578 |
tags["hf_space"]],
|
| 579 |
capture_output=True, text=True, check=True, timeout=60,
|
|
@@ -674,11 +673,10 @@ def verify_baked(cfg: Config, tags: Dict[str, str], manifest: Dict) -> int:
|
|
| 674 |
# pipeline.md Β§12) doesn't enable it. No NVCF token needed. AWS keys
|
| 675 |
# still are β the index restore path is identical to the NVCF
|
| 676 |
# variant's.
|
| 677 |
-
aws =
|
| 678 |
result = subprocess.run(
|
| 679 |
["docker", "run", "--rm", "-d", "-p", "17861:7860", "--gpus", "all",
|
| 680 |
-
"-e", f"
|
| 681 |
-
"-e", f"SIMREADYCENTRAL_INDEX_STORE_AWS_SECRET_ACCESS_KEY={aws['AWS_SECRET_ACCESS_KEY']}",
|
| 682 |
"-e", f"RESTORE_RUN_ID={manifest['run_id']}",
|
| 683 |
tags["hf_space_gpu"]],
|
| 684 |
capture_output=True, text=True, check=True, timeout=60,
|
|
|
|
| 20 |
from typing import Dict, List, Optional
|
| 21 |
|
| 22 |
from . import hf_addressing
|
| 23 |
+
from .artifact_store import space_artifact_secrets
|
| 24 |
from .config import (
|
| 25 |
BUILD_DIR,
|
| 26 |
REPO_ROOT,
|
|
|
|
| 568 |
# load, not just a process coming up. RESTORE_RUN_ID pins the restore
|
| 569 |
# to this run: latest.json may name another one (`upload --no-latest`).
|
| 570 |
token = cfg.siglip2_nvcf_env()["SIGLIP2_TRITON_SERVER_AUTH_TOKEN"]
|
| 571 |
+
aws = space_artifact_secrets() # the read-only keys the Space itself gets
|
| 572 |
result = subprocess.run(
|
| 573 |
["docker", "run", "--rm", "-d", "-p", "17860:7860",
|
| 574 |
"-e", f"SIGLIP2_TRITON_SERVER_AUTH_TOKEN={token}",
|
| 575 |
+
*(flag for key, value in aws.items() for flag in ("-e", f"{key}={value}")),
|
|
|
|
| 576 |
"-e", f"RESTORE_RUN_ID={manifest['run_id']}",
|
| 577 |
tags["hf_space"]],
|
| 578 |
capture_output=True, text=True, check=True, timeout=60,
|
|
|
|
| 673 |
# pipeline.md Β§12) doesn't enable it. No NVCF token needed. AWS keys
|
| 674 |
# still are β the index restore path is identical to the NVCF
|
| 675 |
# variant's.
|
| 676 |
+
aws = space_artifact_secrets() # the read-only keys the Space itself gets
|
| 677 |
result = subprocess.run(
|
| 678 |
["docker", "run", "--rm", "-d", "-p", "17861:7860", "--gpus", "all",
|
| 679 |
+
*(flag for key, value in aws.items() for flag in ("-e", f"{key}={value}")),
|
|
|
|
| 680 |
"-e", f"RESTORE_RUN_ID={manifest['run_id']}",
|
| 681 |
tags["hf_space_gpu"]],
|
| 682 |
capture_output=True, text=True, check=True, timeout=60,
|
pipeline/hf_space.py
CHANGED
|
@@ -51,7 +51,7 @@ from typing import Dict, List
|
|
| 51 |
from huggingface_hub import HfApi, SpaceHardware
|
| 52 |
from huggingface_hub.errors import HfHubHTTPError
|
| 53 |
|
| 54 |
-
from .artifact_store import
|
| 55 |
from .bake import DOCKER_DIR, hf_space_build_args, hf_space_gpu_build_args, image_tags
|
| 56 |
from .config import BUILD_DIR, HF_SPACE_GPU_HARDWARE_DEFAULT, REPO_ROOT, Config
|
| 57 |
from .corpus import Corpus
|
|
@@ -242,7 +242,7 @@ def run(cfg: Config) -> int:
|
|
| 242 |
repo_id = cfg.require("HF_SPACE_REPO_ID") # e.g. "nvidia/simready-central"
|
| 243 |
title = cfg.get("HF_SPACE_TITLE", repo_id.split("/", 1)[-1])
|
| 244 |
siglip2_token = cfg.siglip2_nvcf_env()["SIGLIP2_TRITON_SERVER_AUTH_TOKEN"]
|
| 245 |
-
aws =
|
| 246 |
|
| 247 |
print(f"staging Space source at {STAGE_DIR} ...")
|
| 248 |
stage_repo(STAGE_DIR, deploy_marker(manifest), README_TEMPLATE.format(title=title))
|
|
@@ -264,14 +264,15 @@ def run(cfg: Config) -> int:
|
|
| 264 |
api.add_space_variable(repo_id, key, value)
|
| 265 |
|
| 266 |
print("setting runtime secrets ...")
|
| 267 |
-
# Names must match what pipeline/artifact_store.py's artifact_env()
|
|
|
|
| 268 |
# config.py's siglip2_nvcf_env() read from the environment β Hugging
|
| 269 |
# Face injects Space secrets as plain runtime env vars, so no separate
|
| 270 |
# "buildtime" naming/mounting is needed (see hf_space_seed.py's
|
| 271 |
# docstring for why this pipeline restores at runtime rather than build
|
| 272 |
# time in the first place).
|
| 273 |
-
|
| 274 |
-
|
| 275 |
api.add_space_secret(repo_id, "SIGLIP2_TRITON_SERVER_AUTH_TOKEN", siglip2_token)
|
| 276 |
|
| 277 |
sync_storage_api_token(api, repo_id)
|
|
@@ -332,7 +333,7 @@ def run_gpu(cfg: Config) -> int:
|
|
| 332 |
repo_id = cfg.require("HF_SPACE_REPO_ID_GPU") # e.g. "nvidia/simready-central-gpu"
|
| 333 |
title = cfg.get("HF_SPACE_TITLE_GPU", repo_id.split("/", 1)[-1])
|
| 334 |
hardware = cfg.get("HF_SPACE_GPU_HARDWARE", HF_SPACE_GPU_HARDWARE_DEFAULT)
|
| 335 |
-
aws =
|
| 336 |
|
| 337 |
print(f"staging Space source at {STAGE_DIR_GPU} ...")
|
| 338 |
stage_repo(
|
|
@@ -362,8 +363,8 @@ def run_gpu(cfg: Config) -> int:
|
|
| 362 |
# No SIGLIP2_TRITON_SERVER_AUTH_TOKEN here β this variant's local
|
| 363 |
# siglip2-triton process has no auth in front of it (loopback-only,
|
| 364 |
# same as OpenSearch/Neo4j/Redis in this image).
|
| 365 |
-
|
| 366 |
-
|
| 367 |
|
| 368 |
sync_storage_api_token(api, repo_id)
|
| 369 |
|
|
|
|
| 51 |
from huggingface_hub import HfApi, SpaceHardware
|
| 52 |
from huggingface_hub.errors import HfHubHTTPError
|
| 53 |
|
| 54 |
+
from .artifact_store import space_artifact_secrets
|
| 55 |
from .bake import DOCKER_DIR, hf_space_build_args, hf_space_gpu_build_args, image_tags
|
| 56 |
from .config import BUILD_DIR, HF_SPACE_GPU_HARDWARE_DEFAULT, REPO_ROOT, Config
|
| 57 |
from .corpus import Corpus
|
|
|
|
| 242 |
repo_id = cfg.require("HF_SPACE_REPO_ID") # e.g. "nvidia/simready-central"
|
| 243 |
title = cfg.get("HF_SPACE_TITLE", repo_id.split("/", 1)[-1])
|
| 244 |
siglip2_token = cfg.siglip2_nvcf_env()["SIGLIP2_TRITON_SERVER_AUTH_TOKEN"]
|
| 245 |
+
aws = space_artifact_secrets() # raises if the read-only artifact-bucket keys aren't set
|
| 246 |
|
| 247 |
print(f"staging Space source at {STAGE_DIR} ...")
|
| 248 |
stage_repo(STAGE_DIR, deploy_marker(manifest), README_TEMPLATE.format(title=title))
|
|
|
|
| 264 |
api.add_space_variable(repo_id, key, value)
|
| 265 |
|
| 266 |
print("setting runtime secrets ...")
|
| 267 |
+
# Names must match what pipeline/artifact_store.py's artifact_env() (in
|
| 268 |
+
# the Space; the values are the read-only pair) and
|
| 269 |
# config.py's siglip2_nvcf_env() read from the environment β Hugging
|
| 270 |
# Face injects Space secrets as plain runtime env vars, so no separate
|
| 271 |
# "buildtime" naming/mounting is needed (see hf_space_seed.py's
|
| 272 |
# docstring for why this pipeline restores at runtime rather than build
|
| 273 |
# time in the first place).
|
| 274 |
+
for key, value in aws.items():
|
| 275 |
+
api.add_space_secret(repo_id, key, value)
|
| 276 |
api.add_space_secret(repo_id, "SIGLIP2_TRITON_SERVER_AUTH_TOKEN", siglip2_token)
|
| 277 |
|
| 278 |
sync_storage_api_token(api, repo_id)
|
|
|
|
| 333 |
repo_id = cfg.require("HF_SPACE_REPO_ID_GPU") # e.g. "nvidia/simready-central-gpu"
|
| 334 |
title = cfg.get("HF_SPACE_TITLE_GPU", repo_id.split("/", 1)[-1])
|
| 335 |
hardware = cfg.get("HF_SPACE_GPU_HARDWARE", HF_SPACE_GPU_HARDWARE_DEFAULT)
|
| 336 |
+
aws = space_artifact_secrets() # raises if the read-only keys aren't set β no NVCF token needed here
|
| 337 |
|
| 338 |
print(f"staging Space source at {STAGE_DIR_GPU} ...")
|
| 339 |
stage_repo(
|
|
|
|
| 363 |
# No SIGLIP2_TRITON_SERVER_AUTH_TOKEN here β this variant's local
|
| 364 |
# siglip2-triton process has no auth in front of it (loopback-only,
|
| 365 |
# same as OpenSearch/Neo4j/Redis in this image).
|
| 366 |
+
for key, value in aws.items():
|
| 367 |
+
api.add_space_secret(repo_id, key, value)
|
| 368 |
|
| 369 |
sync_storage_api_token(api, repo_id)
|
| 370 |
|