jupyter / jupyter_client

Jupyter protocol client APIs
https://jupyter-client.readthedocs.io
BSD 3-Clause "New" or "Revised" License
390 stars 283 forks source link

The `OUTPUT_TIMEOUT` of command `jupyter run` is hard-coded as 10 seconds #559

Open you-n-g opened 4 years ago

you-n-g commented 4 years ago

I try to run my code a.py with jupyter run. Here is my code in a.py

import time
i = 1
while True:
    i += 1
    time.sleep(5)
    print(123)

Here is the result.

image

I found that it is hard coded here

What's the motivation for such hardcode. Could I configure it ? Thanks.

MSeal commented 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.

you-n-g commented 4 years ago

@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.

MSeal commented 4 years ago

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.

you-n-g commented 4 years ago

Yes, there are kinds of solution. But I think jupyter run will be the most convient.

I'm using the alternatives ways. But it will be better if we can use jupyter run directly.

Thanks

rgbkrk commented 4 years ago

This kind of seems like we should deprecate jupyter run, at least removing it from this repo since I don't think any maintainers would want to spend a lot of effort on it (especially when we have nbclient)