diff --git a/.github/workflows/step_tests-conda.yml b/.github/workflows/step_tests-conda.yml index 00fb18261..f52afb0f6 100644 --- a/.github/workflows/step_tests-conda.yml +++ b/.github/workflows/step_tests-conda.yml @@ -51,16 +51,22 @@ jobs: - name: Install a Jupyter Kernel run: python -m ipykernel install --name jupytext-ci --user + - name: Test with pytest + run: pytest -n logical --cov --cov-report=xml + - name: Test lab extension run: | + # Uninstall jupyter-fs as it overrides the original browser-test.js to + # check its own functionality (https://github.com/jpmorganchase/jupyter-fs/blob/main/jupyterfs/browser-test.js) + # So uninstall jupyter-fs before running browser check + # + pip uninstall jupyter-fs -y + # Check extension jupyter labextension list jupyter labextension list 2>&1 | grep -ie "jupyterlab-jupytext.*OK" python -m jupyterlab.browser_check - - name: Test with pytest - run: pytest -n logical --cov --cov-report=xml - - name: Upload coverage uses: codecov/codecov-action@v3 with: diff --git a/.github/workflows/step_tests-pip.yml b/.github/workflows/step_tests-pip.yml index f4a0625c1..f3d5ccd9d 100644 --- a/.github/workflows/step_tests-pip.yml +++ b/.github/workflows/step_tests-pip.yml @@ -82,17 +82,23 @@ jobs: # install it sudo apt install ./*.deb + - name: Test with pytest + continue-on-error: ${{ matrix.experimental }} + run: pytest -n logical --cov --cov-report=xml + - name: Test lab extension run: | + # Uninstall jupyter-fs as it overrides the original browser-test.js to + # check its own functionality (https://github.com/jpmorganchase/jupyter-fs/blob/main/jupyterfs/browser-test.js) + # So uninstall jupyter-fs before running browser check + # + pip uninstall jupyter-fs -y + # Check extension jupyter labextension list jupyter labextension list 2>&1 | grep -ie "jupyterlab-jupytext.*OK" python -m jupyterlab.browser_check - - name: Test with pytest - continue-on-error: ${{ matrix.experimental }} - run: pytest -n logical --cov --cov-report=xml - - name: Upload coverage uses: codecov/codecov-action@v3 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 39dec8dfe..d17a87d45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Jupytext ChangeLog **Fixed** - We have fixed a typo when `build_jupytext_contents_manager_class` can't be imported ([#1162](https://github.com/mwouts/jupytext/issues/1162)) +- We use `inspect` to determine whether the current contents manager derives from `AsyncContentsManager` (which is not +supported by Jupytext at the moment). This fixes a compatibility issue with `jupyter-fs==1.0.0` ([#1239](https://github.com/mwouts/jupytext/issues/1239)). Thanks to [Mahendra Paipuri](https://github.com/mahendrapaipuri) for this PR! - Some dependencies of the JupyterLab extensions were updated ([#1243](https://github.com/mwouts/jupytext/issues/1243), [#1245](https://github.com/mwouts/jupytext/issues/1245)) **Added** diff --git a/docs/install.md b/docs/install.md index 761bd08e9..c2ee5fd2e 100644 --- a/docs/install.md +++ b/docs/install.md @@ -32,6 +32,17 @@ If you don't have the notebook icon on text documents after a fresh restart of y jupyter serverextension enable jupytext ``` +When [`jupyter-fs>=1.0.0`](https://github.com/jpmorganchase/jupyter-fs) is being used along with `jupytext`, use `SyncMetaManager` as the contents manager for `jupyter-fs` as `jupytext` do not support async contents manager which is used in default `MetaManager` of `jupyter-fs`. The `jupyter-fs` config must be as follows: + +```json +{ + "ServerApp": { + "contents_manager_class": "jupyterfs.metamanager.SyncMetaManager", + } +} +``` +so that `jupytext` will create its own contents manager derived from `SyncMetaManager`. + ## Jupytext commands in JupyterLab Jupytext comes with a frontend extension for JupyterLab which provides pairing commands (accessible with View / Activate Command Palette, or Ctrl+Shift+C): diff --git a/jupyterlab/jupyterlab_jupytext/__init__.py b/jupyterlab/jupyterlab_jupytext/__init__.py index 2e2b40551..7b0ae4cf2 100644 --- a/jupyterlab/jupyterlab_jupytext/__init__.py +++ b/jupyterlab/jupyterlab_jupytext/__init__.py @@ -1,5 +1,9 @@ """Jupyter server and lab extension entry points""" +import inspect + +import jupyter_server + from jupytext.reraise import reraise try: @@ -20,22 +24,28 @@ def load_jupyter_server_extension(app): # pragma: no cover # The server extension call is too late! # The contents manager was set at NotebookApp.init_configurables - # Let's change the contents manager class + # Get a list of all base classes and check if they contain AsyncContentsManager base_class = app.contents_manager_class - if "async" in base_class.__name__.lower(): - app.log.warning( - "[Jupytext Server Extension] Async contents managers like {} " - "are not supported at the moment " - "(https://github.com/mwouts/jupytext/issues/1020). " - "We will derive a contents manager from LargeFileManager instead.".format( - base_class.__name__ + parent_classes = inspect.getmro(base_class) + for parent_class in parent_classes: + if ( + parent_class + == jupyter_server.services.contents.manager.AsyncContentsManager + ): + app.log.warning( + "[Jupytext Server Extension] Async contents managers like {} " + "are not supported at the moment " + "(https://github.com/mwouts/jupytext/issues/1020). " + "We will derive a contents manager from LargeFileManager instead.".format( + parent_class.__name__ + ) + ) + from jupyter_server.services.contents.largefilemanager import ( # noqa + LargeFileManager, ) - ) - from jupyter_server.services.contents.largefilemanager import ( # noqa - LargeFileManager, - ) - base_class = LargeFileManager + base_class = LargeFileManager + break app.log.info( "[Jupytext Server Extension] Deriving a JupytextContentsManager " diff --git a/pyproject.toml b/pyproject.toml index fa624cff4..4d65500fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,8 +75,7 @@ test-external = [ "gitpython", "pre-commit", # Interaction with other contents managers - # jupyter-fs==0.4.0 is async, which is not supported by Jupytext ATM - "jupyter-fs<0.4.0" + "jupyter-fs>=1.0" ] # Coverage requirements test-cov = [ diff --git a/tests/external/jupyter_fs/test_jupyter_fs.py b/tests/external/jupyter_fs/test_jupyter_fs.py index 0b703e542..789f8e720 100644 --- a/tests/external/jupyter_fs/test_jupyter_fs.py +++ b/tests/external/jupyter_fs/test_jupyter_fs.py @@ -9,11 +9,11 @@ def fs_meta_manager(tmpdir): try: - from jupyterfs.metamanager import MetaManager + from jupyterfs.metamanager import SyncMetaManager except ImportError: pytest.skip("jupyterfs is not available") - cm_class = jupytext.build_jupytext_contents_manager_class(MetaManager) + cm_class = jupytext.build_jupytext_contents_manager_class(SyncMetaManager) logger = logging.getLogger("jupyter-fs") cm = cm_class(parent=None, log=logger) cm.initResource(