Skip to content

Commit

Permalink
Improve cleaning up of files from execution environments
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrous authored Aug 8, 2024
1 parent f889122 commit 427cf5d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions sdc_aws_utils/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,6 @@ def push_science_file(
# Initialize S3 Client
s3_client = create_s3_client_session()

# Verify object does not exist in instrument bucket
if object_exists(
s3_client=s3_client,
bucket=destination_bucket,
file_key=new_file_key,
):
log.warning(f"File {new_file_key} already exists in bucket {destination_bucket}")
return new_file_key

# Upload file to destination bucket
upload_file_to_s3(
s3_client=s3_client,
Expand All @@ -455,6 +446,11 @@ def push_science_file(
file_key=new_file_key,
)

# Cleans the file from the /tmp directory in case of execution environment reuse
if Path(calibrated_filename).exists():
Path(calibrated_filename).unlink() # This deletes the file
print(f'File {Path(calibrated_filename)} successfully cleaned up from execution environment directory in case of reuse.')

else:
log.info(
"File Processed Locally - File will not be uploaded,"
Expand Down

0 comments on commit 427cf5d

Please sign in to comment.