-
Notifications
You must be signed in to change notification settings - Fork 304
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
Set JPY_SESSION_NAME to full notebook path. #1100
Conversation
Codecov ReportBase: 79.93% // Head: 79.99% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1100 +/- ##
==========================================
+ Coverage 79.93% 79.99% +0.05%
==========================================
Files 68 68
Lines 8124 8143 +19
Branches 1601 1604 +3
==========================================
+ Hits 6494 6514 +20
+ Misses 1205 1202 -3
- Partials 425 427 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Thanks @Carreau. I don't see an issue with making get_kernel_env()
async since its essentially an internal method (i.e., so custom (and synchronous) SessionManagers should still work calling their "internal" implementation). I suppose things could be dicey if there is a server extension that is calling that method on the active SessionManager
, but, hey, "major release boundaries" have their benefits. 😉
"Create a uuid for a new session" | ||
return str(uuid.uuid4()) | ||
|
||
async def create_session( | ||
self, path=None, name=None, type=None, kernel_name=None, kernel_id=None | ||
): | ||
"""Creates a session and returns its model""" | ||
"""Creates a session and returns its model | ||
|
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.
Should we add parameter descriptions for the others, or remove the description for name
?
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.
I added the description of what I was sure of, but yes in general many of those function should get actual documentation.
if name is not None: | ||
session_dir = await self.contents_manager.get_kernel_path(path=path) | ||
cwd = self.kernel_manager.cwd_for_path(path) | ||
path = os.path.join(cwd, session_dir, name) | ||
assert isinstance(path, str) |
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.
Won't path
be the same value as name
when the older form of the body is used (i.e., the one that includes a 'notebook' stanza)? And, if so, will that produce the expected results?
Any idea how "old" the old API is? I.e., does lab or nbclassic use that form of payload?
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.
I honestly don't know. It's honestly really unclear for me why this is still called path
if it's often (always?) not a path.
I'm also quite confused about the on-disk Path and Api Path which is why I started to add type annotations.
0b3e4d5
to
2c0ddb0
Compare
Ah, I have to fix CI separately for changes in pytest-jupyter |
Thanks, some of the original failures were due to changes I've made, so no problem. |
39a38cd
to
766b878
Compare
if name is not None: | ||
session_dir = await ensure_async(self.contents_manager.get_kernel_path(path=path)) | ||
cwd = self.kernel_manager.cwd_for_path(path) | ||
path = os.path.join(cwd, session_dir, name) | ||
assert isinstance(path, str) | ||
return {**os.environ, "JPY_SESSION_NAME": path} |
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.
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.
That is true, thanks.
97454c3
to
4aeabaa
Compare
pre-commit (pyupgrade) seem to insist on having optional types be X|Y which is only python 3.10 plus AFAICT. |
That sounds like a bug, we have it configured to |
Okay, build failures seem fixed. |
Do you want me to rebase / squash ? |
No thanks, squash is the default merge type |
Note: we're not merging any API-changing PRs until after the 2.0 final release on Monday. |
Heads up, this PR picked up a few conflicts from the linting refactor in #1114 |
2fdd280
to
cc050b6
Compare
The linting fails but this is unrelated to this PR, some class have signature that change between the sub and superclass, in particular
|
There is also am async method in a subclass that is not async in superclass, and comparison between list and strings that is always false. |
dd7c80b
to
bfdd1d1
Compare
6d9c208
to
a66e8df
Compare
This also add some typing here and there, and extend one of the console warning to log an exception when there is an error. My main concern is that get_kernel_env need to become async. Co-authored-by: Kevin Bates <[email protected]>
0751241
to
6c7a897
Compare
Rebased on master, all the typing error seem unrelated. Is there anything else I can do to help getting that in ? |
@@ -196,12 +199,16 @@ async def _remove_kernel_when_ready(self, kernel_id, kernel_awaitable): | |||
self._kernel_connections.pop(kernel_id, None) | |||
self._kernel_ports.pop(kernel_id, None) | |||
|
|||
async def _async_start_kernel(self, kernel_id=None, path=None, **kwargs): | |||
# TODO DEC 2022: Revise the type-ignore once the signatures have been changed upstream |
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.
Still todo?
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.
The PR have been merged, but we likely need it to be released, and we may want o wait a bit to keep compat with older versions, and once we pin to a newer jupyter_client, we can force this one to be positional only as well.
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.
Okay, let's move ahead, thanks!
thanks !
…On Thu, Jan 12, 2023 at 13:36 Steven Silvester ***@***.***> wrote:
Merged #1100 <#1100>
into main.
—
Reply to this email directly, view it on GitHub
<#1100 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACR5T3XMMXAZHCKVHSSFG3WR73E3ANCNFSM6AAAAAASNTP32Y>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Following jupyter-server/jupyter_server#1100, this expose the value of JUPYTER_SESSION_NAME environment variable as `__file__`. In _most_ cases, this should reflect the notebook file that correspond to current kernel. It is not set when the env variable is not set. And it represent the name of file at the time the session was created, it will not reflect renaming of the file. We could support renaming, but that would require the frontend to send the name of the current file; this would be helpful when we have multiple frontends/documents connected to the same kernel, but this would be out of scope for this PR and a longer discussion to have.
This also add some typing here and there, and extend one of the console warning to log an exception when there is an error.
My main concern is that get_kernel_env need to become async.