Skip to content

Commit d592df8

Browse files
committed
Revert "[Jobs] Add network groups to hf jobs run (#4833)"
This reverts commit 6cae778.
1 parent 3c08b69 commit d592df8

7 files changed

Lines changed: 0 additions & 157 deletions

File tree

docs/source/en/guides/cli.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,20 +2116,6 @@ Pass `--ssh` to `hf jobs run` (or `hf jobs uv run`) to make the Job's container
21162116

21172117
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.
21182118

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-
21332119
### UV Scripts (Experimental)
21342120

21352121
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.

docs/source/en/guides/jobs.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -372,27 +372,6 @@ Connect from a terminal with `hf jobs ssh <job_id>` (or directly with `ssh <job_
372372

373373
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.
374374

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=[...]`:
378-
379-
```python
380-
>>> from huggingface_hub import run_job
381-
>>> server = run_job(
382-
... image="python:3.12",
383-
... command=["python", "-m", "http.server", "8000"],
384-
... network_group="train",
385-
... network_aliases=["master"],
386-
... )
387-
>>> client = run_job(
388-
... image="python:3.12",
389-
... command=["sh", "-c", 'curl --retry 10 --retry-connrefused "http://${HF_NETWORK_GROUP_PREFIX}master:8000/"'],
390-
... network_group="train",
391-
... )
392-
```
393-
394-
Members are resolvable before they are ready, so connect with retries.
395-
396375
## Configure Job Timeout
397376

398377
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.

docs/source/en/package_reference/cli.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,8 +2505,6 @@ $ hf jobs run [OPTIONS] IMAGE COMMAND...
25052505
* `-d, --detach`: Run the Job in the background and print the Job ID.
25062506
* `--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.
25072507
* `--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`.
25102508
* `--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.
25112509
* `--namespace TEXT`: The namespace where the job will be running. Defaults to the current user's namespace.
25122510
* `--token TEXT`: A User Access Token generated from https://huggingface.co/settings/tokens.
@@ -2979,8 +2977,6 @@ $ hf jobs uv run [OPTIONS] SCRIPT [SCRIPT_ARGS]...
29792977
* `-d, --detach`: Run the Job in the background and print the Job ID.
29802978
* `--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.
29812979
* `--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`.
29842980
* `--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.
29852981
* `--namespace TEXT`: The namespace where the job will be running. Defaults to the current user's namespace.
29862982
* `--token TEXT`: A User Access Token generated from https://huggingface.co/settings/tokens.

src/huggingface_hub/_jobs_api.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,8 @@ def _create_job_spec(
581581
volumes: list[Volume] | None = None,
582582
expose: list[int] | None = None,
583583
ssh: bool = False,
584-
network_group: str | None = None,
585-
network_aliases: list[str] | None = None,
586584
resource_group_id: str | None = None,
587585
) -> dict[str, Any]:
588-
if network_aliases and not network_group:
589-
raise ValueError("`network_aliases` requires `network_group`.")
590586
if name is not None:
591587
if labels is not None and "name" in labels:
592588
raise ValueError("`name` and the `name` key in `labels` cannot both be provided.")
@@ -621,12 +617,6 @@ def _create_job_spec(
621617
# make the job container reachable over SSH
622618
if ssh:
623619
job_spec["ssh"] = {"enabled": True}
624-
# join a network group, optionally claiming aliases in it
625-
if network_group:
626-
network: dict[str, Any] = {"group": network_group}
627-
if network_aliases:
628-
network["aliases"] = network_aliases
629-
job_spec["network"] = network
630620
# resource group is optional
631621
if resource_group_id:
632622
job_spec["resourceGroupId"] = resource_group_id

src/huggingface_hub/cli/jobs.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,6 @@ def _parse_and_sync_job_volumes(
216216
),
217217
]
218218

219-
NetworkGroupOpt = Annotated[
220-
str | None,
221-
Option(
222-
"--network-group",
223-
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-
235219
WithOpt = Annotated[
236220
list[str] | None,
237221
Option(
@@ -369,8 +353,6 @@ def jobs_run(
369353
detach: DetachOpt = False,
370354
expose: ExposeOpt = None,
371355
ssh: SshEnabledOpt = False,
372-
network_group: NetworkGroupOpt = None,
373-
network_alias: NetworkAliasOpt = None,
374356
resource_group_id: ResourceGroupIdOpt = None,
375357
namespace: NamespaceOpt = None,
376358
token: TokenOpt = None,
@@ -391,8 +373,6 @@ def jobs_run(
391373
timeout=timeout,
392374
expose=expose,
393375
ssh=ssh,
394-
network_group=network_group,
395-
network_aliases=network_alias,
396376
resource_group_id=resource_group_id,
397377
namespace=namespace,
398378
)
@@ -408,11 +388,6 @@ def jobs_run(
408388
out.hint(f"Exposed ports are reachable at (requires an HF token with read access to the job):\n{urls}")
409389
if isinstance(job.status.ssh_url, str):
410390
out.hint(f"Use `hf jobs ssh {job.owner.name}/{job.id}` to open an SSH session into the job.")
411-
if network_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-
)
416391
if detach:
417392
job_ref = f"{job.owner.name}/{job.id}"
418393
out.hint(f"Use `hf jobs logs -f {job_ref}` to stream logs, or `hf jobs inspect {job_ref}` to check status.")
@@ -963,8 +938,6 @@ def jobs_uv_run(
963938
detach: DetachOpt = False,
964939
expose: ExposeOpt = None,
965940
ssh: SshEnabledOpt = False,
966-
network_group: NetworkGroupOpt = None,
967-
network_alias: NetworkAliasOpt = None,
968941
resource_group_id: ResourceGroupIdOpt = None,
969942
namespace: NamespaceOpt = None,
970943
token: TokenOpt = None,
@@ -990,8 +963,6 @@ def jobs_uv_run(
990963
timeout=timeout,
991964
expose=expose,
992965
ssh=ssh,
993-
network_group=network_group,
994-
network_aliases=network_alias,
995966
resource_group_id=resource_group_id,
996967
namespace=namespace,
997968
)
@@ -1007,11 +978,6 @@ def jobs_uv_run(
1007978
out.hint(f"Exposed ports are reachable at (requires an HF token with read access to the job):\n{urls}")
1008979
if isinstance(job.status.ssh_url, str):
1009980
out.hint(f"Use `hf jobs ssh {job.owner.name}/{job.id}` to open an SSH session into the job.")
1010-
if network_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-
)
1015981
if detach:
1016982
job_ref = f"{job.owner.name}/{job.id}"
1017983
out.hint(f"Use `hf jobs logs -f {job_ref}` to stream logs, or `hf jobs inspect {job_ref}` to check status.")

src/huggingface_hub/hf_api.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12130,8 +12130,6 @@ def run_job(
1213012130
volumes: list[Volume] | None = None,
1213112131
expose: list[int] | None = None,
1213212132
ssh: bool = False,
12133-
network_group: str | None = None,
12134-
network_aliases: list[str] | None = None,
1213512133
resource_group_id: str | None = None,
1213612134
namespace: str | None = None,
1213712135
token: bool | str | None = None,
@@ -12185,15 +12183,6 @@ def run_job(
1218512183
write access to the job's namespace and an SSH public key registered on the Hub
1218612184
(https://huggingface.co/settings/keys). Defaults to False.
1218712185

12188-
network_group (`str`, *optional*):
12189-
Name of a network group to join. Jobs of the same owner sharing a group are placed together and
12190-
can reach each other on every port. Inside each member, `HF_NETWORK_GROUP_HOSTNAME` resolves to
12191-
every member of the group. Lowercase alphanumerics and dashes, 46 characters max.
12192-
12193-
network_aliases (`list[str]`, *optional*):
12194-
Aliases this job claims in its network group. Members reach the jobs claiming an alias at
12195-
`${HF_NETWORK_GROUP_PREFIX}<alias>`. Several jobs may claim the same alias. Requires `network_group`.
12196-
1219712186
resource_group_id (`str`, *optional*):
1219812187
The ID of the resource group to create the Job in. Used to control access to resources within an
1219912188
organization and for cost attribution/spending-limit features. If not provided, the Job is created
@@ -12252,8 +12241,6 @@ def run_job(
1225212241
volumes=volumes,
1225312242
expose=expose,
1225412243
ssh=ssh,
12255-
network_group=network_group,
12256-
network_aliases=network_aliases,
1225712244
resource_group_id=resource_group_id,
1225812245
)
1225912246
response = get_session().post(
@@ -12784,8 +12771,6 @@ def run_uv_job(
1278412771
volumes: list[Volume] | None = None,
1278512772
expose: list[int] | None = None,
1278612773
ssh: bool = False,
12787-
network_group: str | None = None,
12788-
network_aliases: list[str] | None = None,
1278912774
resource_group_id: str | None = None,
1279012775
namespace: str | None = None,
1279112776
token: bool | str | None = None,
@@ -12846,15 +12831,6 @@ def run_uv_job(
1284612831
write access to the job's namespace and an SSH public key registered on the Hub
1284712832
(https://huggingface.co/settings/keys). Defaults to False.
1284812833

12849-
network_group (`str`, *optional*):
12850-
Name of a network group to join. Jobs of the same owner sharing a group are placed together and
12851-
can reach each other on every port. Inside each member, `HF_NETWORK_GROUP_HOSTNAME` resolves to
12852-
every member of the group. Lowercase alphanumerics and dashes, 46 characters max.
12853-
12854-
network_aliases (`list[str]`, *optional*):
12855-
Aliases this job claims in its network group. Members reach the jobs claiming an alias at
12856-
`${HF_NETWORK_GROUP_PREFIX}<alias>`. Several jobs may claim the same alias. Requires `network_group`.
12857-
1285812834
resource_group_id (`str`, *optional*):
1285912835
The ID of the resource group to create the Job in. Used to control access to resources within an
1286012836
organization and for cost attribution/spending-limit features. If not provided, the Job is created
@@ -12941,8 +12917,6 @@ def run_uv_job(
1294112917
volumes=volumes,
1294212918
expose=expose,
1294312919
ssh=ssh,
12944-
network_group=network_group,
12945-
network_aliases=network_aliases,
1294612920
resource_group_id=resource_group_id,
1294712921
namespace=namespace,
1294812922
token=token,

tests/test_cli.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,8 +3353,6 @@ def test_run(self, runner: CliRunner) -> None:
33533353
timeout=None,
33543354
expose=None,
33553355
ssh=False,
3356-
network_group=None,
3357-
network_aliases=None,
33583356
resource_group_id=None,
33593357
namespace=None,
33603358
)
@@ -3383,8 +3381,6 @@ def test_run_with_extra_args(self, runner: CliRunner) -> None:
33833381
timeout=None,
33843382
expose=None,
33853383
ssh=False,
3386-
network_group=None,
3387-
network_aliases=None,
33883384
resource_group_id=None,
33893385
namespace=None,
33903386
)
@@ -3444,8 +3440,6 @@ def test_uv_command(self, runner: CliRunner) -> None:
34443440
timeout=None,
34453441
expose=None,
34463442
ssh=False,
3447-
network_group=None,
3448-
network_aliases=None,
34493443
resource_group_id=None,
34503444
namespace=None,
34513445
)
@@ -3477,8 +3471,6 @@ def test_uv_command_with_extra_args(self, runner: CliRunner) -> None:
34773471
timeout=None,
34783472
expose=None,
34793473
ssh=False,
3480-
network_group=None,
3481-
network_aliases=None,
34823474
resource_group_id=None,
34833475
namespace=None,
34843476
)
@@ -3508,8 +3500,6 @@ def test_uv_remote_script(self, runner: CliRunner) -> None:
35083500
timeout=None,
35093501
expose=None,
35103502
ssh=False,
3511-
network_group=None,
3512-
network_aliases=None,
35133503
resource_group_id=None,
35143504
namespace=None,
35153505
)
@@ -3540,8 +3530,6 @@ def test_uv_local_script(self, runner: CliRunner, tmp_path: Path) -> None:
35403530
timeout=None,
35413531
expose=None,
35423532
ssh=False,
3543-
network_group=None,
3544-
network_aliases=None,
35453533
resource_group_id=None,
35463534
namespace=None,
35473535
)
@@ -4463,42 +4451,6 @@ def test_serialize_expose(self, expose: list[int] | None, expected: dict | None)
44634451
)
44644452
assert spec.get("expose") == expected
44654453

4466-
@pytest.mark.parametrize(
4467-
"network_group, network_aliases, expected",
4468-
[
4469-
(None, None, None),
4470-
("train", None, {"group": "train"}),
4471-
("train", [], {"group": "train"}),
4472-
("train", ["master", "worker"], {"group": "train", "aliases": ["master", "worker"]}),
4473-
],
4474-
)
4475-
def test_serialize_network(
4476-
self, network_group: str | None, network_aliases: list[str] | None, expected: dict | None
4477-
) -> None:
4478-
spec = _create_job_spec(
4479-
image="python:3.12",
4480-
command=["echo"],
4481-
env=None,
4482-
secrets=None,
4483-
flavor=None,
4484-
timeout=None,
4485-
network_group=network_group,
4486-
network_aliases=network_aliases,
4487-
)
4488-
assert spec.get("network") == expected
4489-
4490-
def test_network_aliases_require_group(self) -> None:
4491-
with pytest.raises(ValueError, match="network_aliases"):
4492-
_create_job_spec(
4493-
image="python:3.12",
4494-
command=["echo"],
4495-
env=None,
4496-
secrets=None,
4497-
flavor=None,
4498-
timeout=None,
4499-
network_aliases=["master"],
4500-
)
4501-
45024454

45034455
class TestWebhooksCommand:
45044456
def _make_webhook(self, **kwargs):

0 commit comments

Comments
 (0)