Skip to content

Commit

Permalink
Feature/pdct 1671 s3 back up for bulk import (#248)
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
  • Loading branch information
annaCPR authored Nov 18, 2024
1 parent da4c7cd commit e169246
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/clients/aws/s3bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from app.errors import RepositoryError

_LOGGER = logging.getLogger(__name__)
_LOGGER.setLevel(logging.DEBUG)


class S3UploadContext(BaseModel):
Expand Down Expand Up @@ -90,12 +91,13 @@ def upload_json_to_s3(
:raises Exception: on any error when uploading the file to S3.
"""
try:
s3_client.put_object(
response = 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 @@ -114,7 +116,7 @@ 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(os.getenv("BULK_IMPORT_BUCKET", "Not there"))
_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 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.11"
version = "2.17.12"
description = ""
authors = ["CPR-dev-team <[email protected]>"]
packages = [{ include = "app" }, { include = "tests" }]
Expand Down

0 comments on commit e169246

Please sign in to comment.