Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Jobs] Update expose serialization tests for portsPublic
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
  • Loading branch information
Wauplin and claude committed Sep 29, 2026
commit 1b964fd9cc8d96528cbdaa196c641a5b15e57f42
25 changes: 18 additions & 7 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4708,17 +4708,28 @@ def test_serialize_optional_fields(self) -> None:
assert spec["volumes"][0]["path"] == "subdir"

@pytest.mark.parametrize(
"expose, expected",
"expose, expose_public, expected",
[
(None, None),
([], None),
([8000], {"ports": [8000]}),
([8000, 8001], {"ports": [8000, 8001]}),
(None, None, None),
([], [], None),
([8000], None, {"ports": [8000], "portsPublic": []}),
([8000, 8001], None, {"ports": [8000, 8001], "portsPublic": []}),
# public ports are merged into `ports` (the server requires `portsPublic` to be a subset of `ports`)
([8000, 9000], [9000, 7000], {"ports": [8000, 9000, 7000], "portsPublic": [9000, 7000]}),
],
)
def test_serialize_expose(self, expose: list[int] | None, expected: dict | None) -> None:
def test_serialize_expose(
self, expose: list[int] | None, expose_public: list[int] | None, expected: dict | None
) -> None:
spec = _create_job_spec(
image="python:3.12", command=["echo"], env=None, secrets=None, flavor=None, timeout=None, expose=expose
image="python:3.12",
command=["echo"],
env=None,
secrets=None,
flavor=None,
timeout=None,
expose=expose,
expose_public=expose_public,
)
assert spec.get("expose") == expected

Expand Down
16 changes: 0 additions & 16 deletions tests/test_jobs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from huggingface_hub._jobs_api import (
JobInfo,
JobNetwork,
_create_job_spec,
_default_job_name_from_image,
_default_job_name_from_script,
)
Expand Down Expand Up @@ -150,18 +149,3 @@ def test_job_info_parses_network(network, expected) -> None:
network=network,
)
assert job.network == expected


def test_public_exposed_ports() -> None:
spec = _create_job_spec(
image="python:3.12",
command=["echo"],
env=None,
secrets=None,
flavor=None,
timeout=None,
expose=[8000, 9000],
expose_public=[9000, 7000],
)
# public ports are merged into `ports` (the server requires `portsPublic` to be a subset of `ports`)
assert spec["expose"] == {"ports": [8000, 9000, 7000], "portsPublic": [9000, 7000]}
Loading