From be30d19bf9ade7eedbec4da7df64180b64cc12f7 Mon Sep 17 00:00:00 2001 From: Trevor Basinger Date: Tue, 8 Sep 2026 14:37:21 -0500 Subject: [PATCH] fix(publish): accept hugging face artifact sources --- roar/core/models/glaas.py | 2 +- tests/core/test_validation_source_types.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/roar/core/models/glaas.py b/roar/core/models/glaas.py index 5edf1fb5..6a64b7ca 100644 --- a/roar/core/models/glaas.py +++ b/roar/core/models/glaas.py @@ -16,7 +16,7 @@ # Includes canonical composite digest algorithm for composite artifact payloads. HashAlgorithm = Literal["blake3", "sha256", "sha512", "md5", "composite-blake3", "composite-sha256"] HexDigest = Annotated[str, Field(min_length=8, max_length=128, pattern=r"^[a-f0-9]+$")] -SourceType = Literal["s3", "gs", "https"] | None +SourceType = Literal["s3", "gs", "https", "hf"] | None # ------------------------------------------------------------------------- diff --git a/tests/core/test_validation_source_types.py b/tests/core/test_validation_source_types.py index e02aa2e9..dee7e964 100644 --- a/tests/core/test_validation_source_types.py +++ b/tests/core/test_validation_source_types.py @@ -17,6 +17,7 @@ from __future__ import annotations from roar.application.publish.registration import _VALID_REMOTE_SOURCE_TYPES +from roar.core.models.glaas import RegisterArtifactRequest from roar.core.validation import VALID_SOURCE_TYPES, validate_artifact_registration @@ -48,6 +49,18 @@ def test_hf_validates(): assert validate_artifact_registration(**_artifact("hf")) +def test_hf_builds_a_glaas_registration_request(): + """The typed API request must accept every source emitted by ``roar put``.""" + request = RegisterArtifactRequest( + hashes=[{"algorithm": "blake3", "digest": "d" * 64}], + size=1, + source_type="hf", + source_url="hf://example/model/artifact.bin", + ) + + assert request.source_type == "hf" + + def test_none_still_validates(): """Local artifacts carry no source type.""" assert validate_artifact_registration(**_artifact(None))