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

Add Session workflows documentation #808

Merged
merged 6 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
92 changes: 92 additions & 0 deletions docs/source/developers/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,95 @@ Jupyter Server contains the following components:
- **Kernel Spec Manager** parses files with JSON specification for a Kernels,
and provides a list of available Kernel configurations. To learn about
Kernel Spec, check `the Jupyter Client guide <https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-specs>`_.

Create Session Workflow
-----------------------

The create Session workflow can be seen in figure below:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The create Session workflow can be seen in figure below:
The create Session workflow can be seen in the figure below:


.. image:: ../images/session-create.drawio.png
:alt: Create Session Workflow
:width: 90%
:align: center

When a user starts a new Kernel, the following steps process:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When a user starts a new Kernel, the following steps process:
When a user starts a new kernel, the following steps occur:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "Kernel" should be "kernel" except when it's a proper noun (e.g., Mapping Kernel Manager, Kernel Spec Manager, etc.). I believe this was also true in the general architecture section as well. Perhaps a sweep can be made for such instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I will change it to "kernel".


#. The Notebook client sends |create_session|_ request to Jupyter Server. This
request has all necessary data, such as Notebook name, type, path, and Kernel
name.

#. **Session Manager** asks **Contents Manager** for the Kernel file system path
based on the input data.

#. **Session Manager** sends Kernel path to **Mapping Kernel Manager**.

#. **Mapping Kernel Manager** starts the Kernel create process by using
**Multi Kernel Manager** and **Kernel Manager**. You can learn more about
**Multi Kernel Manager** in
`the Jupyter Client APIs <https://jupyter-client.readthedocs.io/en/latest/api/manager.html#multikernelmanager-controlling-multiple-kernels>`_.

#. **Kernel Manager** uses provisioner layer to launch a new Kernel.

#. **Kernel Provisioner** is responsible for launching Kernels based on the
Kernel specification. If Kernel specification doesn't define provisioner,
it uses `Local Provisioner <https://jupyter-client.readthedocs.io/en/latest/api/provisioners.html#jupyter_client.provisioning.local_provisioner.LocalProvisioner>`_
to launch the Kernel. You can use
`Kernel Provisioner Base <https://jupyter-client.readthedocs.io/en/latest/api/provisioners.html#jupyter_client.provisioning.provisioner_base.KernelProvisionerBase>`_
and
`Kernel Provisioner Factory <https://jupyter-client.readthedocs.io/en/latest/api/provisioners.html#jupyter_client.provisioning.factory.KernelProvisionerFactory>`_
to create custom provisioners.

#. **Kernel Spec Manager** gets the Kernel specification from the JSON file.
The specification is located in ``kernel.json`` file.

#. Once **Kernel Provisioner** launches the Kernel,
**Kernel Manager** generates the new Kernel ID for **Session Manager**.

#. **Session Manager** saves the new Session data to the SQLite3 DataBase
(Session ID, Notebook path, Notebook name, Notebook type, and Kernel ID).

#. Notebook client receives the created Session data.

.. _create_session: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter_server/master/jupyter_server/services/api/api.yaml#/sessions/post_api_sessions

.. |create_session| replace:: the *POST /api/sessions*

Delete Session Workflow
-----------------------

The delete Session workflow can be seen in figure below:

.. image:: ../images/session-delete.drawio.png
:alt: Delete Session Workflow
:width: 80%
:align: center

When a user stops a Kernel, the following steps process:

#. The Notebook client sends |delete_session|_ request to Jupyter Server. This
request has the Session ID that Kernel is currently using.

#. **Session Manager** gets the Session data from the SQLite3 DataBase and sends
the Kernel ID to **Mapping Kernel Manager**.

#. **Mapping Kernel Manager** starts the Kernel shutdown process by using
**Multi Kernel Manager** and **Kernel Manager**.

#. **Kernel Manager** receives interrupt mode from **Kernel Spec Manager**.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#. **Kernel Manager** receives interrupt mode from **Kernel Spec Manager**.
#. **Kernel Manager** determines the mode of interrupt from the **Kernel Spec Manager**.

**Kernel Manager** supports ``Signal`` and ``Message`` interrupt modes.
By default, the ``Signal`` interrupt mode is being used.

- When interrupt mode is ``Signal``, **Kernel Provisioner** kills the Kernel
with ``SIGINT`` operating system signal.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- When interrupt mode is ``Signal``, **Kernel Provisioner** kills the Kernel
with ``SIGINT`` operating system signal.
- When the interrupt mode is ``Signal``, the **Kernel Provisioner** interrupts the kernel
with the ``SIGINT`` operating system signal (although other provisioner implementations may use a different approach).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diagram for the signal-based interrupt should probably replace Kill with Interrupt as well.


- When interrupt mode is ``Message``, **Session** sends
the ``interrupt_request`` message on the control channel. Check the
`messaging in Jupyter guide <https://jupyter-client.readthedocs.io/en/latest/messaging.html#msging-interrupt>`_
to know more about it.

#. When Kernel is shutdown, **Session Manager** deletes the Session data from
the SQLite3 DataBase and responses 204 Status Code to the Notebook client.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the kernel's shutdown be detailed similar to its interrupt? I know that can be a lot and we might be trying to limit text. Perhaps we could do something like...

When the kernel is shutdown, ...

and point to the code (or documentation produced from the code)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevin-bates I think that makes sense. I added steps after kernel interrupt.
Please let me know, what do you think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the SQLite3 DataBase and responses 204 Status Code to the Notebook client.
the SQLite3 database and responses 204 status code to the Notebook client.


.. _delete_session: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter_server/master/jupyter_server/services/api/api.yaml#/sessions/delete_api_sessions__session_

.. |delete_session| replace:: the *DELETE /api/sessions/{session_id}*
Binary file added docs/source/images/session-create.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/session-delete.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.