-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script to automatically remove accepted ontologies #23
Open
cthoyt
wants to merge
2
commits into
OBOFoundry:master
Choose a base branch
from
cthoyt:auto-remove
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+117
−2
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Remove Accepted Ontologies | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 0 * * *" # once per day | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
with: | ||
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | ||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install --upgrade setuptools wheel | ||
pip install tox | ||
- name: Update | ||
run: | | ||
tox -e purge | ||
- name: Commit files | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add --all | ||
git commit -m "Automatically remove accepted ontologies" -a | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ github.ref }} |
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 |
---|---|---|
@@ -1,9 +1,21 @@ | ||
# Repo to manage the OBO Foundry Dashboard for New Ontology Requests | ||
# Repo to manage the OBO Foundry Dashboard for New Ontology Requests (NORs) | ||
|
||
Page deployed at: https://obofoundry.github.io/obo-nor.github.io/ | ||
|
||
To update: | ||
## Update | ||
|
||
1. change `dashboard-config.yml` | ||
2. run `sh run-dash.sh` | ||
|
||
## Remove accepted ontologies | ||
|
||
After ontologies have been accepted into the OBO Foundry, they will be displayed on the | ||
main [OBO Dashboard](https://dashboard.obofoundry.org/) and can be safely removed from the NOR dashboard. This is | ||
automated with the following code: | ||
|
||
```shell | ||
pip install tox | ||
tox -e purge | ||
``` | ||
|
||
This is also automatically run nightly via GitHub Actions. [![Remove Accepted Ontologies](https://github.com/OBOFoundry/obo-nor.github.io/actions/workflows/purge.yml/badge.svg)](https://github.com/OBOFoundry/obo-nor.github.io/actions/workflows/purge.yml) |
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,44 @@ | ||
"""Purge accepted ontologies from NOR Dashboard.""" | ||
|
||
from pathlib import Path | ||
|
||
import click | ||
import requests | ||
import yaml | ||
|
||
HERE = Path(__file__).parent.resolve() | ||
ROOT = HERE.parent.resolve() | ||
DASHBOARD_DIRECTORY = ROOT.joinpath("dashboard") | ||
DASHBOARD_CONFIG_PATH = ROOT.joinpath("dashboard-config.yml") | ||
|
||
URL = "https://raw.githubusercontent.com/OBOFoundry/OBOFoundry.github.io/master/registry/ontologies.yml" | ||
|
||
|
||
@click.command() | ||
def main(): | ||
"""Purge accepted ontologies from NOR Dashboard.""" | ||
#: A set of prefixes for active ontologies in the OBO Foundry | ||
prefixes = { | ||
record["id"] | ||
for record in yaml.safe_load(requests.get(URL).content)["ontologies"] | ||
if record["activity_status"] in {"active"} | ||
} | ||
|
||
# Remove folders corresponding to active ontologies | ||
for directory in DASHBOARD_DIRECTORY.iterdir(): | ||
if directory.is_dir() and directory.name in prefixes: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already an action that deals with cleaning the directory. Only the yaml file needs to be edited! The rest happens automatically! |
||
for path in directory.iterdir(): | ||
click.echo(f"removing file: {path}") | ||
path.unlink() | ||
click.echo(f"removing directory: {directory}") | ||
directory.rmdir() | ||
|
||
# Remove configuration corresponding to active ontologies | ||
config = yaml.safe_load(DASHBOARD_CONFIG_PATH.read_text()) | ||
config["ontologies"]["custom"] = [ | ||
row for row in config["ontologies"]["custom"] if row["id"] not in prefixes | ||
] | ||
|
||
|
||
if __name__ == "__main__": | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[tox] | ||
envlist = | ||
lint | ||
purge | ||
|
||
[testenv:purge] | ||
skip_install = true | ||
deps = | ||
click | ||
requests | ||
pyyaml | ||
commands = | ||
python scripts/purge.py | ||
|
||
[testenv:lint] | ||
skip_install = true | ||
deps = | ||
black | ||
isort | ||
commands = | ||
isort --profile=black . | ||
black . |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pull request instead - I prefer not to commit to master..
https://github.com/OBOFoundry/obo-nor.github.io/blob/master/.github/workflows/dashboard.yml#L31