-
Notifications
You must be signed in to change notification settings - Fork 310
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
Add async start hook to ExtensionApp API #1417
base: main
Are you sure you want to change the base?
Conversation
cc @vidartf and @afshin, since we discussed this a bit on the server call today. I've added documentation and made it possible to write one of these hooks for "classic" server extensions, i.e. extensions that don't inherit from the The function must be named |
Downstream test failures appear to be unrelated. |
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 @Zsailer
I have some questions about this:
- why not using
start_extension
to get an easier to understand APIstart/stop_extension
? - if not renaming to
start_extension
, we should not prefix the class method with_
(akaExtensionApp._start_jupyter_server_extension
) as the convention implies that those have visibility protected and that does not fit the need for them to be public (to be accessed by the extension manager). - I understand why you would add support for the classic extension. But in that case, I feel that we should also allow the
stop_extension
hook as it will surely be needed to clean started resources.
Hey @fcollonval 👋 Thanks for looking at this. First, let me acknowledge the obvious... naming is hard.
I originally used this naming pattern, but in the last Jupyter Server meeting, folks asked if we could make this API available for "simple" server extension, i.e. one's that don't inherit from ExtensionApp. The pattern set for classic extension is to use I'm fine with have
Hm, I understand what you mean, but this is a slightly odd/edge case. The The extension manager is a special case. Yes, technically it's breaking the "public visibility within a class" convention, but it's a special type of "public" here. It must change if the We followed this same logic when renaming the
Sure. I don't think it's strictly necessary for this PR to be reviewed/merged. I'm happy to add it here, but there are many other cases where you need an async start action without leaving lingering resources around that need cleanup. |
This is enabled in the current API, and is used by jupyter-lsp, using the function-based mechanism: def load_jupyter_server_extension(nbapp):
if hasattr(nbapp, "io_loop"):
io_loop = nbapp.io_loop
else:
# handle jupyter_server 1.x
io_loop = ioloop.IOLoop.current()
io_loop.call_later(0, initialize, nbapp, virtual_documents_uri)
async def initialize(nbapp, virtual_documents_uri):
await #... yadda yadda The shortcoming is this spews a lot of output (especially with We added this because people complained about how long a server took to start up in a JupyterHub setting. Blocking the URL print would feel perceptually worse, but in the end would feel better. |
Thanks @Zsailer for your detailed answer. The arguments with the naming make sense. Indeed naming is always a high source of debates 😅 Regarding adding |
Hello, this would be super useful to speed-up startup of jupyter-ai and simplify code in jupyterlab-lsp. What is blocking this PR? @Zsailer if you rebase would the CI pass now? |
b798e25
to
1abbce9
Compare
@krassowski I rebased, but some tests are still failing. The test related to the examples is a simple fix (just add a mock license to the package). The failing downstream test in JupyterLab isn't as clear to me. Otherwise, nothing blocking here once we get the CI green. |
Thanks! I can take a look here tomorrow or Friday and open a PR against your branch if I get it working :) |
Great, thank you @krassowski! If I get some time today/tomorrow, I'll try to fix too. I'd love to see this get merged too :) |
I've looked into this one - it is because the "critical" logs explaining how to open jupyter were moved from jupyter_server/jupyter_server/serverapp.py Lines 3091 to 3129 in e544fa1
This is because JupyterLab downstream checks if any errors were logged between application startup and completion of the test task. We could:
|
@Zsailer unable to join the call today but wanted to check if you have thoughts on the a-c options above? |
I think (c) is the right way to go here. Let's do this in a separate PR that we merge first and rebase here. If you have time before I get to it and want to work on such a PR, feel free to open it and assign me to review. Otherwise, I can open a PR later this week. Thanks @krassowski! |
Fixes #1203 and #1329