Skip to content

Commit

Permalink
use only 1 reference to the s3 key name.
Browse files Browse the repository at this point in the history
  • Loading branch information
rshewitt committed May 30, 2023
1 parent 8b09e81 commit 7049e38
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions datagovharvester/extract/dcatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
create_s3_payload,
)

def store_record_in_s3( record, source_id, job_id, record_idx, S3_client, bucket_name ):
def store_record_in_s3( record, source_id, job_id, record_idx, S3_client,
key_name, bucket_name ):
""" store the input record in a s3 bucket
record (dict) : dcatus record
source_id (str) : uuid
Expand All @@ -16,7 +17,6 @@ def store_record_in_s3( record, source_id, job_id, record_idx, S3_client, bucket
"""
try:
record = json.dumps(record)
key_name = f"{source_id}/{job_id}/{record_idx}.json"
s3_payload = create_s3_payload(record, bucket_name, key_name)
upload_to_S3(S3_client, s3_payload)
return key_name
Expand Down Expand Up @@ -46,9 +46,10 @@ def extract_json_catalog(url, source_id, job_id, S3_client, bucket_name):

for idx, record in enumerate(data["dataset"]):
try:
store_record_in_s3( record, source_id, job_id, idx, S3_client, bucket_name )
s3_path = bucket_name + f"/{source_id}/{job_id}/{idx}.json"
output["s3_paths"].append( s3_path )
key_name = f"/{source_id}/{job_id}/{idx}.json"
store_record_in_s3( record, source_id, job_id, idx, S3_client,
key_name, bucket_name )
output["s3_paths"].append( key_name )
output["job_ids"].append( job_id )
except Exception as e:
output["errors"].append( e )
Expand Down

1 comment on commit 7049e38

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
datagovharvester/extract
   __init__.py00100% 
   dcatus.py2877 75%
   utils.py1455 64%
datagovharvester/utils
   __init__.py00100% 
   json_utilities.py722 71%
   s3_utilities.py1444 71%
datagovharvester/validate
   __init__.py00100% 
   dcat_us.py200100% 
TOTAL831878% 

Tests Skipped Failures Errors Time
13 0 💤 0 ❌ 0 🔥 13.654s ⏱️

Please sign in to comment.