Repository navigation
fix(jobs): derive the default Job name from the last path component on both separators - #5360
Closed
inchang-ing wants to merge 2 commits into
Closed
inchang-ing wants to merge 2 commits into
inchang-ing wants to merge 2 commits into
Conversation
…n both separators `_default_job_name_from_script` split the script path only on `/`, so Windows paths leaked straight into the auto-generated Job name: `.\train.py` (what PowerShell tab completion inserts) became `--train-<hash>`, and an absolute `C:\Users\...\train.py` became `C--Users-alice-projects-sft-train-<hash>` -- putting the local directory layout and the username into the Job's `name` label. A long path also made the 100-character cut from huggingface#5306 land before the script name. Split the last component on both separators and strip both of them from the tail before hashing. The hash input is unchanged, and POSIX paths behave exactly as before. Regression tests: `.\train.py`, an absolute Windows path, `./train.py` and a POSIX absolute path all resolve to `train-<hash>`; they fail on main (`--train-<hash>` / `C--Users-...-train-<hash>`). Closes huggingface#5359 AI-assisted change, disclosed per repo policy. Signed-off-by: inchang-ing <197932532+inchang-ing@users.noreply.github.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5360 +/- ##
==========================================
+ Coverage 75.00% 77.62% +2.61%
==========================================
Files 145 178 +33
Lines 13978 25444 +11466
==========================================
+ Hits 10484 19750 +9266
- Misses 3494 5694 +2200 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
superseded by #5388 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5359
Problem
_default_job_name_from_scriptsplit the script path only on/, so Windows paths leaked straight into the auto-generated Job name:.\train.py(what PowerShell tab completion inserts) →--train-<hash>C:\Users\...\train.py→C--Users-alice-projects-sft-train-<hash>, putting the local directory layout and the username into the Job'snamelabelA long path also made the 100-character cut from #5306 land before the script name, so the name no longer mentioned the script at all. The script itself resolved correctly — only the name was wrong.
Fix
Split the last path component on both separators (
re.split(r"[\\/]", ...)) and strip both from the tail before hashing. The hash input is unchanged, and POSIX paths behave exactly as before. This follows the reporter's suggested shape.Testing
New parametrized cases in
test_default_job_name_from_script_windows_paths:.\train.py, an absolute Windows path,./train.pyand a POSIX absolute path all resolve totrain-<hash>. The two Windows cases fail onmain(--train-<hash>andC--Users-...-train-<hash>); the POSIX cases keep passing either way.Full
tests/test_jobs_api.py: 28 passed.AI-assisted change.
Note
Low Risk
Localized naming helper change with regression tests; no change to job submission payload or hashing semantics beyond the display prefix.
Overview
Fixes auto-generated Hub Job names when the launch script is given as a Windows path (e.g. PowerShell
.\train.pyorC:\Users\...\train.py)._default_job_name_from_scriptpreviously took the “last segment” using/only, so backslashes left directory paths (and sometimes usernames) in the label and could push the script stem out of the 100-character limit after sanitization.The name base is now derived with
re.spliton both/and\, and trailing separators are stripped on both. Hash inputs and POSIX behavior are unchanged; only the human-readable prefix is corrected.Adds parametrized tests for Windows relative/absolute paths alongside existing POSIX cases.
Reviewed by Cursor Bugbot for commit 3b80452. Bugbot is set up for automated code reviews on this repo. Configure here.