-
Notifications
You must be signed in to change notification settings - Fork 88
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
Redesign nb-tester interface #2405
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Pre-work for #2405. This PR refactors nb-tester to decouple the config logic, which decides which notebooks to run and how to patch them, from the notebook execution logic, which runs the notebooks. The config logic is already the most complicated part of the program. This PR decouples config and execution by moving them to separate files and having them communicate only by a single `NotebookJob` interface. Each `NotebookJob` contains a notebook path and instructions on how to run that notebook. This means the config logic can be scoped to creating a list of `NotebookJob` objects. This also makes the config logic easier to test. There _should_ be no behaviour changes in this PR.
9dbd215
to
b8d2f78
Compare
@@ -14,7 +14,6 @@ dependencies = [ | |||
"nbformat~=5.10.4", | |||
"ipykernel~=6.29.2", | |||
"squeaky==0.7.0", | |||
"tomli==2.2.1", |
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.
Switched to the built-in tomllib
. I believe we kept tomli
for a while for backwards-compatibility with older Python versions, but we now specify Python >= 3.11 in the pyproject.toml
, so I think it's time to remove it here.
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 like this interface! It's a good design to only allow specifying one test strategy at a time. If you want to run with multiple test strategies, then run once per test strategy. That keeps the interface and code more understandable.
Nit in the PR title that this is not a "refactor" but a "revamp" or "redesign".
Consider splitting out the changes I proposed with scripts/ci
as a prefactor. Fwict, they can be separated out from everything else. We've messed up CI config before, so it's worth having close review on them.
Splits out part of #2405 This PR pulls some of our CI functionality out of the nb-tester package and into separate scripts.
83eace1
to
9ae730d
Compare
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.
Great PR! Thank you for implementing the file patch interface, I think it will be really powerful. I included a couple of suggestions for how to utilize patches, and a small formatting error.
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.
Amazing work Frank! I left a small typo fix suggestion and a comment about the args that I think it's cool to know. I like a lot the new interface and the code looks good, so I think we can merge it once @emilkovacev's suggestions are implemented :)
Co-authored-by: Arnau Casau <[email protected]>
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.
New patching interface works really well! I tested this against a few notebooks locally, and was able to very quickly and easily get them to run.
Attempt to simplify the way we control
nb-tester
.This PR includes the patch information in the config file. Like before, each notebook is part of a group. The new aspect is each group can define how to patch each notebook in different situations.
This PR also adds tests and documentation for the config part of the script. If you exclude the new README and tests, this PR reduces the script size by ~100 LOC.
Config example
Take the following config file as an example.
If we run nb-tester against this file with
--test-strategy=ci
, each notebook in the group will be patched with thetest-eagle
device. If we run it with--test-strategy=hardware
, the notebooks will be run with no patch. Running with a test strategy not defined for that group (e.g.--test-strategy=new-strat
) means that group will be skipped.CLI example
You can also run the script without a config file with the
--patch
arg. In this case, all files listed after the--patch
argument are part of the same "group". You must include a patch for this group using TOML syntax. For example:test-docs-notebooks --patch '{ patch="qiskit-fake-provider", num_qubits=6 }' path/to/file.ipynb
Closes #2401