-
Notifications
You must be signed in to change notification settings - Fork 163
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
[SCHEMA] Render schema elements in text #610
Conversation
@yarikoptic check this out! Here is an example filename format example snippet. The first one is autogenerated from the specification, while the second one is the preexisting one. It's far from perfect, but I think it's pretty promising! |
auxdatatypes are still difficult to work with.
Still far from perfect.
I'm marking this ready for review, with a couple of caveats:
|
😲 did you find a spot in the spec that yields more information? I just found this in https://bids-specification.readthedocs.io/en/latest/99-appendices/06-meg-file-formats.html#kityokogawaricoh Seems like a badly defined suffix ... reminiscent of the |
It looks like |
yes please 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apart from one comment, LGTM
Co-authored-by: Stefan Appelhoff <stefan.appelhoff@mailbox.org>
@effigies @emdupre @Remi-Gau @yarikoptic we would like to merge this PR but would feel more comfortable with at least one more review. EDIT: To clarify: Perhaps the most valuable review would be to open the build artifact (pdf or HTML), and compare the new computer rendered template with the old, hand-written template. Currently both are left in this PR for comparison --> the upper one is the new one, the lower one the old one. So you can basically go through the artifact, searching for "template" and then do a check if the entities, suffixes, etc. match and sound about right. example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have skimmed through it, saw some of my requested (forgot the medium we communicated through with @tsalo awhile back) changes reflected . This review includes some of my comments (e.g. eventually should be RFed so there is no sys.path
) which I never submitted (will not remove them) but they can be ignored.
This is a HUGE work and progress, thank you @tsalo for leading it, and everyone who contributed. Let's get it merged and work on top of that ;)
CONTRIBUTING.md
Outdated
```bash | ||
python tools/bids_schema.py entity src/schema/ src/99-appendices/04-entity-table.md | ||
``` | ||
As such, you need to ensure that the functions used throughout the specific to render these elements are appropriately referencing the schema; in essence, that, if your changes do impact how functions should be called, the function calls have been updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reads odd, needs tune up and probably split into two sentences
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
|
||
Run `mkdocs serve` and open `localhost:8000` to browse the rendered specification. | ||
Make sure that all filename format templates, entity tables, and entity definitions are correct | ||
and that the code that generates these elements is not broken by your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle, pr would do that right?
For comparing pdf changes, pdfdiff could be handy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, the CI will render the files, but the CI won't fail if the code fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, how come is that? because it is too deep (invoked through remake etc) and something just swallows its failures? Ideally we should fail if anything fails in the code... if not possible "legitimately", could be done by wrapping __main__
invocation in try/except and then creating some sentinel file and then checking after invocation of the outside tool that there is no such file.
just a comment/idea: should not stop this PR from being merged!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a problem with the mkdocs-macros
plugin.
main.py
Outdated
specification and are run/rendered with the mkdocs plugin "macros". | ||
""" | ||
import sys | ||
sys.path.append("tools/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do this, should take for of __file__
and construct full path so it wouldn't rely on being invoked from the specific directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it isn't even a script - not yet sure but better ways could emerge through review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, make it tools/Init. Py
from datetime import datetime | ||
|
||
import numpy as np | ||
|
||
sys.path.append("../tools/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like adding __init__.py
broke things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsalo I suggest to revert for now. We can smooth and streamline later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
Note that before merge the "Remove old outputs (currently retained for comparison)." should still be done (in entities table). |
import os | ||
import sys | ||
|
||
schemacode_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @yarikoptic, but this is the current version of what you commented on in #610 (comment). Should I add __init__.py
to this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed in maintainers meeting: let's remove the "old template texts" and then merge
References #544 and closes #591. Uses the
mkdocs-macros
plugin to generate certain markdown elements (e.g., the filename patterns) from the schema. This should easily extend to tables and json examples, as well.Changes proposed:
mkdocs-macros
plugin within the markdown files.macros
as dependencies.TODO:
macros
documentation says that thedefine_env
function can be in a module, I can't seem to get that working, so it's in its own file at the top level for now.pybids
is probably overkill, but I imagine thepybids
devs would have some insights on this..nii
and.nii.gz
as.nii[.gz]
in file formats.Consider dropping.json
from the list of extensions in the schema. JSON files are not alternatives to the other extensions. They are required (at some level).{{ make_filename_template(datatypes=["anat"]) }}
as bad.More To Dos (added by @sappelhoff here for better visibility, but can be done by anybody)