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

Convert models to macro templates #94

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

dbirman
Copy link
Member

@dbirman dbirman commented Oct 25, 2024

This PR overhauls the aind-data-schema-models repository to use jinja2 templates.

The entry point is the run_all.sh script, which pulls the templates from the _generators/templates folder. The name of each template file is used to get the corresponding data from the models folder. The templates then parse each row, generating the corresponding classes, and merge them into the ALL/ONE_OF patterns that we use. It's not super easy to write the templates so I almost certainly made a typo somewhere, especially in the docstrings appreciate a close eye on them.

Some additional utility functions were added to support this and tests to coverage the new code.

Overall I'm happy with this approach, it's super simple and the templates are pretty understandable except for some weird edge cases with how empty columns are treated by pandas. This should be backward compatible with our existing repos, but we need to check carefully before merging this.

Also the mouse_anatomy file is massive, although it's only really a few MB so not a big deal to keep it. I vote that we merge this in some form and then revisit how to handle large vocabularies with this issue #80 in the future.

@dbirman dbirman marked this pull request as ready for review October 30, 2024 05:03
@dbirman dbirman requested review from jtyoung84, Sun-flow and dyf and removed request for Sun-flow October 30, 2024 05:03
@dbirman
Copy link
Member Author

dbirman commented Oct 30, 2024

Closes #73

@dbirman
Copy link
Member Author

dbirman commented Oct 30, 2024

Closes #63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant