Skip to content

Commit

Permalink
[feat] : re-add syncing workflow (#53)
Browse files Browse the repository at this point in the history
* add option to not output csv file

* add workflow
  • Loading branch information
vpchung authored Feb 24, 2024
1 parent 73c58e4 commit 64a19aa
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/sync-to-portal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Sync manifests to portal tables

on:
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
defaults:
run:
working-directory: portal_tables
steps:
- uses: actions/[email protected]

- name: Setup Python
uses: actions/[email protected]
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install synapseclient pandas
- name: Sync to portal
run: |
python sync_publications.py --noprint
python sync_datasets.py --noprint
python sync_tools.py --noprint
env:
SYNAPSE_AUTH_TOKEN: ${{ secrets.SYNAPSE_AUTH_TOKEN }}
5 changes: 3 additions & 2 deletions portal_tables/sync_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ def main():
utils.update_table(syn, args.portal_table_id, final_database)
print()

print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
if not args.noprint:
print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
print("\n\nDONE ✅")


Expand Down
5 changes: 3 additions & 2 deletions portal_tables/sync_education.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ def main():
utils.update_table(syn, args.portal_table_id, final_database)
print()

print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
if not args.noprint:
print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
print("\n\nDONE ✅")


Expand Down
5 changes: 3 additions & 2 deletions portal_tables/sync_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ def main():
utils.update_table(syn, args.portal_table_id, final_database)
print()

print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
if not args.noprint:
print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
print("\n\nDONE ✅")


Expand Down
5 changes: 3 additions & 2 deletions portal_tables/sync_people.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ def main():
utils.update_table(syn, args.portal_table_id, final_database)
print()

print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
if not args.noprint:
print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
print("\n\nDONE ✅")


Expand Down
5 changes: 3 additions & 2 deletions portal_tables/sync_publications.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ def main():
utils.update_table(syn, args.portal_table_id, final_database)
print()

print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
if not args.noprint:
print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
print("\n\nDONE ✅")


Expand Down
5 changes: 3 additions & 2 deletions portal_tables/sync_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ def main():
utils.update_table(syn, args.portal_table_id, final_database)
print()

print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
if not args.noprint:
print(f"📄 Saving copy of final table to: {args.output_csv}...")
final_database.to_csv(args.output_csv, index=False)
print("\n\nDONE ✅")


Expand Down
6 changes: 6 additions & 0 deletions portal_tables/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def get_args(resource: str) -> argparse.Namespace:
action="store_true",
help="Output all logs and interim tables.",
)
parser.add_argument(
"-np",
"--noprint",
action="store_true",
help="Do not output CSV file.",
)
return parser.parse_args()


Expand Down

0 comments on commit 64a19aa

Please sign in to comment.