-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add workflow for publishing model schemata to dandi/schema
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Publish model schemata | ||
|
||
on: | ||
# ATM, this is the closest trigger to a PR merging | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- dandi/model*.py | ||
- tools/pubschemata.py | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout this repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Need history for `git describe` | ||
path: dandi | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.8' | ||
|
||
- name: Install dandi | ||
run: python -m pip install . | ||
working-directory: dandi | ||
|
||
- name: Checkout dandi/schema | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: dandi/schema | ||
path: schema | ||
token: ${{ secrets.DANDI_GITHUB_TOKEN }} | ||
|
||
- name: Generate model schemata | ||
run: python dandi/tools/pubschemata.py schema/releases | ||
|
||
- name: Commit changes | ||
run: | | ||
git add releases | ||
if ! git diff --quiet | ||
then git commit -m "Publish model schemata as of dandi-cli $(git -C ../dandi describe --tags)" | ||
git push | ||
else echo "No changes to commit" | ||
fi | ||
working-directory: schema | ||
|
||
# vim:set sts=2: |
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,15 @@ | ||
from pathlib import Path | ||
import sys | ||
from dandi.models import AssetMeta, CommonModel, DandiMeta | ||
|
||
|
||
def publish_model_schemata(releasedir): | ||
version = CommonModel.__fields__["schemaVersion"].default | ||
vdir = Path(releasedir, version) | ||
vdir.mkdir(exist_ok=True, parents=True) | ||
(vdir / "dandiset.json").write_text(DandiMeta.schema_json(indent=2)) | ||
(vdir / "asset.json").write_text(AssetMeta.schema_json(indent=2)) | ||
|
||
|
||
if __name__ == "__main__": | ||
publish_model_schemata(sys.argv[1]) |