@@ -402,8 +402,8 @@ def get_latest_commit_hash(owner, repo, branch='main'):
402402 ######
403403 ### Begin Upload and/or validation
404404 #####
405- # if args.figshare or args.validate or github_token:
406- if args .figshare or args .validate :
405+ if args .figshare or args .validate or github_token :
406+ # if args.figshare or args.validate:
407407 # FigShare File Prefixes:
408408
409409 prefixes = ['beataml' , 'hcmi' , 'cptac' , 'mpnst' , 'genes' , 'drugs' ]
@@ -436,6 +436,13 @@ def get_latest_commit_hash(owner, repo, branch='main'):
436436 for file in glob (os .path .join (all_files_dir , '*.gz' )):
437437 decompress_file (file )
438438
439+ ### These should be done before schema checking.
440+ sample_mapping_command = ['python3' , 'scripts/map_improve_sample_ids.py' , '--local_dir' , "/tmp" , '--version' , args .version ]
441+ run_docker_upload_cmd (sample_mapping_command , 'all_files_dir' , 'Map_Samples' , args .version )
442+
443+ drug_mapping_command = ['python3' , 'scripts/map_improve_drug_ids.py' , '--local_dir' , "/tmp" , '--version' , args .version ]
444+ run_docker_upload_cmd (drug_mapping_command , 'all_files_dir' , 'Map_Drugs' , args .version )
445+
439446 # Run schema checker - This will always run if uploading data.
440447 schema_check_command = ['python3' , 'scripts/check_schema.py' , '--datasets' ] + datasets
441448 run_docker_upload_cmd (schema_check_command , 'all_files_dir' , 'validate' , args .version )
@@ -452,40 +459,47 @@ def get_latest_commit_hash(owner, repo, branch='main'):
452459
453460 print ("File compression and decompression adjustments are complete." )
454461
455- # Upload to Figshare using Docker
462+ ### Upload to Figshare using Docker
456463 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' ]
464+ figshare_command = ['python3' , 'scripts/push_to_figshare.py' , '--directory' , "/tmp" , '--title' , f"CODERData{ args .version } " , '--token' , os .getenv ('FIGSHARE_TOKEN' ), '--project_id' , '189342' , '--version' , args . version , '-- publish' ]
458465 run_docker_upload_cmd (figshare_command , 'all_files_dir' , 'Figshare' , args .version )
459466
467+ ### Push changes to GitHub using Docker
468+ # if args.version and args.figshare and figshare_token and github_token and args.github_username and args.github_email:
460469
461- # Push changes to GitHub using Docker
462- # if args.version and args.figshare and figshare_token and github_token and args.github_username and args.github_email:
463- if args .version and github_token and args .github_username and args .github_email :
464-
465- git_command = [
466- 'bash' , '-c' , (
467- f'git config --global user.name "{ args .github_username } " '
468- f'&& git config --global user.email "{ args .github_email } " '
469- f'&& cp /tmp/improve_sample_mapping.json /usr/src/app/coderdata/build/improve_sample_mapping.json '
470- f'&& cp /tmp/improve_drug_mapping.json /usr/src/app/coderdata/build/improve_drug_mapping.json '
471- f'&& git add build/improve_sample_mapping.json '
472- f'&& git add build/improve_drug_mapping.json '
473- f'&& cp /tmp/figshare_latest.yml /usr/src/app/coderdata/docs/_data/figshare_latest.yml '
474- f'&& git add docs/_data/figshare_latest.yml '
475- f'&& git commit -m "Data Built and Uploaded. New Tag: { args .version } " '
476- f'&& git tag { args .version } '
477- f'&& git push https://{ args .github_username } :{ github_token } @github.com/PNNL-CompBio/coderdata.git main '
478- f'&& git push https://{ args .github_username } :{ github_token } @github.com/PNNL-CompBio/coderdata.git --tags'
479- )
480- ]
470+ # You can only upload to Github after Figshare upload is completed - otherwise figshare_latest.yml and dataset.yml won't be available.
471+ if args .version and github_token and args .github_username and args .github_email :
472+
473+ git_command = [
474+ 'bash' , '-c' , (
475+ f'git config --global user.name "{ args .github_username } " '
476+ f'&& git config --global user.email "{ args .github_email } " '
477+
478+ # Checkout a new branch
479+ f'&& git checkout -b testing-auto-build-pr-{ args .version } '
480+
481+ # Copy and add the necessary files
482+ f'&& cp /tmp/improve_sample_mapping.json.gz /usr/src/app/coderdata/build/improve_sample_mapping.json.gz '
483+ f'&& cp /tmp/improve_drug_mapping.json.gz /usr/src/app/coderdata/build/improve_drug_mapping.json.gz '
484+ f'&& gunzip /usr/src/app/coderdata/build/*.gz '
485+ f'&& git add -f build/improve_sample_mapping.json build/improve_drug_mapping.json '
486+ f'&& cp /tmp/figshare_latest.yml /usr/src/app/coderdata/docs/_data/figshare_latest.yml '
487+ f'&& cp /tmp/dataset.yml /usr/src/app/coderdata/coderdata/dataset.yml '
488+ f'&& git add -f docs/_data/figshare_latest.yml coderdata/dataset.yml'
489+
490+ # Tag and push
491+ f'&& git commit -m "Data Built and Uploaded. New Tag: { args .version } " '
492+ f'&& git tag { args .version } '
493+ f'&& git push https://{ args .github_username } :{ github_token } @github.com/PNNL-CompBio/coderdata.git testing-auto-build-pr-{ args .version } '
494+
495+ # Create a PR using GitHub CLI
496+ f'&& gh pr create --title "Testing Auto PR instead of auto Merge { args .version } " '
497+ f'--body "This PR was automatically generated by the build process." '
498+ f'--base main --head testing-auto-build-pr-{ args .version } '
499+ )
500+ ]
481501
482- sample_mapping_command = ['python3' , 'scripts/map_improve_sample_ids.py' , '--local_dir' , "/tmp" , '--version' , args .version ]
483- run_docker_upload_cmd (sample_mapping_command , 'all_files_dir' , 'Map_Samples' , args .version )
484-
485- drug_mapping_command = ['python3' , 'scripts/map_improve_drug_ids.py' , '--local_dir' , "/tmp" , '--version' , args .version ]
486- run_docker_upload_cmd (drug_mapping_command , 'all_files_dir' , 'Map_Drugs' , args .version )
487-
488- run_docker_upload_cmd (git_command , 'all_files_dir' , 'GitHub' , args .version )
502+ run_docker_upload_cmd (git_command , 'all_files_dir' , 'GitHub' , args .version )
489503
490504if __name__ == '__main__' :
491505 main ()
0 commit comments