Skip to content

Commit

Permalink
enable large file upload (#13)
Browse files Browse the repository at this point in the history
* enable large file upload

Signed-off-by: Isabella do Amaral <[email protected]>

* bump oras-py to 0.2.21

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

* test chunked uploads

Signed-off-by: Isabella do Amaral <[email protected]>

---------

Signed-off-by: Isabella do Amaral <[email protected]>
Signed-off-by: tarilabs <[email protected]>
Co-authored-by: tarilabs <[email protected]>
  • Loading branch information
isinyaaa and tarilabs authored Oct 3, 2024
1 parent 0b71d27 commit f51e18f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ site

# E2E
venv
temp
1 change: 1 addition & 0 deletions omlmd/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def push(
files=files,
manifest_annotations=model_metadata.to_annotations_dict(),
manifest_config=manifest_cfg,
do_chunked=True,
)
self.notify_listeners(PushEvent(target, model_metadata))
return result
Expand Down
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.1.30"
oras = "^0.2.21"
pyyaml = "^6.0.1"
click = "^8.1.7"
cloup = "^3.0.5"
Expand Down
34 changes: 34 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import subprocess
import tempfile
from pathlib import Path

Expand Down Expand Up @@ -64,6 +65,39 @@ def update(self, _, event: Event) -> None:
assert e0.metadata == ModelMetadata.from_dict(md)


@pytest.mark.e2e
def test_push_pull_chunked(tmp_path, target):
omlmd = Helper()

md = {
"name": "mnist",
"description": "Lorem ipsum",
"author": "John Doe",
"accuracy": 0.987,
}
here = Path.cwd()
temp = here / "temp"
base_size = 16 * 1024 * 1024 * 3 # 48MB
try:
subprocess.run(
[
"dd",
"if=/dev/null",
f"of={temp}",
"bs=1",
"count=0",
f"seek={base_size}",
],
)

omlmd.push(target, temp, **md)
omlmd.pull(target, tmp_path)
assert len(list(tmp_path.iterdir())) == 3
assert tmp_path.joinpath(temp.name).stat().st_size == base_size
finally:
temp.unlink()


@pytest.mark.e2e
def test_e2e_push_pull(tmp_path, target):
omlmd = Helper()
Expand Down

0 comments on commit f51e18f

Please sign in to comment.