#365·papermill

Running papermill on Jupytext's `.py` notebook

Author: hoangthienan95Created May 16, 2019Updated Feb 19, 2026

I'm running papermill on LSF and for some reason I can run it locally fine but when submitting the job it just gets stuck at 60% for 20 minutes. I used Jupytext to convert my notebook into .py notebook and run it like a script with default parameters and it finished in less than 1 minute. I think this has to do with starting/running the kernel. What can I do to diagnose this?

Also, is it possible to use papermill to run Jupytext's converted .py file as a script, using the current env's python interpreter instead of through Jupyter kernel? I usually develop scripts iteratively using Jupyter Notebook then have to run them as python script (partly of the error seen above, our cluster is finicky). I really love papermill's ability to parametrize scripts without writing verboseargparse/ CLI parser code and it comes with YAML parsing. I can just document my arguments using markdown cell in Jupyter notebook, which can be turned into comments in the .py file with Jupytext.

It would be amazing if I can use Jupytext to convert my notebook, papermill to inject parameter (by parsing the tags from the .py file, which would appear as a comment, ex: # + {"tags": ["parameters"]}), and run it like a normal script. The parametrized script can be a temp file and deleted after execution. Is it possible to do such thing? Where should I go first to try to implement such feature?

Basically, it would be running papermill with --prepare-only then convert to .py with jupytext, then run the script with no parameters. Right now, if I do .py as the output folder extension, it returns the file with the notebook's JSON, how do I make it pipe directly into Jupytext and possibly execute it?