Skip to content
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

Option for not writing an output ipynb file #669

Merged
merged 2 commits into from Jun 28, 2022

Conversation

dcnadler
Copy link
Contributor

What does this PR do?

In the current setup of papermill, an output_path is required to write an output ipynb file even if you only want to use the returned NotebookNode object. For example, in my case, I end up using tempfile a good amount to get around this.

This motivation came up in PR #107, as well

Approach

Let user pass output_path = None to indicate they don't want to write an output ipynb.

A new IO handler was added, NoIOHandler to deal with this option.

Alternative approach

I tried to match the api interface of PR #107, but I could also see having a specific string that indicates no output writing (similar to "-" indicating stdin/stdout).

The advantage being that the IO handler can be registered in the IO factory as designed, and not implemented outside of it as I had to do with path=None, since get_handler uses path.startswith.

If that sounds like a better approach, I'm open to string suggestions - haven't thought of a good one yet :)

Copy link
Member

@MSeal MSeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this seems like a cleaner way than doing '/dev/null' output pathing.

@codecov
Copy link

codecov bot commented Jun 28, 2022

Codecov Report

Merging #669 (bb587e0) into main (a6b00a8) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #669      +/-   ##
==========================================
+ Coverage   91.64%   91.72%   +0.07%     
==========================================
  Files          17       17              
  Lines        1568     1583      +15     
==========================================
+ Hits         1437     1452      +15     
  Misses        131      131              
Impacted Files Coverage Δ
papermill/execute.py 100.00% <ø> (ø)
papermill/iorw.py 80.23% <100.00%> (+0.80%) ⬆️
papermill/parameterize.py 97.95% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a6b00a8...bb587e0. Read the comment docs.

@MSeal MSeal merged commit 98013f0 into nteract:main Jun 28, 2022
@dcnadler dcnadler deleted the no-output-file branch June 28, 2022 17:20
@mnp
Copy link

mnp commented Sep 20, 2022

How does one do this from the CLI?

Seems like passing /dev/null would be fine but you get a warning when it doesn't know that file extension.

@dcnadler
Copy link
Contributor Author

This PR did modify the CLI interface.

If you wanted to add a no-output CLI option, it looks like you'd need to add that in https://github.com/nteract/papermill/blob/main/papermill/ and work around the stdout logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants