can´t disable ploomber log after activating it in jupyter notebooks - jupyter-notebook

I tested the plomber logging feature using notebooks for train/test some models by adding this to the pipeline.yaml file (papermill parameter)
papermill_params:
log_output: True
and called my ploomber notebook execution with this command:
ploomber build pipeline.yaml --log info --log-file experiment1.log
so far so good the log is printed to console and saved to file. If I open the notebook, the log is printed in every notebook cell as expected. Then I disabled the log removing the yaml entry and executing the pipeline this way:
ploomber build pipeline.yaml --log info
but now i am unable to disable log. All the messages are printed into every notebook cell making it nearly unusable when trying to see the cell output.

Related

Unable to set the kernel ("Not specified") for a jupyter notebook in Pycharm

As seen in the screenshot the kernel is "Not specified" and can not set since the dropdown is disabled. Can this be remedied?
The Project interpreter is python3 and otherwise for other file types the project works fine
I've run into the same issue of PyCharm not allowing me to select a Jupyter kernel other than the one that is saved to the notebook (the drop-down menu is either grayed-out as in your picture, or disappears altogether). This condition appears to occur when the kernel that was active when the notebook was saved is not available in the current environment. The only workaround I've found for this situation is:
Start a Jupyter notebook server using the same Python environment as you are using in PyCharm
From the Jupyter server web page, open the notebook
From the Kernel menu, select Change kernel, and then select the desired kernel
Save the notebook, then close/halt it
Re-open the notebook in PyCharm. It should then be able to execute with the kernel that was chosen in Step 3 above.

Prevent jupyter console from reading code from jupyter notebook

When on jupyter console and I hit the up arrow key, I'd like to go to the previously run line of code on that console. However it will read a previously run cell from a jupyter notebook instead. Is there a way to prevent this from happening?

prevent jupyterlab from automatically starting new session for all open tabs

I shut down all kernels and close jupyterlab in the browser, but when I open it again it starts a session, and a kernel, for all opened notebooks
I'd followed the code and found that in jupyterlab notebook code the start session function calls (POST /api/sessions) on notebook load if there is not any running kernel for the current notebook. and the API creates a session and also starts a kernel.
I can't find any config for stopping this action in jupyter configs or jupyterlab settings (settings -> advanced settings editor)
You can prevent automatically starting kernels when you open a notebook by running Jupyterlab with the jupyter lab --LabServerApp.notebook_starts_kernel=False flag.
To make the configuration permanent, you can add
c.LabServerApp.notebook_starts_kernel = False to $(jupyter --config-dir)/jupyter_lab_config.py. If this file doesn't exist yet, generate it by running jupyter lab --generate-config.
See this issue comment for more details:
https://github.com/jupyterlab/jupyterlab/issues/12019#issuecomment-1145841583

Running a python .py file on Jetbrain Pycharm

I write my .py files using Pycharm JetBrains editors. When I run my codes, the output is shown in a console entitled "Run", without any prompt. Therefore, I dont have access to the variables of my code output. How can I force the pycharm to show the output of my codes in ipython console?
You can edit the Run Configuration and check the box "Show command line afterwards". This will run your script, but leave you in an interactive prompt. Everything from your script will have been imported and available.
As a note, if you install the IPython package (Preferences -> Project -> Project Interpreter, click + to add packages) then you can get a nicer console interpreter.
Finally, a different way to accomplish what you are looking for: run under Debug rather than Run. You can set a breakpoint and then use the debugger's Console right at the line you might be interested in.

How to enable and access debug logging for notebook and IPython kernel

I'm doing a small research on IPython kernel and trying to get debug logs out of it and see how it interacts with a notebook. Now it looks like the documentation and example configs shipped in my distribution is totally outdated.
The questions
Where the ipython kernel log files are located?
How can I enable DEBUG level logging in both jupyter notebook and ipython kernel?
What I've tried
Please read this section before giving links to the official docs
First I created profiles for both IPython and notebook with the following commands:
$ ipython profile create
$ jupyter notebook --generate-config
As expected three files where created:
.jupyter/jupyter_notebook_config.py
.ipython/profile_default/ipython_config.py
.ipython/profile_default/ipython_kernel_config.py
In these files I found similar commented fragments:
# Set the log level by value or name.
# c.Application.log_level = 0
I tried to uncomment it in the jupyter config. Instead of adding more details it totally disabled console output for the jupyter process. I also tried value 50 it has the same result, value DEBUG gave me Python error on start.
I also played with these values in ipython's configs but I wasn't able to find log files location.
In mail list command line option --log-level=DEBUG is mentioned and indeed it works for jupyter. But I really want to persist this setting in a profile and have debug info for the kernel too.
Config options NotebookApp.log_level and IPKernelApp.log_level also change nothing.
I believe that this kind of functionality is still on the wishlist:
https://github.com/ipython/ipython/issues/8570
But you could try something like this:
jupyter notebook --debug > log.file 2>&1
or
ipykernel kernel --debug > log.file 2>&1
You can also try to start ipython kernel without attached frontend with option --debug:
ipython kernel --debug
You can get lot of info about interaction between kernel and the forntend by setting c.Session.debug = True in jupyter_notebook_config.py.

Resources