@@ -270,8 +270,6 @@ def run_docker_upload_cmd(cmd_arr, all_files_dir, name, version):
270270 docker_run .extend (['upload' ])
271271 if 'FIGSHARE_TOKEN' in env and name == 'Figshare' :
272272 docker_run .extend (['-e' , f"FIGSHARE_TOKEN={ env ['FIGSHARE_TOKEN' ]} " , 'upload' ])
273- if name == "validate" :
274- docker_run .extend (['upload' ])
275273 if name == "Map_Drugs" or name == "Map_Samples" :
276274 docker_run .extend (['upload' ])
277275 if 'GITHUB_TOKEN' in env and name == "GitHub" :
@@ -404,60 +402,60 @@ def get_latest_commit_hash(owner, repo, branch='main'):
404402 ######
405403 ### Begin Upload and/or validation
406404 #####
407- if args .figshare or args .validate or github_token :
408- # if args.figshare or args.validate:
405+ # if args.figshare or args.validate or github_token:
406+ if args .figshare or args .validate :
409407 # FigShare File Prefixes:
410408
411- # prefixes = ['beataml', 'hcmi', 'cptac', 'mpnst', 'genes', 'drugs']
412- # broad_sanger_datasets = ["ccle","ctrpv2","fimm","gdscv1","gdscv2","gcsi","prism","nci60"]
413- # if "broad_sanger" in datasets:
414- # prefixes.extend(broad_sanger_datasets)
415- # datasets.extend(broad_sanger_datasets)
416- # datasets.remove("broad_sanger")
417-
418- # figshare_token = os.getenv('FIGSHARE_TOKEN')
419-
420- # all_files_dir = 'local/all_files_dir'
421- # if not os.path.exists(all_files_dir):
422- # os.makedirs(all_files_dir)
409+ prefixes = ['beataml' , 'hcmi' , 'cptac' , 'mpnst' , 'genes' , 'drugs' ]
410+ broad_sanger_datasets = ["ccle" ,"ctrpv2" ,"fimm" ,"gdscv1" ,"gdscv2" ,"gcsi" ,"prism" ,"nci60" ]
411+ if "broad_sanger" in datasets :
412+ prefixes .extend (broad_sanger_datasets )
413+ datasets .extend (broad_sanger_datasets )
414+ datasets .remove ("broad_sanger" )
415+
416+ figshare_token = os .getenv ('FIGSHARE_TOKEN' )
417+
418+ all_files_dir = 'local/all_files_dir'
419+ if not os .path .exists (all_files_dir ):
420+ os .makedirs (all_files_dir )
423421
424- # # Ensure figshare tokens are available
425- # if args.figshare and not figshare_token:
426- # raise ValueError("Required tokens (FIGSHARE) are not set in environment variables.")
422+ # Ensure figshare tokens are available
423+ if args .figshare and not figshare_token :
424+ raise ValueError ("Required tokens (FIGSHARE) are not set in environment variables." )
427425
428- # # Ensure version is specified
429- # if args.figshare and not args.version:
430- # raise ValueError("Version must be specified when pushing to figshare")
431-
432- # # Move relevant files to a designated directory
433- # for file in glob(os.path.join("local", '*.*')):
434- # if any(file.startswith(os.path.join("local", prefix)) for prefix in prefixes):
435- # shutil.move(file, os.path.join(all_files_dir, os.path.basename(file)))
436-
437- # # Decompress all compressed files in the directory for schema checking
438- # for file in glob(os.path.join(all_files_dir, '*.gz')):
439- # decompress_file(file)
440-
441- # # Run schema checker - This will always run if uploading data.
442- # schema_check_command = ['python3', 'scripts/check_schema.py', '--datasets'] + datasets
443- # run_docker_upload_cmd(schema_check_command, 'all_files_dir', 'validate', args.version)
426+ # Ensure version is specified
427+ if args .figshare and not args .version :
428+ raise ValueError ("Version must be specified when pushing to figshare" )
429+
430+ # Move relevant files to a designated directory
431+ for file in glob (os .path .join ("local" , '*.*' )):
432+ if any (file .startswith (os .path .join ("local" , prefix )) for prefix in prefixes ):
433+ shutil .move (file , os .path .join (all_files_dir , os .path .basename (file )))
434+
435+ # Decompress all compressed files in the directory for schema checking
436+ for file in glob (os .path .join (all_files_dir , '*.gz' )):
437+ decompress_file (file )
438+
439+ # Run schema checker - This will always run if uploading data.
440+ schema_check_command = ['python3' , 'scripts/check_schema.py' , '--datasets' ] + datasets
441+ run_docker_upload_cmd (schema_check_command , 'all_files_dir' , 'validate' , args .version )
444442
445- # print("Validation complete. Proceeding with file compression/decompression adjustments")
443+ print ("Validation complete. Proceeding with file compression/decompression adjustments" )
446444
447- # # Compress or decompress files based on specific conditions after checking
448- # for file in glob(os.path.join(all_files_dir, '*')):
449- # is_compressed = file.endswith('.gz')
450- # if ('samples' in file or 'figshare' in file) and is_compressed:
451- # decompress_file(file)
452- # elif not ('samples' in file or 'figshare' in file) and not is_compressed:
453- # compress_file(file)
454-
455- # print("File compression and decompression adjustments are complete.")
445+ # Compress or decompress files based on specific conditions after checking
446+ for file in glob (os .path .join (all_files_dir , '*' )):
447+ is_compressed = file .endswith ('.gz' )
448+ if ('samples' in file or 'figshare' in file ) and is_compressed :
449+ decompress_file (file )
450+ elif not ('samples' in file or 'figshare' in file ) and not is_compressed :
451+ compress_file (file )
452+
453+ print ("File compression and decompression adjustments are complete." )
456454
457- # # Upload to Figshare using Docker
458- # if args.figshare and args.version and figshare_token:
459- # figshare_command = ['python3', 'scripts/push_to_figshare.py', '--directory', "/tmp", '--title', f"CODERData{args.version}", '--token', os.getenv('FIGSHARE_TOKEN'), '--project_id', '189342', '--publish']
460- # run_docker_upload_cmd(figshare_command, 'all_files_dir', 'Figshare', args.version)
455+ # Upload to Figshare using Docker
456+ if args .figshare and args .version and figshare_token :
457+ figshare_command = ['python3' , 'scripts/push_to_figshare.py' , '--directory' , "/tmp" , '--title' , f"CODERData{ args .version } " , '--token' , os .getenv ('FIGSHARE_TOKEN' ), '--project_id' , '189342' , '--publish' ]
458+ run_docker_upload_cmd (figshare_command , 'all_files_dir' , 'Figshare' , args .version )
461459
462460
463461 # Push changes to GitHub using Docker
0 commit comments