Skip to content

Commit

Permalink
support : in model source (#22)
Browse files Browse the repository at this point in the history
* reproducer

Signed-off-by: tarilabs <[email protected]>

* fix and refactor

Signed-off-by: tarilabs <[email protected]>

---------

Signed-off-by: tarilabs <[email protected]>
  • Loading branch information
tarilabs authored Oct 15, 2024
1 parent 47ec50b commit c1f4a53
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Changelog = "https://github.com/containers/omlmd/releases"

[tool.poetry.dependencies]
python = "^3.9"
oras = "^0.2.21"
oras = "^0.2.22"
pyyaml = "^6.0.1"
click = "^8.1.7"
cloup = "^3.0.5"
Expand Down
30 changes: 30 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import tempfile
from pathlib import Path
from hashlib import sha256

import pytest

Expand Down Expand Up @@ -126,3 +127,32 @@ def test_e2e_push_pull_with_filters(tmp_path, target):
)
omlmd.pull(target, tmp_path, media_types=[MIME_APPLICATION_MLMODEL])
assert len(list(tmp_path.iterdir())) == 1


@pytest.mark.e2e
def test_e2e_push_pull_column(tmp_path, target):
omlmd = Helper()
md = {
"name": "using : in the filename",
"description": "Lorem ipsum",
"author": "John Doe",
"accuracy": 0.987,
}
content = "Hello, World!"
content_sha = sha256(content.encode("utf-8")).hexdigest()
here = Path.cwd()
temp = here / ("sha256:"+content_sha)
try:
with open(temp, "w") as f:
f.write(content)

omlmd.push(target, temp, **md)
omlmd.pull(target, tmp_path)
with open(tmp_path.joinpath(temp.name), "r") as f:
pulled = f.read()
assert pulled == content
pulled_sha = sha256(pulled.encode("utf-8")).hexdigest()
assert pulled_sha == content_sha
finally:
temp.unlink()

0 comments on commit c1f4a53

Please sign in to comment.