"""Format state machine kickoff calls. Place the data into a file called assets.csv with the format {asset_final_id},{bucket_name},{filename} Each row will be formatted into an aws cli call to kick off the state machine. """ import json SFN_ARN = ':'.join([ 'arn', 'aws', 'states', 'us-east-1', '437795906767', 'stateMachine', 'prod-sfn-content-match-audio' ]) def main(): """Start process.""" with open('assets.csv') as f: lines = f.read().split() for line in lines: if not line: continue pieces = line.split(',') output = { 'asset_final_id': pieces[0], 'bucket': pieces[1], 'filename': pieces[2], 'duration_ms': int(pieces[3]), 'bypass_filter': True } formatted_input = json.dumps(output).replace('"', '\\"') print(( 'aws stepfunctions start-execution ' f"--state-machine-arn '{SFN_ARN}' " f'--name asset-final-id-{pieces[0]} ' f'--input "{formatted_input}" >> start-output.log' )) if __name__ == '__main__': main()