Skip to content

Commit af46e1f

Browse files
committed
adding script and GA to edit bican_biolink and include bican specific requirements, for now it is about the category slot
1 parent 38a7370 commit af46e1f

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: generating other formats
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'linkml-schema/bican_biolink.yaml'
9+
10+
permissions:
11+
contents: write
12+
13+
14+
jobs:
15+
generate:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout this repository
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: 3.9
25+
26+
- name: Install the required python packages
27+
run: python -m pip install .[test]
28+
29+
- name: Other installations
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install -y build-essential git wget curl
33+
34+
- name: Editing the bican biolink yaml file
35+
run: |
36+
cd linkml-schema
37+
python ../utils/bican_biolink_edit.py bican_biolink.yaml
38+
cd ..
39+
40+
- name: Adding edited file to git
41+
run: |
42+
git config --local user.email "[email protected]"
43+
git config --local user.name "GitHub Action"
44+
if ! git diff linkml-schema/bican_biolink.yaml --quiet; then
45+
git add linkml-schema/bican_biolink.yaml
46+
git commit -m "Updating the bican biolink yaml file for the bican specific case"
47+
git push
48+
else
49+
echo "No changes to commit"
50+
fi

.github/workflows/generate_other_formats.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
paths:
88
- 'linkml-schema/**'
99
workflow_run:
10-
workflows: [ generating yaml file ]
10+
workflows: [ "generating yaml file", "bican_biolink_edit" ]
1111
types:
1212
- completed
1313

utils/bican_biolink_edit.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Functions to edit the biolink model after running the general trimmer from bkbit
2+
# Edits are specific to our needs in bican and are not generalizable.
3+
# Earlier the issues were "fixed" by adding "slot_usage", but it might be easier to add it to the bican_biolink directly.
4+
import sys
5+
import yaml
6+
from pathlib import Path
7+
8+
def bican_biolink_edit(schema_yaml: str) -> None:
9+
"""
10+
Edit the biolink model to fit the bican needs
11+
12+
:param schema: SchemaView object
13+
"""
14+
# Change the category slot to have a curie range and a pattern for bican categories
15+
schema_yaml_path = Path(schema_yaml)
16+
with schema_yaml_path.open("r") as f:
17+
schema_dict = yaml.safe_load(f)
18+
schema_dict["slots"]["category"]["range"] = "curie"
19+
schema_dict["slots"]["category"]["pattern"] = r"^bican:[A-Z][A-Za-z]+$"
20+
schema_dict["slots"]["category"]["description"] = schema_dict["slots"]["category"]["description"] + ". NOTE: The category slot was modified to have a curie range and a pattern for bican categories."
21+
22+
with schema_yaml_path.open("w") as f:
23+
f.write(yaml.dump(schema_dict, sort_keys=False))
24+
25+
26+
if __name__ == '__main__':
27+
bican_biolink_yaml_path = sys.argv[1]
28+
bican_biolink_edit(bican_biolink_yaml_path)

0 commit comments

Comments
 (0)