Commit
·
02b47e6
1
Parent(s):
4ea6260
Fix HF Jobs compatibility: handle non-interactive environments and update examples
Browse files- README.md +2 -1
- atlas-export.py +17 -7
README.md
CHANGED
@@ -53,7 +53,8 @@ uv run atlas-export.py \
|
|
53 |
|
54 |
```bash
|
55 |
# Run on HF Jobs with GPU for faster embedding generation
|
56 |
-
hf jobs run --
|
|
|
57 |
uv run https://huggingface.co/datasets/uv-scripts/build-atlas/raw/main/atlas-export.py \
|
58 |
stanfordnlp/imdb \
|
59 |
--space-name imdb-viz \
|
|
|
53 |
|
54 |
```bash
|
55 |
# Run on HF Jobs with GPU for faster embedding generation
|
56 |
+
hf jobs run vllm/vllm-openai:latest --flavor t4-small \
|
57 |
+
-s HF_TOKEN=$HF_TOKEN \
|
58 |
uv run https://huggingface.co/datasets/uv-scripts/build-atlas/raw/main/atlas-export.py \
|
59 |
stanfordnlp/imdb \
|
60 |
--space-name imdb-viz \
|
atlas-export.py
CHANGED
@@ -26,8 +26,9 @@ Example usage:
|
|
26 |
--model openai/clip-vit-base-patch32 \
|
27 |
--sample 10000
|
28 |
|
29 |
-
# Run on HF Jobs with GPU (
|
30 |
-
hf jobs run --
|
|
|
31 |
uv run https://huggingface.co/datasets/uv-scripts/build-atlas/raw/main/atlas-export.py \
|
32 |
my-dataset \
|
33 |
--space-name my-atlas \
|
@@ -350,10 +351,19 @@ def main():
|
|
350 |
if hf_token:
|
351 |
login(token=hf_token)
|
352 |
else:
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
|
358 |
# Set up output directory
|
359 |
if args.output_dir:
|
@@ -424,7 +434,7 @@ if __name__ == "__main__":
|
|
424 |
print("# With custom model and sampling:")
|
425 |
print("uv run atlas-export.py my-dataset --space-name my-viz --model nomic-ai/nomic-embed-text-v1.5 --sample 10000\n")
|
426 |
print("# For HF Jobs with GPU:")
|
427 |
-
print("hf jobs run --
|
428 |
print("# Local generation only:")
|
429 |
print("uv run atlas-export.py dataset --space-name test --local-only --output-dir ./atlas-output")
|
430 |
sys.exit(0)
|
|
|
26 |
--model openai/clip-vit-base-patch32 \
|
27 |
--sample 10000
|
28 |
|
29 |
+
# Run on HF Jobs with GPU (requires HF token for Space deployment)
|
30 |
+
hf jobs run vllm/vllm-openai:latest --flavor t4-small \
|
31 |
+
-s HF_TOKEN=$HF_TOKEN \
|
32 |
uv run https://huggingface.co/datasets/uv-scripts/build-atlas/raw/main/atlas-export.py \
|
33 |
my-dataset \
|
34 |
--space-name my-atlas \
|
|
|
351 |
if hf_token:
|
352 |
login(token=hf_token)
|
353 |
else:
|
354 |
+
# Check if running in non-interactive environment (HF Jobs, CI, etc.)
|
355 |
+
is_interactive = sys.stdin.isatty()
|
356 |
+
|
357 |
+
if is_interactive:
|
358 |
+
logger.warning("No HF token provided. You may not be able to push to the Hub.")
|
359 |
+
response = input("Continue anyway? (y/n): ")
|
360 |
+
if response.lower() != 'y':
|
361 |
+
sys.exit(0)
|
362 |
+
else:
|
363 |
+
# In non-interactive environments, fail immediately if no token
|
364 |
+
logger.error("No HF token provided. Cannot deploy to Space in non-interactive environment.")
|
365 |
+
logger.error("Please set HF_TOKEN environment variable or use --hf-token argument.")
|
366 |
+
sys.exit(1)
|
367 |
|
368 |
# Set up output directory
|
369 |
if args.output_dir:
|
|
|
434 |
print("# With custom model and sampling:")
|
435 |
print("uv run atlas-export.py my-dataset --space-name my-viz --model nomic-ai/nomic-embed-text-v1.5 --sample 10000\n")
|
436 |
print("# For HF Jobs with GPU:")
|
437 |
+
print("hf jobs run vllm/vllm-openai:latest --flavor t4-small -s HF_TOKEN=$HF_TOKEN uv run https://huggingface.co/datasets/uv-scripts/build-atlas/raw/main/atlas-export.py dataset --space-name viz --model sentence-transformers/all-mpnet-base-v2\n")
|
438 |
print("# Local generation only:")
|
439 |
print("uv run atlas-export.py dataset --space-name test --local-only --output-dir ./atlas-output")
|
440 |
sys.exit(0)
|