Skip to content

Commit

Permalink
Feature/pdct 1671 s3 back up for bulk import (#250)
Browse files Browse the repository at this point in the history
* Comment s3 backup logic back in + test refactor

* Bump patch version

* Bump patch version again

* Move validation functions to the validation service

* Use a simple aws client without config to connect to s3

* Bump patch version

* Add debuggin logs

* Bump patch version

* Remove incorrect region when setting up AWS client

* Bump patch version to 2.17.13
  • Loading branch information
annaCPR authored Nov 18, 2024
1 parent e169246 commit 8f95f44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions app/clients/aws/s3bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ def upload_json_to_s3(
:param dict[str, Any] json_data: The json data to be uploaded to S3.
:raises Exception: on any error when uploading the file to S3.
"""
_LOGGER.info(f"Uploading {context.object_name} to: {context.bucket_name}")
try:
response = s3_client.put_object(
s3_client.put_object(
Bucket=context.bucket_name,
Key=context.object_name,
Body=json.dumps(json_data),
ContentType="application/json",
)
_LOGGER.debug(f"Response from S3 client: {response}")
_LOGGER.info(
f"🎉 Successfully uploaded JSON to S3: {context.bucket_name}/{context.object_name}"
)
Expand All @@ -116,7 +116,6 @@ def upload_ingest_json_to_s3(
:param str corpus_import_id: The import_id of the corpus the ingest data belongs to.
:param dict[str, Any] json_data: The ingest json data to be uploaded to S3.
"""
_LOGGER.info(f"Uploading file to: {os.getenv('BULK_IMPORT_BUCKET')}")
ingest_upload_bucket = os.environ["BULK_IMPORT_BUCKET"]
current_timestamp = datetime.now().strftime("%m-%d-%YT%H:%M:%S")

Expand All @@ -128,7 +127,7 @@ def upload_ingest_json_to_s3(
json.dump(data, file, indent=4)
return

s3_client = boto3.client("s3", region_name="eu-west-2")
s3_client = boto3.client("s3")

context = S3UploadContext(
bucket_name=ingest_upload_bucket,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "admin_backend"
version = "2.17.12"
version = "2.17.13"
description = ""
authors = ["CPR-dev-team <[email protected]>"]
packages = [{ include = "app" }, { include = "tests" }]
Expand Down

0 comments on commit 8f95f44

Please sign in to comment.