Skip to content

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
huggingface:mainfrom
inchang-ing:fix/job-name-windows-paths
Closed

inchang-ing wants to merge 2 commits into
huggingface:mainfrom
inchang-ing:fix/job-name-windows-paths

Conversation

@inchang-ing

@inchang-ing inchang-ing commented Nov 14, 2026 •

Copy link
Copy Markdown

Closes #5359

Problem

_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) → --train-<hash>
  • an absolute C:\Users\...\train.py → 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 #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.py and a POSIX absolute path all resolve to train-<hash>. The two Windows cases fail on main (--train-<hash> and C--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.py or C:\Users\...\train.py). _default_job_name_from_script previously 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.split on 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.

inchang-ing and others added 2 commits November 14, 2026 13:43
…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>
@bot-ci-comment

Copy link
Copy Markdown

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

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.62%. Comparing base (1daa48b) to head (3b80452).
⚠️ Report is 861 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Wauplin

Wauplin commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

superseded by #5388

@Wauplin Wauplin closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Jobs] Auto-generated Job name uses the whole Windows script path (.\train.py -> --train-<hash>)

2 participants