Skip to content

Commit

Permalink
Merge pull request #55 from uc-cdis/fix/export-json
Browse files Browse the repository at this point in the history
fix: json type
  • Loading branch information
mfshao authored Aug 14, 2024
2 parents e7e7272 + d286545 commit cb45c00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions manifestservice/manifests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import json
import flask
import html
import boto3
from flask import current_app as app
import re
import requests
import ntpath
from datetime import date, datetime
from datetime import datetime
from authutils.token.validate import current_token, validate_request, set_current_token
from authutils import user as authutils_user
from cdislogging import get_logger

logger = get_logger("manifestservice_logger", log_level="info")
Expand Down Expand Up @@ -323,13 +322,12 @@ def _add_metadata_to_bucket(current_token, metadata_body):
result["metadata"], file_type="metadata"
)

metadata_as_bytes = str.encode(str(metadata_body))
filepath_in_bucket = folder_name + "/exported-metadata/" + filename
try:
obj = s3.Object(
flask.current_app.config.get("MANIFEST_BUCKET_NAME"), filepath_in_bucket
)
obj.put(Body=metadata_as_bytes)
obj.put(Body=bytes(json.dumps(metadata_body).encode('UTF-8')))
except Exception as e:
return str(e), False

Expand Down Expand Up @@ -357,14 +355,13 @@ def _add_manifest_to_bucket(current_token, manifest_json):
filename = _generate_unique_filename(
result["manifests"],
)
manifest_as_bytes = str.encode(str(flask.request.json))
filepath_in_bucket = folder_name + "/" + filename

try:
obj = s3.Object(
flask.current_app.config.get("MANIFEST_BUCKET_NAME"), filepath_in_bucket
)
obj.put(Body=manifest_as_bytes)
obj.put(Body=bytes(json.dumps(manifest_json).encode('UTF-8')))
except Exception as e:
logger.error(f"Failed to add manifest to bucket: {e}")
return str(e), False
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 = "manifestservice"
version = "0.5.0"
version = "0.5.2"
description = "Handles reading from and writing to a user's s3 folder containing their manifests"
authors = ["CTDS UChicago <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit cb45c00

Please sign in to comment.