Skip to content

Commit

Permalink
fix: properly indicate whether migrate_resource_to_s3_job actually di…
Browse files Browse the repository at this point in the history
…d it
  • Loading branch information
paulmueller committed Oct 3, 2024
1 parent 5cb05bc commit 7903bb8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
checks:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@main
- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@main
with:
python-version: "3.8"
- name: Install flake8 dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@main
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@main
with:
python-version: "3.9"
- name: Install dependencies
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.15.3
- fix: properly indicate whether migrate_resource_to_s3_job actually did it
0.15.2
- setup: fix ckanext namespace
0.15.1
Expand Down
13 changes: 9 additions & 4 deletions ckanext/dcor_depot/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def patch_resource_noauth(package_id, resource_id, data_dict):

def migrate_resource_to_s3_job(resource):
"""Migrate a resource to the S3 object store"""
performed_upload = False
rid = resource["id"]
# Make sure the resource is available for processing
wait_for_resource(rid)
Expand All @@ -40,7 +41,12 @@ def migrate_resource_to_s3_job(resource):
f"are running pytest with synchronous jobs!",
NoSHA256Available)
sha256 = sha256sum(path)
# Perform the upload

# Tell whether we have to perform an upload.
if not s3cc.object_exists(rid, "resource"):
performed_upload = True

# Perform the upload (if necessary), returning the URL
s3_url = s3cc.upload_artifact(
resource_id=rid,
path_artifact=path,
Expand All @@ -50,16 +56,15 @@ def migrate_resource_to_s3_job(resource):
override=False,
)

# Append the S3 URL to the resource metadata
# Set the S3 URL in the resource metadata
patch_resource_noauth(
package_id=resource["package_id"],
resource_id=resource["id"],
data_dict={
"s3_available": True,
"s3_url": s3_url})

return s3_url
return False
return performed_upload


def symlink_user_dataset_job(pkg, usr, resource):
Expand Down

0 comments on commit 7903bb8

Please sign in to comment.