Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion roar/core/models/glaas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


# -------------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions tests/core/test_validation_source_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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))
Expand Down
Loading