generated from AustralianBioCommons/guide-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from supernord/main
Add GoogleSheet import feature from field guide
- Loading branch information
Showing
7 changed files
with
145 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ permissions: | |
id-token: write | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
name: Update guides | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
update_guides: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: setup python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.8.16' | ||
|
||
- name: install python packages | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: execute table conversion script | ||
run: python scripts/guides_table_conversion.py | ||
|
||
- name: Commit if updated | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add -A | ||
git diff-index --quiet HEAD || git commit -m "update guides" | ||
- name: Push if changes | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Metagenomics | ||
type: category | ||
page_id: metagenomics | ||
description: How-to Guides focused on metagenomics. | ||
--- | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pandas | ||
requests | ||
argparse | ||
PyYAML | ||
python-frontmatter | ||
urllib3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Adapted from https://github.com/elixir-europe/rdmkit/blob/master/var/conversions.py | ||
Adapted from https://github.com/AustralianBioCommons/human-omics-data-sharing-field-guide/blob/328e84634d10b0df51e798dbf1cc114c7cb26357/var/tools_table_conversion.py | ||
""" | ||
|
||
import pandas as pd | ||
import yaml | ||
import os | ||
|
||
# --------- Variables --------- | ||
|
||
google_id = "1CWSW5CAg0f8e5XB9Bl80jiDT8QCWOWhuCxKjDWLi5a4" | ||
gid = "0" | ||
url = f"https://docs.google.com/spreadsheets/d/{google_id}/export?format=csv&gid={gid}" | ||
output_path = "_data/tool_and_resource_list.yml" | ||
rootdir = '../pages' | ||
allowed_registries = ['biotools', 'fairsharing', 'tess', 'wfh-collection', 'wfh', 'doi', 'template'] | ||
|
||
# --------- Converting the table --------- | ||
|
||
print(f"----> Converting GoogleSheets table to {output_path} started.") | ||
resource_table = pd.read_csv(url, dtype={'name': str, 'url': str, 'description': str, 'id': str, 'fairsharing': str, | ||
'biotools': str, 'tess': str, 'wfh-collection': str, 'wfh': str, | ||
'doi': str, 'template': str, 'related_pages': str}) | ||
resource_list = resource_table.to_dict("records") | ||
clean_resource_list = [] | ||
for resource in resource_list: | ||
if not pd.isna(resource['related_pages']): | ||
category_list = resource['related_pages'].rsplit(sep=",") | ||
else: | ||
category_list = "" | ||
registry_dict = {} | ||
for registry in allowed_registries: | ||
if not pd.isna(resource[registry]): | ||
registry_dict[registry] = resource[registry] | ||
del(resource[registry]) | ||
clean_resource = {k: resource[k] for k in resource if not pd.isna(resource[k])} | ||
clean_resource_list.append(clean_resource) | ||
clean_resource['registry'] = registry_dict | ||
if category_list != "": | ||
clean_resource['related_pages'] = category_list | ||
|
||
print(os.getcwd()) | ||
with open(output_path, 'w+') as yaml_file: | ||
documents = yaml.dump(clean_resource_list, yaml_file) | ||
|
||
print("----> YAML is dumped successfully") |