-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Simplify dev_tools.notebooks.utils.rewrite_notebook #6030
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
Merged
pavoljuhas
merged 8 commits into
quantumlib:master
from
pavoljuhas:simplify-rewrite_notebook
Mar 14, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dad7560
Simplify dev_tools.notebooks.utils.rewrite_notebook
pavoljuhas 85891a3
Add xfailing tests to verify cleanup of temporary notebooks
pavoljuhas c695e98
Add notebook utility remove_if_temporary_notebook
pavoljuhas dd1a130
rewrite_notebook - write new file after pattern validation
pavoljuhas ed7315e
Clean up temporary files produced by rewrite_notebook
pavoljuhas 9464f43
Lint - clean up directory last as before
pavoljuhas 92477a7
Always create temporary file with rewrite_notebook
pavoljuhas 0d5895f
Purge the remove_if_temporary_notebook function
pavoljuhas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ def test_notebooks_against_released_cirq(notebook_path): | |
notebook_file = os.path.basename(notebook_path) | ||
notebook_rel_dir = os.path.dirname(os.path.relpath(notebook_path, ".")) | ||
out_path = f"out/{notebook_rel_dir}/{notebook_file[:-6]}.out.ipynb" | ||
rewritten_notebook_descriptor, rewritten_notebook_path = rewrite_notebook(notebook_path) | ||
rewritten_notebook_path = rewrite_notebook(notebook_path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
papermill_flags = "--no-request-save-on-cell-execute --autosave-cell-every 0" | ||
cmd = f"""mkdir -p out/{notebook_rel_dir} | ||
papermill {rewritten_notebook_path} {out_path} {papermill_flags}""" | ||
|
@@ -83,6 +83,4 @@ def test_notebooks_against_released_cirq(notebook_path): | |
f"notebook (in Github Actions, you can download it from the workflow artifact" | ||
f" 'notebook-outputs')" | ||
) | ||
|
||
if rewritten_notebook_descriptor: | ||
os.close(rewritten_notebook_descriptor) | ||
os.remove(rewritten_notebook_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems we are (and have always been) leaking temporary files. Could you fix while you're at it?
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.
done.
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.
@viathor - thank you for the review. The temporary files cleanup was a bit more involved - can you please take a quick look again?