-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use jupyter kernel mechanism #172
Use jupyter kernel mechanism #172
Conversation
@mcg1969 This is ready for review. Some comments:
|
Thank you @fcollonval! I will review ASAP. But what should we do with the failing Windows tests? |
@fcollonval any opinions about the hacky approach taken in #104? Do you think there is merit to implementing both of these? |
The CI job got broken due to a unfortunate rename of the log file in 9797e82 |
I look at it. But firstly as you mentioned in #104, this is not really a sustainable approach - there are side effects; in particular the removal of the patch at each
So with #104 the conda environments for papermill or voila will not be aware of the other environments as only the With this modification, it is possible to install the kernel at the system or user level. Therefore all environments will be visible from any environment. |
Got it, I appreciate the explanation! It really does give your approach a good defense. And it justifies building a utility to enable this more easily. But this PR doesn't have to wait for that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Small feedback on the exposed use case. In fact, it is not working if So, this is not an argument in favor of this approach. |
Interesting. Can we improve upon your approach somehow? |
I don't think it is unreasonable to expect nb_conda_kernels to be present in any environment intended to leverage kernels. After all, wouldn't the kernel provider mechanism need to be in every such environment, too? |
Only if the application has adopted its use. Kernel providers are essentially a replacement of |
Right. But right now nb_conda_kernels is really a patch on jupyter_client so it would make sense that any tool using the latter now should also bring in the former. And if jupyter_client is replaced with a new library that is what these tools need to pull in. |
Yes I agree with you. If the purpose is to alter a tool using the kernels, it make sense to install it along side all such tools. |
We could change the kernel args to set the full executable path. But I see problem ahead for such case; like side effect due to the conda environment not being properly activated. So I would say the best practice is to install |
BTW This raises the question of handling the root environment. |
I'm pretty sure it uses RUNNER_COMMAND for the root environment if the running environment is not root. But let's check. |
But those lines are correct. If we are running a kernel that lives in the current prefix, we assume the environment is already activated, and we need to skip it. We might need to adjust the command to use absolute paths but we shouldn't use the full RUNNER_COMMAND. |
Yes they are correct for usage within notebook or JupyterLab. But in the exported kernelspec there:
Back to the use case, if I run voila on a notebook using the root environment kernel, the commands stack will be:
=> So the kernel will be executed with the root environment python. But the root environment will not be activated. So there may be inconsistency. As proof from my computer, here is the content of $HOME/.local/share/jupyter/kernels/ {"argv": ["/home/fcollonval/miniconda3/bin/python", "-m", "ipykernel_launcher", "-f", "{connection_file}"], "display_name": "Python [conda env:root] *", "language": "python", "metadata": {"conda_env_name": "root", "conda_env_path": "/home/fcollonval/miniconda3"}} and the one for $HOME/.local/share/jupyter/kernels/ {"argv": ["python", "-m", "nb_conda_kernels.runner", "/home/fcollonval/miniconda3", "/home/fcollonval/miniconda3/envs/voila", "/home/fcollonval/miniconda3/envs/voila/bin/python", "-m", "ipykernel_launcher", "-f", "{connection_file}"], "display_name": "Python [conda env:voila]", "language": "python", "metadata": {"conda_env_name": "voila", "conda_env_path": "/home/fcollonval/miniconda3/envs/voila"}} |
I see what you're saying, and I agree the behavior has to change for the exported case. I do want to make sure we do not change the activation behavior for the normal case, but that seems doable. |
And actually, perhaps |
I will open a new issue to address that point.
I agree too. It works nicely - let's not mess it up 😉
Good suggestion, I'll try. |
The future kernel provider mechanism is not coming soon: jupyter-server/jupyter_server#112
But more and more tools (voila, papermill,...) rely on the
jupyter kernelspec
mechanism. And there is at least one issue on those tools due to trouble when dealing with conda environment:So as there is a good chance people are editing a notebook before using those tools, this add an option
kernelspec_path
to install the kernel spec dynamically discovered by this extension in the specified target path.TODO:
nb_conda_kernels list