Open you-n-g opened 4 years ago
That does appear to be a hard-coded value. This file predates my time with the project (and hasn't anything but a linting fix in 4 years!), but I believe it was used more as a testing / proof of concept tool for using jupyter_client to pass code to kernels (I might be wrong on that).
What's your goal here? There might be a better library interface depending on what you're trying to achieve. Usually for direct code execution people use nbclient, directly or indirectly, which has more configurable options for passing and executing code through jupyter_client.
That being said, I'm totally fine with making that hard-coded value configurable if you want to make that change.
@MSeal Thanks for you quick response.
Sometimes I write some code in jupyter notebook first, then I want to convert it to a python script (which can be easily managed by git) with minimal modification ('minimal' means that I even don't have to change the magic function) and run it regularly.
Ahh generally I just strip outputs (if you want a clean file) and commit the notebook to git directly, using papermill when I want to re-execute it. Saves one from the multiple-sources of truth problem.
For what you described you may be able to just use ipython -c 'mycode.py'
and skip the kernel abstraction in that case as you're not running it in any application setting. Also I believe the nbconvert conversion to python files will translate magics for you as well if you wanted to use a plain python
executable entrypoint instead.
Yes, there are kinds of solution. But I think jupyter run
will be the most convient.
ipython -c 'mycode.py'
will raise some exception when plotting some figures.I'm using the alternatives ways. But it will be better if we can use jupyter run
directly.
Thanks
I try to run my code
a.py
with jupyter run. Here is my code ina.py
Here is the result.
I found that it is hard coded here
What's the motivation for such hardcode. Could I configure it ? Thanks.