Sync from GitHub via hub-sync
Browse files- README.md +4 -10
- optimize-parquet.py +4 -11
README.md
CHANGED
|
@@ -50,18 +50,12 @@ Use `hf jobs run ... uv run <url>` here, not `hf jobs uv run <url>`. `hf jobs uv
|
|
| 50 |
|
| 51 |
**2. Create a webhook on the input bucket that re-runs this Job:**
|
| 52 |
|
| 53 |
-
```
|
| 54 |
-
from
|
| 55 |
-
|
| 56 |
-
create_webhook(
|
| 57 |
-
job_id="<job id from step 1>",
|
| 58 |
-
watched=[{"type": "bucket", "name": "<user>/my-raw-files"}],
|
| 59 |
-
domains=["repo"],
|
| 60 |
-
secret="<fine-grained token>",
|
| 61 |
-
)
|
| 62 |
```
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
**3. Upload a file:**
|
| 67 |
|
|
|
|
| 50 |
|
| 51 |
**2. Create a webhook on the input bucket that re-runs this Job:**
|
| 52 |
|
| 53 |
+
```bash
|
| 54 |
+
hf webhooks create --job-id <job id from step 1> \
|
| 55 |
+
--watch bucket:<user>/my-raw-files --domain repo --secrets HF_TOKEN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
```
|
| 57 |
|
| 58 |
+
`--secrets HF_TOKEN` stores a token with the webhook, encrypted, and every triggered run receives it as a secret to read and write the buckets. The value comes from `HF_TOKEN` in your environment, or from the token you logged in with; pass `--secrets HF_TOKEN=hf_…` to use a different one. Use a fine-grained token, not your main one. The base Job needs no `--secrets`, because a webhook run does not inherit the Job's own secrets.
|
| 59 |
|
| 60 |
**3. Upload a file:**
|
| 61 |
|
optimize-parquet.py
CHANGED
|
@@ -19,13 +19,10 @@ Setup (once):
|
|
| 19 |
uv run https://huggingface.co/datasets/uv-scripts/data-processing/raw/main/optimize-parquet.py
|
| 20 |
|
| 21 |
# 2. A webhook on the input bucket that re-runs that Job on every change.
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
domains=["repo"],
|
| 27 |
-
secret="<fine-grained token>",
|
| 28 |
-
)
|
| 29 |
|
| 30 |
Then upload files to the input bucket, e.g.
|
| 31 |
`hf buckets cp data.csv hf://buckets/<user>/<input-bucket>/data.csv`,
|
|
@@ -40,10 +37,6 @@ from pathlib import PurePosixPath
|
|
| 40 |
|
| 41 |
from datasets import load_dataset
|
| 42 |
|
| 43 |
-
# Use the webhook secret as the token when HF_TOKEN is not set.
|
| 44 |
-
if "HF_TOKEN" not in os.environ and "WEBHOOK_SECRET" in os.environ:
|
| 45 |
-
os.environ["HF_TOKEN"] = os.environ["WEBHOOK_SECRET"]
|
| 46 |
-
|
| 47 |
BUILDERS = {".csv": "csv", ".json": "json", ".jsonl": "json", ".parquet": "parquet"}
|
| 48 |
|
| 49 |
event = json.loads(os.environ.get("WEBHOOK_PAYLOAD", "{}"))
|
|
|
|
| 19 |
uv run https://huggingface.co/datasets/uv-scripts/data-processing/raw/main/optimize-parquet.py
|
| 20 |
|
| 21 |
# 2. A webhook on the input bucket that re-runs that Job on every change.
|
| 22 |
+
# --secrets HF_TOKEN gives every triggered run a token for the two buckets;
|
| 23 |
+
# a webhook run does not inherit the base Job's own secrets.
|
| 24 |
+
hf webhooks create --job-id <job id from step 1> \\
|
| 25 |
+
--watch bucket:<user>/<input-bucket> --domain repo --secrets HF_TOKEN
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
Then upload files to the input bucket, e.g.
|
| 28 |
`hf buckets cp data.csv hf://buckets/<user>/<input-bucket>/data.csv`,
|
|
|
|
| 37 |
|
| 38 |
from datasets import load_dataset
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
BUILDERS = {".csv": "csv", ".json": "json", ".jsonl": "json", ".parquet": "parquet"}
|
| 41 |
|
| 42 |
event = json.loads(os.environ.get("WEBHOOK_PAYLOAD", "{}"))
|