Sanjay M. P.
Sanjay M. P.

Reputation: 1009

Convert python script to Jupyter and save the output in html

I have a python script, which takes --days params and outputs graphs for the range, i want to convert this python script to Jupyter notebook and execute the code and save the output in html format.

parser = argparse.ArgumentParser()
parser.add_argument(
     "--days",
     type=int,
     default=1,
     help="Specify number of days data needed, else defaults to 1 day",
    )
args = parser.parse_args()

above lines gets saved in a Jupyter cell on conversion, how do pass the days argument while executing the jupyter notebook ?

Used papermill for execution and ran into the below error:

Output Notebook: mynotebook_output.ipynb
Executing:   0%|                                                                                     | 0/13 [00:00<?, ?cell/s]Executing notebook with kernel: python3
Executing:  15%|███████████▊                                                                 | 2/13 [00:01<00:09,  1.17cell/s]
Traceback (most recent call last):
File "/home/sanju/.local/bin/papermill", line 8, in <module>
   sys.exit(papermill())
File "/home/sanju/.local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/sanju/.local/lib/python3.6/site-packages/click/core.py", line 782, in main
   rv = self.invoke(ctx)
File "/home/sanju/.local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
   return ctx.invoke(self.callback, **ctx.params)
File "/home/sanju/.local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
   return callback(*args, **kwargs)
File "/home/sanju/.local/lib/python3.6/site-packages/papermill/cli.py", line 238, in papermill
   execution_timeout=execution_timeout,
File "/home/sanju/.local/lib/python3.6/site-packages/papermill/execute.py", line 110, in execute_notebook
   raise_for_execution_errors(nb, output_path)
File "/home/sanju/.local/lib/python3.6/site-packages/papermill/execute.py", line 222, in raise_for_execution_errors
   raise error 
   papermill.exceptions.PapermillExecutionError:
---------------------------------------------------------------------------
Exception encountered at "In [2]":
An exception has occurred, use %tb to see the full traceback.
    
SystemExit: 2

Also tried running the python script as cmd line on the jupyter notebook, the python script executed but no graphs are shown. jupyter nb Do advice if its the right path or is there a better version to convert the python script with output graphs in a html version.

Upvotes: 0

Views: 511

Answers (0)

Related Questions