Skip to content

Commit

Permalink
[MNT] Add example scripts for creating data dictionary + graph data J…
Browse files Browse the repository at this point in the history
…SON schema (#427)

* add example scripts for creating data dict + graph data jsonschema

* move helper scripts into directory

* update instruction on regenerating vocab file
  • Loading branch information
alyssadai authored Feb 4, 2025
1 parent 12342c1 commit 5a5709c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ This vocabulary is used by Neurobagel APIs to fetch available attributes and att
When the Neurobagel graph data model is updated (e.g., if new classes or subclasses are created),
this file should be regenerated by running:
```bash
python generate_nb_vocab_file.py
python helper_scripts/generate_nb_vocab_file.py
```
This will create a file called `nb_vocab.ttl` in the current working directory.
11 changes: 11 additions & 0 deletions helper_scripts/generate_dictionary_jsonschema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is an example script for generating a JSON schema for the Neurobagel data dictionary model.
# Example usage: python generate_dictionary_jsonschema.py

import json

from bagel.dictionary_models import DataDictionary

FPATH = "neurobagel_datadictionary.schema.json"

with open(FPATH, "w") as f:
f.write(json.dumps(DataDictionary.model_json_schema(), indent=2))
16 changes: 16 additions & 0 deletions helper_scripts/generate_graphdata_jsonschema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is an example script for generating a JSON schema for the Neurobagel graph data model (i.e., the model for a Neurobagel "Dataset").
# Example usage: python generate_graphdata_jsonschema.py

import json

from bagel.models import Dataset

FPATH = "neurobagel_graphdata.schema.json"

with open(FPATH, "w") as f:
f.write(
json.dumps(
Dataset.model_json_schema(),
indent=2,
)
)
File renamed without changes.
File renamed without changes.

0 comments on commit 5a5709c

Please sign in to comment.