@@ -20,51 +20,41 @@ def upload_to_s3(file_path: Path, bucket_name: str, folder_name: str):
2020 sys .exit (1 )
2121
2222
23- def main (bucket_name : str , repo_name : str , working_directory :str ):
24-
23+ def main (bucket_name : str , repo_name : str ):
2524 cwd = os .getcwd ()
2625 print ("Current working directory:" , cwd )
2726
28- # Go up one level to reach utils/
29- #json_dir = os.path.dirname(os.path.dirname(os.getcwd()))
30- #json_dir = os.chdir(working_directory)
31- #print("Utils directory:", json_dir)
32-
33- root_dir = Path .cwd ().parents [1 ] # go up 2 levels
27+ root_dir = Path .cwd ().parents [1 ]
3428 json_file = root_dir / f"{ repo_name } .json"
3529 minified_json = "spec.json"
3630
3731 print (json_file )
3832
33+ if not json_file .is_file ():
34+ print (f"[ERROR] JSON spec not found: { json_file } " )
35+ return 1
36+
3937 with open (json_file , "r" ) as f :
4038 data = json .load (f )
4139
4240 with open (minified_json , "w" ) as f :
4341 json .dump (data , f , separators = ("," , ":" ))
4442
45- #json_file = f"{repo_name}.json"
46-
47- # Build path to JSON file
48- #json_path = os.path.join(json_dir, json_file)
49-
5043 upload_to_s3 (minified_json , bucket_name , repo_name )
5144
5245 print ("[DONE] Processing complete." )
5346 return 0
5447
55-
5648if __name__ == "__main__" :
5749 print ("Hitting main" )
5850
59- if len (sys .argv ) != 4 :
60- print ("Usage: python copy_spec_to_s3.py <s3_bucket_name> <repo_name> <Working Directory> " )
51+ if len (sys .argv ) != 3 :
52+ print ("Usage: python copy_spec_to_s3.py <s3_bucket_name> <repo_name>" )
6153 sys .exit (1 )
6254
6355 bucket_name = sys .argv [1 ]
6456 repo_name = sys .argv [2 ]
65- working_directory = sys .argv [3 ]
6657 print (f"Repo name: { repo_name } " )
6758 print (f"Bucket name: { bucket_name } " )
68- print (f"Working Directory: { working_directory } " )
6959
70- sys .exit (main (bucket_name ,repo_name , working_directory ))
60+ sys .exit (main (bucket_name ,repo_name ))
0 commit comments