Skip to content

Commit

Permalink
Merge pull request #7 from Darshan808/fix-ci
Browse files Browse the repository at this point in the history
Fix CI Failures
  • Loading branch information
Zsailer authored Feb 13, 2025
2 parents 1abbce9 + e966a3c commit c076f60
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 59 deletions.
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

0 comments on commit c076f60

Please sign in to comment.