Skip to content

Commit

Permalink
fix missing pathlib import. fix missing aip file extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
camlyall committed Apr 21, 2023
1 parent 7c2adbd commit 1ae9753
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions a3m/client/clientScripts/a3m_store_aip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from a3m.client import metrics

from pathlib import Path

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -36,7 +37,15 @@ def _upload_file(path, bucket, key):
boto_args.update(config=config)

s3 = boto3.resource(**boto_args)
s3.meta.client.upload_file(path, bucket, key)

# TODO: The S3 path should include a pre-defined directory path for the AIP
# We could use a predefined variable in the configuration file for a global A3M Storage such as predefined/global/path/<Transfer Source/DIPS/AIPS>/
# Alternatively, we could use a predefined variable specifically for the AIP location such as predefined/aip/location/
# In any case, the S3 path must be structured in a way that makes it easy to locate and manage the AIP.
s3_path = key + path.suffix

logger.info(s3_path)
s3.meta.client.upload_file(str(path), bucket, s3_path)


def _store_aip(job, sip_id, aip_path):
Expand All @@ -51,13 +60,13 @@ def _store_aip(job, sip_id, aip_path):
raise Exception("AIP is a directory")

logger.info("Uploading AIP...")
_upload_file(str(aip_path), settings.S3_BUCKET, sip_id)
_upload_file(aip_path, settings.S3_BUCKET, sip_id)


def call(jobs):
job = jobs[0]
with transaction.atomic():
with job.JobContext():
sip_id = job.args[1]
aip_path = job.args[2]
aip_path = Path(job.args[2])
job.set_status(_store_aip(job, sip_id, aip_path))

0 comments on commit 1ae9753

Please sign in to comment.