Repository navigation
[Jobs] Manage public and private exposed ports - #5027
Merged
Merged
Conversation
|
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. |
Public ports are merged into the exposed ports list client-side, since the server only requires portsPublic to be a subset of ports at the wire level. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Wauplin
marked this pull request as ready for review
September 29, 2026 10:11
'hf jobs expose <id> 8000 --public 9000' instead of 'hf jobs expose <id> --expose 8000 --expose-public 9000'. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The CLI framework adds --format/--json/--quiet automatically. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
|
This PR has been shipped as part of the v2.1.0 release. |
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.
Summary
expose_publicand--expose-publicwhen creating Docker, UV, or scheduled Jobs. The server acceptsportsPublicat creation; the client previously sent only token-protectedports.update_job_exposeandhf jobs expose <job_id> [PORTS]... [--public PORT]to replace ports on a running Job.--clearcloses all exposed ports.JobInfoand scheduledJobSpec, and document both modes.expose(token-protected) andexpose_public(unauthenticated) are independent: a public port does not need to be listed inexposetoo. The server requiresportsPublicto be a subset ofports(it returns400 portsPublic must be a subset of portsotherwise), but that is a wire-format detail. The client merges public ports intoportsbefore sending, so users don't have to repeat themselves (--expose-public 8000instead of--expose 8000 --expose-public 8000). OnJobInfo,exposestill reflects the server'sportsfield, which means it lists all exposed ports, public ones included.hf jobs exposetakes token-protected ports as positional arguments and public ports with--public(hf jobs expose <job_id> 8000 --public 9000). The command name already says "expose", sohf jobs expose <job_id> --expose 8000 --expose-public 9000would repeat it.hf jobs runkeeps--expose/--expose-public, because there the flags sit next to many unrelated options.update_job_exposereplaces the full configuration, as required by the endpoint: ports that are in neitherexposenorexpose_publicare closed. Calling it with neither list closes all ports.Example
Start a Job with a public HTTP server:
Switch the port to token-protected access on the running Job:
Mix private and public ports, then close everything:
The Job was canceled afterward.
make style,make quality, and targeted Jobs CLI/API tests pass. One pure payload check was added (public ports merged intoports); no new mocked endpoint tests.🤖 Generated with Claude Code
Note
Medium Risk
Changes Jobs networking and authentication (public vs token-protected ports) and adds a live port-reconfiguration API; misconfiguration could expose services without auth, though behavior is explicit and documented.
Overview
Adds unauthenticated port exposure for Hub Jobs alongside the existing token-protected
--expose/exposeflow, and lets you change exposed ports on a running Job without restarting it.Creation time:
expose_publicand--expose-publicare wired throughrun_job,run_uv_job, and scheduled job APIs/CLI. The client builds the Hub payload via_build_expose_payload, merging public ports intoportssoportsPublicstays a subset ofportswithout users duplicating port numbers.Runtime updates: New
HfApi.update_job_expose(exported asupdate_job_expose)PUTs/api/jobs/{namespace}/{job_id}/exposeand replaces the full port set—omitted ports are closed; calling with no lists clears everything. CLI:hf jobs expose <job_id> [PORTS]... [--public PORT]... [--clear].Models & UX:
JobInfo/JobSpecsurfaceexposeandexpose_publicfrom the API; docs and CLI reference are updated. Post-run hints no longer assume every exposed URL requires a token.Reviewed by Cursor Bugbot for commit b629e7c. Bugbot is set up for automated code reviews on this repo. Configure here.