-
Notifications
You must be signed in to change notification settings - Fork 308
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
Inject session identifier into environment variable. #679
Conversation
Codecov Report
@@ Coverage Diff @@
## main #679 +/- ##
==========================================
- Coverage 77.81% 77.80% -0.01%
==========================================
Files 110 110
Lines 10415 10464 +49
Branches 1403 1404 +1
==========================================
+ Hits 8104 8142 +38
- Misses 1922 1930 +8
- Partials 389 392 +3
Continue to review full report at Codecov.
|
The use of session should solve this problem, as far as I know the name of the session can be used to record the path |
I'm highly confused by this statement, and what it's trying to convey. |
Oh I see, sorry for not looking at the question carefully, have you considered the effect of root_dir on this path? The current session maintenance for files is probably enough, deleting the session when the file is moved or deleted seems to solve all the problems |
Yes, but I haven't check, my understanding is that the notebook server process CWD is root_dir. |
So it may expose the current server's |
There are many use case where users want to know the current notebook name/path. This help by adding a session identifier (to not really say this is the current notebook name), and by default make it the full path to the notebook document that created the session. This will of course not work if the notebook get renamed, but we can tackle this later. See also jupyter/jupyter_client#656, jupyter/notebook#6180. It will need to be ported to jupyter_server as well. This is the mirror commit of jupyter/notebook#6279 on main notebook.
c4056a5
to
7abce6b
Compare
Sure, removed the |
Love this PR, I think this is really useful!
Maybe it is useful to have this standard in the Jupyter ecosystem, what do you think? |
What about multiple notebooks connected to a single Kernel? e.g. in jupyterlab, you can connect multiple notebook, console (console don't have a path) to a single kernel. What is the intended behavior? Should the |
It can't be a list, as it is an env variable, it could be a I'm fine with SCRIPT_NAME as well, or any other name that would get this in, I does not particularly matter to me, but we've been through the past few month/years through various proposal, and roughly:
Now my idea is to already get that somehow, somewhere, as one source for the current file name or whatever, and at least in IPykernel, use this (and/or other sources), to set |
yes, this is what I was meaning. However, thinking more, the maintenance of that string would be a pain when notebooks/console/files would connect/disconnect.
That sounds like a good practice to identity the origin of the kernel message request. IIRC There is already a (unused)
this would work if the content if collocated to the kernel (same machine, same env), but would not be applicable for remote kernels or remote content (when the content is not colocated with the kernel). |
Of course, unless you know how to map from one to the other. |
We have discussed this during the weekly server dev meeting:
|
I have relaunched the failing CI (Jupyter Server Tests on windows and Mac OS). It is still failing with the same error. e.g on Windows
Is this expected due to some flakyness? |
Yes, we've had some flakiness overall in CI recently. |
Based on the previous discussion, I think we agree to to move forward with this partial solution, and agree that it is already useful a a hint. @Carreau Maybe you could add in the doc a paragraph around this, open a subsequent issue to keep track of the remaining work. Based on that, we could merge. Thx again. |
This will get merged tomorrow unless there are any more comments or suggestions! |
Kicking CI since a lot has changed since the last commit. |
Whoa, this is new, on the Windows builds.
I just kicked a previously passing build to see if it happens there. |
The other builds passed, kicked this one again. |
Ah, I think what it is is that we are overriding the default env that is passed down here, which is preventing the random number generator from working on Windows. |
Merged as failing Windows tests seem to be unrelated. |
Actually, they probably were relevant as @blink1073 indicated (why only Windows though?). I conflated it with #672 |
) * Inject session identifier into environment variable. There are many use case where users want to know the current notebook name/path. This help by adding a session identifier (to not really say this is the current notebook name), and by default make it the full path to the notebook document that created the session. This will of course not work if the notebook get renamed, but we can tackle this later. See also jupyter/jupyter_client#656, jupyter/notebook#6180. It will need to be ported to jupyter_server as well. This is the mirror commit of jupyter/notebook#6279 on main notebook. * Make start_kernel env extend os.environ (#859) * Make start_kernel env extend os.environ * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Matthias Bussonnier <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
There are many use case where users want to know the current notebook
name/path. This help by adding a session identifier (to not really say
this is the current notebook name), and by default make it the full path
to the notebook document that created the session.
This will of course not work if the notebook get renamed, but we can
tackle this later.
See also jupyter/jupyter_client#656,
jupyter/notebook#6180. It will need to be ported
to jupyter_server as well.
This is the mirror commit of
jupyter/notebook#6279 on main notebook.