Skip to content

Commit

Permalink
Merge pull request #324 from mwakaba2/async-contents-api
Browse files Browse the repository at this point in the history
Asynchronous Contents API
  • Loading branch information
Zsailer committed Dec 10, 2020
2 parents 28f784b + 7d863f3 commit 6fef2a8
Show file tree
Hide file tree
Showing 21 changed files with 1,658 additions and 216 deletions.
31 changes: 26 additions & 5 deletions docs/source/developers/contents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,19 @@ methods:
ContentsManager.is_hidden

You may be required to specify a Checkpoints object, as the default one,
``FileCheckpoints``, could be incompatible with your custom
``FileCheckpoints``, could be incompatible with your custom
ContentsManager.

Customizing Checkpoints
-----------------------
.. currentmodule:: jupyter_server.services.contents.checkpoints

Customized Checkpoint definitions allows behavior to be
Customized Checkpoint definitions allows behavior to be
altered and extended.

The ``Checkpoints`` and ``GenericCheckpointsMixin`` classes
(from :mod:`jupyter_server.services.contents.checkpoints`)
have reusable code and are intended to be used together,
have reusable code and are intended to be used together,
but require the following methods to be implemented.

.. autosummary::
Expand All @@ -220,7 +220,7 @@ No-op example
~~~~~~~~~~~~~

Here is an example of a no-op checkpoints object - note the mixin
comes first. The docstrings indicate what each method should do or
comes first. The docstrings indicate what each method should do or
return for a more complete implementation.

.. code-block:: python
Expand All @@ -238,7 +238,7 @@ return for a more complete implementation.
def delete_checkpoint(self, checkpoint_id, path):
"""deletes a checkpoint for a file"""
def list_checkpoints(self, path):
"""returns a list of checkpoint models for a given file,
"""returns a list of checkpoint models for a given file,
default just does one per file
"""
return []
Expand Down Expand Up @@ -267,3 +267,24 @@ ContentsManager.
.. _NBFormat: https://nbformat.readthedocs.io/en/latest/index.html
.. _PGContents: https://github.com/quantopian/pgcontents
.. _PostgreSQL: https://www.postgresql.org/

Asynchronous Support
--------------------

An asynchronous version of the Contents API is available to run slow IO processes concurrently.

- :class:`~manager.AsyncContentsManager`
- :class:`~filemanager.AsyncFileContentsManager`
- :class:`~largefilemanager.AsyncLargeFileManager`
- :class:`~checkpoints.AsyncCheckpoints`
- :class:`~checkpoints.AsyncGenericCheckpointsMixin`

.. note::

.. _contentfree:

In most cases, the non-asynchronous Contents API is performant for local filesystems.
However, if the Jupyter Notebook web application is interacting with a high-latent virtual filesystem, you may see performance gains by using the asynchronous version.
For example, if you're experiencing terminal lag in the web application due to the slow and blocking file operations, the asynchronous version can reduce the lag.
Before opting in, comparing both non-async and async options' performances is recommended.

Loading

0 comments on commit 6fef2a8

Please sign in to comment.