[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 👍 |
|
@tsalo Sorry for being slow... The example snippet and rendering look absolutely wonderful to me!!! Awesome job! |
|
Just a reminder to us that we should merge this after ASL and qMRI, but before PET ... so that we can finally start reaping the benefits. see also #690 (comment) |
sappelhoff
left a comment
There was a problem hiding this comment.
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.
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.
Reads odd, needs tune up and probably split into two sentences
|
|
||
| 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.
In principle, pr would do that right?
For comparing pdf changes, pdfdiff could be handy
There was a problem hiding this comment.
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.
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.
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.
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.
But it isn't even a script - not yet sure but better ways could emerge through review
There was a problem hiding this comment.
Yep, make it tools/Init. Py
|
|
||
| import numpy as np | ||
|
|
||
| sys.path.append("../tools/") |
There was a problem hiding this comment.
It looks like adding __init__.py broke things.
There was a problem hiding this comment.
@tsalo I suggest to revert for now. We can smooth and streamline later on.
|
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.
Sorry @yarikoptic, but this is the current version of what you commented on in #610 (comment). Should I add __init__.py to this line?
sappelhoff
left a comment
There was a problem hiding this comment.
as discussed in maintainers meeting: let's remove the "old template texts" and then merge

References #544 and closes #591. Uses the
mkdocs-macrosplugin 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-macrosplugin within the markdown files.macrosas dependencies.TODO:
macrosdocumentation says that thedefine_envfunction 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.pybidsis probably overkill, but I imagine thepybidsdevs would have some insights on this..niiand.nii.gzas.nii[.gz]in file formats.Consider dropping.jsonfrom 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)