Skip to content
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

[MNT] Add example scripts for creating data dictionary + graph data JSON schema #427

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alyssadai
Copy link
Contributor

@alyssadai alyssadai commented Jan 29, 2025

Changes proposed in this pull request:

  • Add standalone Python scripts for creating JSON schema from our Pydantic models

Checklist

This section is for the PR reviewer

  • PR has an interpretable title with a prefix ([ENH], [FIX], [REF], [TST], [CI], [MNT], [INF], [MODEL], [DOC]) (see our Contributing Guidelines for more info)
  • PR has a label for the release changelog or skip-release (to be applied by maintainers only)
  • PR links to GitHub issue with mention Closes #XXXX
  • Tests pass
  • Checks pass

For new features:

  • Tests have been added

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

Summary by Sourcery

New Features:

  • Add standalone Python scripts for creating JSON schema from Pydantic models.

@alyssadai alyssadai added the skip-release PR doesn't appear in the changelog and preserves current version when merged label Jan 29, 2025
@alyssadai alyssadai self-assigned this Jan 29, 2025
Copy link

sourcery-ai bot commented Jan 29, 2025

Reviewer's Guide by Sourcery

This pull request introduces two new scripts that generate JSON schemas for the Neurobagel data dictionary and graph data models. These scripts use the Pydantic models to create the schemas and output them to JSON files.

Sequence diagram for JSON schema generation

sequenceDiagram
    participant Script
    participant PydanticModel
    participant FileSystem
    Script->>PydanticModel: model_json_schema()
    PydanticModel-->>Script: JSON schema
    Script->>FileSystem: Write schema to file
    Note over Script,FileSystem: Writes formatted JSON with indent=2
Loading

Flow diagram for JSON schema generation process

graph TD
    A[Pydantic Models] --> B[generate_dictionary_jsonschema.py]
    A --> C[generate_graphdata_jsonschema.py]
    B --> D[neurobagel_datadictionary.schema.json]
    C --> E[neurobagel_graphdata.schema.json]
    subgraph Models
    F[DataDictionary Model] -.-> A
    G[Dataset Model] -.-> A
    end
Loading

File-Level Changes

Change Details Files
Added a script to generate a JSON schema for the Neurobagel graph data model.
  • Created a new Python script.
  • Imported the necessary libraries.
  • Used the Dataset model to generate the JSON schema.
  • Output the schema to a JSON file.
generate_graphdata_jsonschema.py
Added a script to generate a JSON schema for the Neurobagel data dictionary model.
  • Created a new Python script.
  • Imported the necessary libraries.
  • Used the DataDictionary model to generate the JSON schema.
  • Output the schema to a JSON file.
generate_dictionary_jsonschema.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.55%. Comparing base (62cbad8) to head (07dcf91).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #427   +/-   ##
=======================================
  Coverage   98.55%   98.55%           
=======================================
  Files          18       18           
  Lines        1109     1109           
=======================================
  Hits         1093     1093           
  Misses         16       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-release PR doesn't appear in the changelog and preserves current version when merged
Projects
Status: Implement - Done
Development

Successfully merging this pull request may close these issues.

1 participant