Skip to content

Commit

Permalink
enh: return S3 URL in s3cc.upload_artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Feb 22, 2024
1 parent 32f1a60 commit 62b7823
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.7.5
- enh: return S3 URL in s3cc.upload_artifact
0.7.4
- fix: disable basins when loading a dataset instance
- enh: implement s3cc.upload_artifact
Expand Down
3 changes: 2 additions & 1 deletion dcor_shared/s3cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,11 @@ def upload_artifact(
private = ds_dict["private"]

rid = resource_id
s3.upload_file(
s3_url = s3.upload_file(
bucket_name=bucket_name,
object_name=f"{artifact}/{rid[:3]}/{rid[3:6]}/{rid[6:]}",
path=path_artifact,
sha256=sha256 or sha256sum(path_artifact),
private=private,
override=override)
return s3_url
7 changes: 4 additions & 3 deletions tests/test_s3cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ def test_upload_artifact(enqueue_job_mock, tmp_path):
path_fake_preview = tmp_path / "test_preview.jpg"
path_fake_preview.write_text("This is not a real image!")
# upload the preview
s3cc.upload_artifact(rid,
path_artifact=path_fake_preview,
artifact="preview")
s3_url2 = s3cc.upload_artifact(rid,
path_artifact=path_fake_preview,
artifact="preview")
assert s3_url == s3_url2.replace("preview", "resource")
# make sure that worked
assert s3cc.artifact_exists(rid, "preview")
# attempt to download the private artifact
Expand Down

0 comments on commit 62b7823

Please sign in to comment.