Commit c566bbf
authored
fix(setup): don't fail mount on empty bucket subfolder (#208)
## Problem
Running an HF Job with a bucket volume pointing at an empty (or
not-yet-created) subfolder fails the mount before the job starts,
surfacing as a `MountFailure`.
`validate_path_prefix()` (`src/hub_api.rs`) runs before mounting and
treats an empty listing as "does not exist", then `src/setup.rs` panics
the sidecar via `.unwrap_or_else(|e| panic!(...))`. For a bucket this is
wrong: a subfolder that is empty and one that does not exist are
indistinguishable (both list as `[]`), because bucket keys are flat and
a prefix only "exists" if there are objects under it.
This blocks exactly the case you'd want to support: mounting an
empty/new subfolder in order to write into it. The validation also ran
before `read_only` was computed, so it even blocked write mounts.
- Direct mount of an empty bucket subfolder (`-v
hf://buckets/org/b/sub/dir:/mnt`) hits the bug.
- Bucket root (`-v hf://buckets/org/b:/mnt`) is fine (validation skipped
for an empty prefix).
- Local-dir sources are fine because `huggingface_hub` works around this
by uploading a `.keep` placeholder.
## Fix
Move the validation after `read_only` is computed and only run it for
read-only mounts, warning instead of panicking:
- **Write mounts**: skip the check entirely. The folder is created by
writing into it.
- **Read-only mounts**: a missing/empty prefix just yields an empty
mount, so we `warn!` instead of panicking the sidecar. This keeps the
fail-fast hint for typo'd subfolders without killing the job.
This removes the failure at the source and makes the `.keep` placeholder
in `huggingface_hub` (`sync_job_volume`) unnecessary for bucket sources.1 parent 4cdeedc commit c566bbf
1 file changed
Lines changed: 15 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | 390 | | |
400 | 391 | | |
401 | 392 | | |
| |||
407 | 398 | | |
408 | 399 | | |
409 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
410 | 416 | | |
411 | 417 | | |
412 | 418 | | |
| |||
0 commit comments