Skip to content

Commit

Permalink
added ga.py and lg.py before merging upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
puja-trivedi committed Jan 23, 2025
2 parents e92f559 + f19a74b commit c9d8d33
Show file tree
Hide file tree
Showing 35 changed files with 5,251 additions and 2,456 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ansr_generate_other_formats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: generating other formats for anatomical_structure

on:
pull_request_target:
types: [opened, synchronize]
paths:
- 'linkml-schema/anatomical_structure.yaml'


permissions:
contents: write

jobs:
generate_from_reusable:
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main
with:
model_name: anatomical_structure
17 changes: 17 additions & 0 deletions .github/workflows/assertion_generate_other_formats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: generating other formats for assertion_evidence

on:
pull_request_target:
types: [opened, synchronize]
paths:
- 'linkml-schema/assertion_evidence.yaml'


permissions:
contents: write

jobs:
generate_from_reusable:
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main
with:
model_name: assertion_evidence
74 changes: 0 additions & 74 deletions .github/workflows/generate_other_formats.yaml

This file was deleted.

32 changes: 27 additions & 5 deletions .github/workflows/generate_yaml_model.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Generates linkml yaml schema from metadata in googlesheets using schemasheets
name: generating yaml file

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
model:
description: 'model name'
required: true
type: string

jobs:
generate_libgen_yaml:
Expand All @@ -26,11 +32,27 @@ jobs:
sudo apt-get update
sudo apt-get install -y build-essential git wget curl
# Check if download-dir exists; if not, create it
- name: Check if download-dir exists
run: |
if [ ! -d "linkml-schema/source_${{ inputs.model }}/gsheet_output" ]; then
echo "Directory does not exist. Making directory"
mkdir -p linkml-schema/source_${{ inputs.model }}/gsheet_output
fi
# Check if gsheet.yaml exists
- name: Check if gsheet.yaml exists
run: |
if [ ! -f "linkml-schema/source_${{ inputs.model }}/gsheet.yaml" ]; then
echo "gsheet.yaml does not exist. Exiting"
exit 1
fi
# Generate yaml model
- name: Generate yaml model
run: |
cd linkml-schema
bkbit schema2model -o library_generation.yaml --gsheet --gsheet-download-dir source_library_generation/gsheet_output source_library_generation/gsheet.yaml --no-inlined
bkbit schema2model -o ${{ inputs.model }}.yaml --gsheet --gsheet-download-dir source_${{ inputs.model }}/gsheet_output source_${{ inputs.model }}/gsheet.yaml --no-inlined
cd ..
# Generate unique branch name
Expand All @@ -45,8 +67,8 @@ jobs:
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
commit-message: "Generate new version of the linkml model"
commit-message: "Generate new version of the linkml model for ${{ inputs.model }}"
branch: ${{ env.BRANCH_NAME }}
title: "Auto PR: yaml generated from google spreadsheets using schemasheets"
body: "This PR adds a autogenerated yaml file."
title: "Auto PR: ${{ inputs.model }}.yaml generated from google spreadsheets using schemasheets"
body: "This PR adds a autogenerated ${{ inputs.model }}.yaml file."
base: main
17 changes: 17 additions & 0 deletions .github/workflows/genome_generate_other_formats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: generating other formats for genome_annotation

on:
pull_request_target:
types: [opened, synchronize]
paths:
- 'linkml-schema/genome_annotation.yaml'


permissions:
contents: write

jobs:
generate_from_reusable:
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main
with:
model_name: genome_annotation
17 changes: 17 additions & 0 deletions .github/workflows/library_generate_other_formats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: generating other formats for library_generation

on:
pull_request_target:
types: [opened, synchronize]
paths:
- 'linkml-schema/library_generation.yaml'


permissions:
contents: write

jobs:
generate_from_reusable:
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main
with:
model_name: library_generation
73 changes: 73 additions & 0 deletions .github/workflows/reusable-generate_other_formats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Reusable workflow for generating other formats

on:
workflow_call:
inputs:
model_name:
description: 'A name of the model, without the .yaml extension'
required: true
type: string

permissions:
contents: write

jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install the required python packages
run: python -m pip install .[test]

- name: Other installations
run: |
sudo apt-get update
sudo apt-get install -y build-essential git wget curl
- name: Generate other model representations
run: |
cd linkml-schema
name=${{ inputs.model_name }};
echo "Processing $name model...";
gen-json-schema ${name}.yaml > ../json-schema-autogen/${name}.json;
# generating jsonld context and removing generation_date field to avoid constant updates
gen-jsonld-context ${name}.yaml > ../jsonld-context-autogen/${name}.context.jsonld;
sed -i "/generation_date/d" ../jsonld-context-autogen/${name}.context.jsonld;
gen-pydantic ${name}.yaml > ../models_py-autogen/${name}.py;
if [ ${name} = "library_generation" ] || [ ${name} = "genome_annotation" ]; then
echo "Fixing erdiagrams for $name";
python ../utils/fix_and_create_erdiagram.py;
else
gen-erdiagram ${name}.yaml > ../erdiagram-autogen/${name}.md;
fi
cd ..
- name: Adding other model representations to git
run: |
name=${{ inputs.model_name }};
git config --global user.name "action@github.com"
git config --global user.email "Github Actions"
git branch
git diff
git add json-schema-autogen/${name}.json
git add jsonld-context-autogen/${name}.context.jsonld
git add models_py-autogen/${name}.py
git add erdiagram-autogen/${name}.md
if ! git diff --quiet HEAD; then
git commit -m "generate another formats for ${name} model"
git pull --rebase # to avoid conflicts with different wf runs
git push
else
echo "No changes to commit"
fi
94 changes: 94 additions & 0 deletions .github/workflows/reusable-generate_other_formats_new.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Reusable workflow for generating other formats

on:
workflow_call:
inputs:
model_name:
description: 'A name of the model(s), without the .yaml extension. Models should be separated by a comma.'
required: true
type: string
linkml_version:
description: 'linkml version to test (optional, by default it uses one from the pyproject.toml)'
required: false
type: string

permissions:
contents: write

jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install the required python packages
run: python -m pip install .[test]

- name: Updating linkml if requested
if: ${{ inputs.linkml_version != null }}
run: |
pip install linkml==${{ inputs.linkml_version }}
echo "linkml version: ${{ inputs.linkml_version }} has been installed"
- name: Other installations
run: |
sudo apt-get update
sudo apt-get install -y build-essential git wget curl
- name: Generate other model representations
run: |
cd linkml-schema
models_list="${{ inputs.model_name }}"
echo " "
echo "Model list: $models_list"
for name in $(echo "$models_list" | tr ',' '\n'); do
echo "Processing $name model...";
linkml generate json-schema ${name}.yaml > ../json-schema-autogen/${name}.json;
echo "json-schema generated";
# generating jsonld context and removing generation_date field to avoid constant updates
linkml generate jsonld-context ${name}.yaml > ../jsonld-context-autogen/${name}.context.jsonld;
sed -i "/generation_date/d" ../jsonld-context-autogen/${name}.context.jsonld;
echo "jsonld-context generated";
linkml generate pydantic ${name}.yaml > ../models_py-autogen/${name}.py;
echo "pydantic model generated";
if [ ${name} = "library_generation" ] || [ ${name} = "genome_annotation" ]; then
echo "Fixing erdiagrams for $name";
python ../utils/fix_and_create_erdiagram.py;
else
linkml generate erdiagram ${name}.yaml > ../erdiagram-autogen/${name}.md;
fi
echo "erdiagram generated";
done
cd ..
- name: Adding other model representations to git
run: |
git config --global user.name "action@github.com"
git config --global user.email "Github Actions"
git branch
models_list="${{ inputs.model_name }}"
echo "Model list: $models_list"
for name in $(echo "$models_list" | tr ',' '\n'); do
echo "Processing: $name"
git add json-schema-autogen/${name}.json
git add jsonld-context-autogen/${name}.context.jsonld
git add models_py-autogen/${name}.py
git add erdiagram-autogen/${name}.md
done
if ! git diff --quiet HEAD; then
git commit -m "generate another formats for ${models_list} model(s)"
git pull --rebase # to avoid conflicts with different wf runs
git push
else
echo "No changes to commit"
fi
19 changes: 19 additions & 0 deletions .github/workflows/software_update_generate_other_formats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: testing a linkml version, generating other formats for multiple models

on:
workflow_dispatch:
inputs:
linkml_version:
description: 'linkml version to test'
required: true
type: string

permissions:
contents: write

jobs:
generate_from_reusable:
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats_new.yaml@main
with:
model_name: genome_annotation,library_generation,anatomical_structure,assertion_evidence
linkml_version: ${{ github.event.inputs.linkml_version }}
Loading

0 comments on commit c9d8d33

Please sign in to comment.