Skip to content
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

Fix CI Failures #7

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/source/developers/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ Here is basic example:
"""
await asyncio.sleep(.1)

.. note:: The server startup banner (displaying server info and access URLs) is printed before starting asynchronous tasks, so those tasks might still be running even after the banner appears.

.. WARNING: This note is also present in the "Starting asynchronous tasks from an ExtensionApp" section.
If you update it here, please update it there as well.

Making an extension discoverable
--------------------------------
Expand Down Expand Up @@ -386,6 +390,11 @@ Here is a basic (pseudo) code example:
async def stop_extension(self):
self.my_background_task.cancel()

.. note:: The server startup banner (displaying server info and access URLs) is printed before starting asynchronous tasks, so those tasks might still be running even after the banner appears.

.. WARNING: This note is also present in the "Starting asynchronous tasks from an extension" section.
If you update it here, please update it there as well.


Distributing a server extension
===============================
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"
name = "jupyter-server-example"
description = "Jupyter Server Example"
readme = "README.md"
license = ""
license = "BSD-3-Clause"
requires-python = ">=3.8"
dependencies = [
"jinja2",
Expand Down
116 changes: 58 additions & 58 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3061,6 +3061,24 @@ def start_app(self) -> None:
)
self.exit(1)

info = self.log.info
for line in self.running_server_info(kernel_count=False).split("\n"):
info(line)
info(
_i18n(
"Use Control-C to stop this server and shut down all kernels (twice to skip confirmation)."
)
)
if "dev" in __version__:
info(
_i18n(
"Welcome to Project Jupyter! Explore the various tools available"
" and their corresponding documentation. If you are interested"
" in contributing to the platform, please visit the community"
" resources section at https://jupyter.org/community.html."
)
)

self.write_server_info_file()

if not self.no_browser_open_file:
Expand All @@ -3070,6 +3088,46 @@ def start_app(self) -> None:
if self.open_browser and not self.sock:
self.launch_browser()

if self.identity_provider.token and self.identity_provider.token_generated:
# log full URL with generated token, so there's a copy/pasteable link
# with auth info.
if self.sock:
self.log.critical(
"\n".join(
[
"\n",
"Jupyter Server is listening on %s" % self.display_url,
"",
(
"UNIX sockets are not browser-connectable, but you can tunnel to "
f"the instance via e.g.`ssh -L 8888:{self.sock} -N user@this_host` and then "
f"open e.g. {self.connection_url} in a browser."
),
]
)
)
else:
if self.no_browser_open_file:
message = [
"\n",
_i18n("To access the server, copy and paste one of these URLs:"),
" %s" % self.display_url,
]
else:
message = [
"\n",
_i18n(
"To access the server, open this file in a browser:",
),
" %s" % urljoin("file:", pathname2url(self.browser_open_file)),
_i18n(
"Or copy and paste one of these URLs:",
),
" %s" % self.display_url,
]

self.log.critical("\n".join(message))

async def _cleanup(self) -> None:
"""General cleanup of files, extensions and kernels created
by this instance ServerApp.
Expand Down Expand Up @@ -3127,64 +3185,6 @@ async def _post_start(self):
except Exception as err:
self.log.error(err)

info = self.log.info
for line in self.running_server_info(kernel_count=False).split("\n"):
info(line)
info(
_i18n(
"Use Control-C to stop this server and shut down all kernels (twice to skip confirmation)."
)
)
if "dev" in __version__:
info(
_i18n(
"Welcome to Project Jupyter! Explore the various tools available"
" and their corresponding documentation. If you are interested"
" in contributing to the platform, please visit the community"
" resources section at https://jupyter.org/community.html."
)
)

if self.identity_provider.token and self.identity_provider.token_generated:
# log full URL with generated token, so there's a copy/pasteable link
# with auth info.
if self.sock:
self.log.critical(
"\n".join(
[
"\n",
"Jupyter Server is listening on %s" % self.display_url,
"",
(
"UNIX sockets are not browser-connectable, but you can tunnel to "
f"the instance via e.g.`ssh -L 8888:{self.sock} -N user@this_host` and then "
f"open e.g. {self.connection_url} in a browser."
),
]
)
)
else:
if self.no_browser_open_file:
message = [
"\n",
_i18n("To access the server, copy and paste one of these URLs:"),
" %s" % self.display_url,
]
else:
message = [
"\n",
_i18n(
"To access the server, open this file in a browser:",
),
" %s" % urljoin("file:", pathname2url(self.browser_open_file)),
_i18n(
"Or copy and paste one of these URLs:",
),
" %s" % self.display_url,
]

self.log.critical("\n".join(message))

def start(self) -> None:
"""Start the Jupyter server app, after initialization

Expand Down
Loading