You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/guides/cli.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2116,6 +2116,20 @@ Pass `--ssh` to `hf jobs run` (or `hf jobs uv run`) to make the Job's container
2116
2116
2117
2117
Only users with write access to the Job's namespace are allowed in (the Job creator, or members of the owner organization), authenticated by an SSH public key registered at https://huggingface.co/settings/keys.
2118
2118
2119
+
### Network groups
2120
+
2121
+
Pass `--network-group <name>` to `hf jobs run` (or `hf jobs uv run`) to let Jobs of the same owner reach each other on every port. Inside each member, `$HF_NETWORK_GROUP_HOSTNAME` resolves to every Job in the group, and `${HF_NETWORK_GROUP_PREFIX}<alias>` to the members that claimed an alias with `--network-alias <alias>`:
2122
+
2123
+
```bash
2124
+
# Start a server, reachable by the other members of the group as "master"
2125
+
>>> hf jobs run --detach --network-group train --network-alias master python:3.12 python -m http.server 8000
2126
+
2127
+
# Start a client in the same group
2128
+
>>> hf jobs run --detach --network-group train python:3.12 sh -c 'curl --retry 10 --retry-connrefused "http://${HF_NETWORK_GROUP_PREFIX}master:8000/"'
2129
+
```
2130
+
2131
+
Members are resolvable before they are ready, so connect with retries.
2132
+
2119
2133
### UV Scripts (Experimental)
2120
2134
2121
2135
Run UV scripts (Python scripts with inline dependencies) on HF infrastructure. UV scripts are Python scripts that include their dependencies directly in the file using a special comment syntax.
Copy file name to clipboardExpand all lines: docs/source/en/guides/jobs.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -372,6 +372,27 @@ Connect from a terminal with `hf jobs ssh <job_id>` (or directly with `ssh <job_
372
372
373
373
Only users with write access to the Job's namespace are allowed in (the Job creator, or members of the owner organization), authenticated by an SSH public key registered at https://huggingface.co/settings/keys.
374
374
375
+
## Network groups
376
+
377
+
Pass `network_group="<name>"` to [`run_job`] (or [`run_uv_job`]) to let Jobs of the same owner reach each other on every port. Inside each member, `HF_NETWORK_GROUP_HOSTNAME` resolves to every Job in the group, and `${HF_NETWORK_GROUP_PREFIX}<alias>` to the members that claimed an alias with `network_aliases=[...]`:
Members are resolvable before they are ready, so connect with retries.
395
+
375
396
## Configure Job Timeout
376
397
377
398
Jobs have a default timeout (30 minutes), after which they will automatically stop. This is important to know when running long-running tasks like model training.
Copy file name to clipboardExpand all lines: docs/source/en/package_reference/cli.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2505,6 +2505,8 @@ $ hf jobs run [OPTIONS] IMAGE COMMAND...
2505
2505
*`-d, --detach`: Run the Job in the background and print the Job ID.
2506
2506
*`--expose INTEGER`: Expose a container port through the jobs proxy. Repeat the flag for multiple ports (e.g. `--expose 8000 --expose 8001`). Each exposed port is reachable on the public jobs domain; access requires an HF token with read access to the job's namespace.
2507
2507
*`--ssh`: Make the job's container reachable over SSH. Connect with `hf jobs ssh <job_id>`. Requires an SSH public key registered on https://huggingface.co/settings/keys.
2508
+
*`--network-group TEXT`: Join a network group. Jobs of the same owner sharing a group are placed together and reach each other on every port. Inside each member, `$HF_NETWORK_GROUP_HOSTNAME` resolves to every member. Lowercase alphanumerics and dashes, 46 characters max.
2509
+
*`--network-alias TEXT`: Claim an alias in the network group. Members reach the jobs claiming it at `${HF_NETWORK_GROUP_PREFIX}<alias>`. Repeat the flag for several aliases. Requires `--network-group`.
2508
2510
*`--resource-group-id TEXT`: The ID of the resource group to create the Job in. Used to control access to resources within an organization and for cost attribution/spending-limit features.
2509
2511
*`--namespace TEXT`: The namespace where the job will be running. Defaults to the current user's namespace.
2510
2512
*`--token TEXT`: A User Access Token generated from https://huggingface.co/settings/tokens.
@@ -2977,6 +2979,8 @@ $ hf jobs uv run [OPTIONS] SCRIPT [SCRIPT_ARGS]...
2977
2979
*`-d, --detach`: Run the Job in the background and print the Job ID.
2978
2980
*`--expose INTEGER`: Expose a container port through the jobs proxy. Repeat the flag for multiple ports (e.g. `--expose 8000 --expose 8001`). Each exposed port is reachable on the public jobs domain; access requires an HF token with read access to the job's namespace.
2979
2981
*`--ssh`: Make the job's container reachable over SSH. Connect with `hf jobs ssh <job_id>`. Requires an SSH public key registered on https://huggingface.co/settings/keys.
2982
+
*`--network-group TEXT`: Join a network group. Jobs of the same owner sharing a group are placed together and reach each other on every port. Inside each member, `$HF_NETWORK_GROUP_HOSTNAME` resolves to every member. Lowercase alphanumerics and dashes, 46 characters max.
2983
+
*`--network-alias TEXT`: Claim an alias in the network group. Members reach the jobs claiming it at `${HF_NETWORK_GROUP_PREFIX}<alias>`. Repeat the flag for several aliases. Requires `--network-group`.
2980
2984
*`--resource-group-id TEXT`: The ID of the resource group to create the Job in. Used to control access to resources within an organization and for cost attribution/spending-limit features.
2981
2985
*`--namespace TEXT`: The namespace where the job will be running. Defaults to the current user's namespace.
2982
2986
*`--token TEXT`: A User Access Token generated from https://huggingface.co/settings/tokens.
help="Join a network group. Jobs of the same owner sharing a group are placed together and reach each other on every port. Inside each member, `$HF_NETWORK_GROUP_HOSTNAME` resolves to every member. Lowercase alphanumerics and dashes, 46 characters max.",
224
+
),
225
+
]
226
+
227
+
NetworkAliasOpt=Annotated[
228
+
list[str] |None,
229
+
Option(
230
+
"--network-alias",
231
+
help="Claim an alias in the network group. Members reach the jobs claiming it at `${HF_NETWORK_GROUP_PREFIX}<alias>`. Repeat the flag for several aliases. Requires `--network-group`.",
232
+
),
233
+
]
234
+
219
235
WithOpt=Annotated[
220
236
list[str] |None,
221
237
Option(
@@ -353,6 +369,8 @@ def jobs_run(
353
369
detach: DetachOpt=False,
354
370
expose: ExposeOpt=None,
355
371
ssh: SshEnabledOpt=False,
372
+
network_group: NetworkGroupOpt=None,
373
+
network_alias: NetworkAliasOpt=None,
356
374
resource_group_id: ResourceGroupIdOpt=None,
357
375
namespace: NamespaceOpt=None,
358
376
token: TokenOpt=None,
@@ -373,6 +391,8 @@ def jobs_run(
373
391
timeout=timeout,
374
392
expose=expose,
375
393
ssh=ssh,
394
+
network_group=network_group,
395
+
network_aliases=network_alias,
376
396
resource_group_id=resource_group_id,
377
397
namespace=namespace,
378
398
)
@@ -388,6 +408,11 @@ def jobs_run(
388
408
out.hint(f"Exposed ports are reachable at (requires an HF token with read access to the job):\n{urls}")
389
409
ifisinstance(job.status.ssh_url, str):
390
410
out.hint(f"Use `hf jobs ssh {job.owner.name}/{job.id}` to open an SSH session into the job.")
411
+
ifnetwork_group:
412
+
out.hint(
413
+
f"Joined network group '{network_group}'. Jobs started with `--network-group {network_group}` reach each other "
414
+
"at `$HF_NETWORK_GROUP_HOSTNAME` (every member) or `${HF_NETWORK_GROUP_PREFIX}<alias>` (members claiming an alias)."
415
+
)
391
416
ifdetach:
392
417
job_ref=f"{job.owner.name}/{job.id}"
393
418
out.hint(f"Use `hf jobs logs -f {job_ref}` to stream logs, or `hf jobs inspect {job_ref}` to check status.")
@@ -938,6 +963,8 @@ def jobs_uv_run(
938
963
detach: DetachOpt=False,
939
964
expose: ExposeOpt=None,
940
965
ssh: SshEnabledOpt=False,
966
+
network_group: NetworkGroupOpt=None,
967
+
network_alias: NetworkAliasOpt=None,
941
968
resource_group_id: ResourceGroupIdOpt=None,
942
969
namespace: NamespaceOpt=None,
943
970
token: TokenOpt=None,
@@ -963,6 +990,8 @@ def jobs_uv_run(
963
990
timeout=timeout,
964
991
expose=expose,
965
992
ssh=ssh,
993
+
network_group=network_group,
994
+
network_aliases=network_alias,
966
995
resource_group_id=resource_group_id,
967
996
namespace=namespace,
968
997
)
@@ -978,6 +1007,11 @@ def jobs_uv_run(
978
1007
out.hint(f"Exposed ports are reachable at (requires an HF token with read access to the job):\n{urls}")
979
1008
ifisinstance(job.status.ssh_url, str):
980
1009
out.hint(f"Use `hf jobs ssh {job.owner.name}/{job.id}` to open an SSH session into the job.")
1010
+
ifnetwork_group:
1011
+
out.hint(
1012
+
f"Joined network group '{network_group}'. Jobs started with `--network-group {network_group}` reach each other "
1013
+
"at `$HF_NETWORK_GROUP_HOSTNAME` (every member) or `${HF_NETWORK_GROUP_PREFIX}<alias>` (members claiming an alias)."
1014
+
)
981
1015
ifdetach:
982
1016
job_ref=f"{job.owner.name}/{job.id}"
983
1017
out.hint(f"Use `hf jobs logs -f {job_ref}` to stream logs, or `hf jobs inspect {job_ref}` to check status.")
0 commit comments