in src/write_params_to_file.py [0:0]
def write_params_to_s3(params_list, bucket_name, dirname, ACCESS_KEY, SECRET_KEY):
# These are none when credentials file doesn't exist, or is set to ''. Shift off text credentials with AWS batch
if ACCESS_KEY is not None and SECRET_KEY is not None:
# Authenticate AWS session and create bucket object
try:
session = boto3.Session(
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
)
s3 = session.resource('s3')
except botocore.exceptions.ClientError:
s3 = boto3.resource('s3')
else:
s3 = boto3.resource('s3')
# Create content string
content = ''
for item in params_list:
content += f'{item}\n'
# Write content string directly to file
s3.Object(bucket_name, dirname + '/settings.txt').put(Body=content)
print(f'Successfully uploaded settings file to s3 bucket {bucket_name}')