-
Notifications
You must be signed in to change notification settings - Fork 84
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
serializing nested ntbk metadata items #147
Conversation
Yep the failed tests show that the metadata is being correctly propagated to the sphinx env, you just need to update them! |
OK I think I've got it fixed (in a fairly inelegant way, but 🤷♂ ). I had to update the pre-commit flake8 test because the nested JSON lines are too long, but other than that tests were passing |
tests/test_parser.py
Outdated
"ipub": '{"bibliography": "example.bib", "biboptions": ["super", "sort"], "bibstyle": "unsrtnat", "language": "portuges", "listcode": true, "listfigures": true, "listtables": true, "titlepage": {"author": "Authors Name", "email": "[email protected]", "institution": ["Institution1", "Institution2"], "logo": "logo_example.png", "subtitle": "Sub-Title", "supervisors": ["First Supervisor", "Second Supervisor"], "tagline": "A tagline for the report.", "title": "Main-Title"}, "toc": {"depth": 2}, "pandoc": {"use_numref": true, "at_notation": true}, "sphinx": {"bib_title": "My Bibliography"}}', | ||
"jupytext": '{"metadata_filter": {"notebook": "ipub"}}', | ||
"kernelspec": '{"display_name": "Python 3", "language": "python", "name": "python3"}', | ||
"language_info": '{"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2"}', |
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.
@chrisjsewell is there any reason for us to think any of this stuff will be brittle and break over time? (e.g. as libraries update etc?)
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.
ugh I think the answer is yes, because the tests are erroring because the version of jupytext they've got is different from the one on my machine. hmmmmm
.pre-commit-config.yaml
Outdated
tests/test_parser.py| | ||
tests/test_text_based.py |
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.
Lazy 😜 ! Add # noqa: E501
to specific lines that are too long, not ignore the whole 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.
ahhh that's right, I knew there was a way to do that
tests/test_parser.py
Outdated
@@ -23,7 +29,18 @@ def test_complex_outputs(sphinx_run, file_regression): | |||
# print(sphinx_run.status()) | |||
assert sphinx_run.warnings() == "" | |||
assert sphinx_run.app.env.metadata == { |
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 this is pretty long now, probably easier to add a data_regression.check
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.
same with the others
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.
ok this is a good opportunity to learn about data_regression.check
. I guess that we will just have to update the regression templates any time that the jupytext version is 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.
Yeh, or if it's going to change to often, just do as a minimum assert set(sphinx_run.app.env.metadata.keys()) == {"celltoolbar", ...}
@chrisjsewell where does the jupytext dependency get defined? I didn't see it in there, but I think it's needed for myst text reading, no? Are we inheriting it from some other package? And if so then should I just add it in explicitly? edit: oh weird, we're not using jupytext in the parsing, but the file metadata is still different somehow... I am thinking this might be more sensible if we just check to make sure the keys are always the same, as well as the values of a few select keys |
There's (at least currently) no specific dependency of The versions you see in the notebook/myst-markdown metadata, are/were generated during |
OK take a look at the latest testing suite. I'm checking for all the keys in the metadata, as well as for the proper values for a few keys, including both "flat" and "nested" values. Think that works? |
assert sphinx_run.app.env.metadata["basic_run"]["test_name"] == "notebook1" | ||
assert ( | ||
sphinx_run.app.env.metadata["basic_run"]["kernelspec"] | ||
== '{"display_name": "Python 3", "language": "python", "name": "python3"}' |
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.
note - black did this, and it seemed reasonable + removed the line too long issues, so I went with it
Codecov Report
@@ Coverage Diff @@
## master #147 +/- ##
=======================================
Coverage 83.85% 83.85%
=======================================
Files 9 9
Lines 805 805
=======================================
Hits 675 675
Misses 130 130
Continue to review full report at Codecov.
|
Yep looks fine to me 👍 |
I don't think you realize how easy you have it here lol. For example, I just has this PR merged aiidateam/aiida-core#3613 after months of having to address revisions from 3 reviewers and a lot more stringent CI checks 😬 |
haha - my worst was in switching over the matplotlib documentation entirely to use sphinx-gallery. It took 7 months and more bikeshedding than I have ever experienced in my life :-) I also had this MNE-python PR that had 268 comments over 3 months before it finally got merged. |
* serializing nested ntbk metadata items * updating tests for nested metadata
I think that this is the only thing that we need to do in order to get nested metadata working.
edit: I think I need to edit some of the tests because the metadata in the output document will be different...I will try and figure out to update the regressions stuff so that it works (though somebody comment if that's not the problem here). @chrisjsewell are we OK with just updating the regression templates so that they now include the JSON-serialized nested metadata?
closes #147