From f395260da7f2353e8c1238e788a50e24fd1ec856 Mon Sep 17 00:00:00 2001 From: Divide-By-0 Date: Thu, 28 Sep 2023 12:09:18 +0200 Subject: [PATCH] more s3 script cleanup --- .../scripts/upload_to_s3.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/twitter-verifier-circuits/scripts/upload_to_s3.py b/packages/twitter-verifier-circuits/scripts/upload_to_s3.py index 8a893d4e5..3a3700d83 100644 --- a/packages/twitter-verifier-circuits/scripts/upload_to_s3.py +++ b/packages/twitter-verifier-circuits/scripts/upload_to_s3.py @@ -11,18 +11,16 @@ parser = argparse.ArgumentParser(description='Upload files to S3 bucket') parser.add_argument('--bucket_name', type=str, default='zkemail-zkey-chunks', help='Name of the S3 bucket') -parser.add_argument('--dirs', type=str, default='./chunked_build/email, ./chunked_build/email/email_js', help="Comma seperated directories to upload files from") -# parser.add_argument('--build_dir', type=str, default='chunked_build', help='Name of the build directory directory with the circuitname/ folder') -# parser.add_argument('--circuit_name', type=str, default='email', help='Name of the circuit (i.e. the foldername in build_dir/)') -parser.add_argument('--prefix_to_tar', type=str, default='email.zkey', help='Prefix to match for files in order to compress to a .tar.gz and upload') +parser.add_argument('--build-dir', type=str, default='build', help='Name of the build directory directory with the circuitname/ folder') +parser.add_argument('--circuit-name', type=str, default='wallet', help='Name of the circuit (i.e. the foldername in build_dir/)') parser.add_argument('--prefix', type=str, default='vkey.json,email.wasm', help='Comma-seperated prefixes to upload without compression') args = parser.parse_args() bucket_name = args.bucket_name -# build_dir = args.build_dir -# circuit_name = args.circuit_name -prefix_to_tar = args.prefix_to_tar +build_dir = args.build_dir +circuit_name = args.circuit_name +prefix_to_tar = args.circuit_name + ".zkey" prefixes = args.prefix.split(',') -dirs = args.dirs.split(',') +dirs = [os.path.join(build_dir, circuit_name, ""), os.path.join(build_dir, circuit_name, circuit_name + '_js')] # Get the latest commit hash commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip() @@ -32,17 +30,17 @@ # source = '.' # zkey_dir = source + '/{build_dir}/{circuit_name}/' # wasm_dir = source + '/{build_dir}/{circuit_name}/{circuit_name}_js/' - def upload_to_s3(filename, dir=""): with open(dir + filename, 'rb') as file: print("Starting upload...") s3.upload_fileobj(file, bucket_name, commit_hash + '/' + filename, ExtraArgs={ 'ACL': 'public-read', 'ContentType': 'binary/octet-stream'}) - print("Done uploading ", filename, "!") + print(f"Done uploading {filename} to: https://{bucket_name}.s3.amazonaws.com/{commit_hash}/{filename}") # Loop through the files in the remote directory for dir in dirs: + print("Searching for files in: ", dir) for file in os.listdir(dir): # Check if the file matches the pattern if file.startswith(prefix_to_tar):