Skip to content

Commit

Permalink
Import base contentsmanager from jupyter server (#934)
Browse files Browse the repository at this point in the history
* Import LargeFileManager from jupyter_server by default
* Test Jupytext with "notebook" in pre-release versions
* Test Jupytext with Python 3.10

Co-authored-by: Jeremy Tuloup <[email protected]>
  • Loading branch information
mwouts and jtpio authored Mar 20, 2022
1 parent 8cfa66b commit 88a5a39
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }}
strategy:
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
python-version: [ 3.6, 3.7, 3.8, 3.9, "3.10"]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -219,6 +219,35 @@ jobs:
- name: Upload coverage
uses: codecov/codecov-action@v1

test-pip-notebook-pre:
needs: skip_duplicate
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }}
strategy:
matrix:
python-version: [ 3.7 ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# All dependencies but markdown-it-py
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Notebook pre-release version #933
pip install --pre -U notebook
- name: Install a Jupyter Kernel
run: python -m ipykernel install --name python_kernel --user
- name: Test with pytest
run: pytest --cov=./ --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v1

build:
name: Build
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
comment:
after_n_builds: 9
after_n_builds: 11

coverage:
status:
Expand Down
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Jupytext ChangeLog
**Fixed**
- We made sure that our tests also work in absence of a Python kernel ([#906](https://github.com/mwouts/jupytext/issues/906))

**Changed**
- The Jupytext contents manager is derived from the `LargeFileManager` imported from `jupyter_server` rathen than `notebook` ([#933](https://github.com/mwouts/jupytext/issues/933))


1.13.7 (2022-02-09)
-------------------
Expand Down
21 changes: 16 additions & 5 deletions jupytext/contentsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,22 @@ def get_config(self, path, use_cache=False):


try:
from notebook.services.contents.largefilemanager import LargeFileManager
# The LargeFileManager is taken by default from jupyter_server if available
from jupyter_server.services.contents.largefilemanager import LargeFileManager

TextFileContentsManager = build_jupytext_contents_manager_class(LargeFileManager)
except ImportError:
# Older versions of notebook do not have the LargeFileManager #217
from notebook.services.contents.filemanager import FileContentsManager

TextFileContentsManager = build_jupytext_contents_manager_class(FileContentsManager)
# If we can't find jupyter_server then we take it from notebook
try:
from notebook.services.contents.largefilemanager import LargeFileManager

TextFileContentsManager = build_jupytext_contents_manager_class(
LargeFileManager
)
except ImportError:
# Older versions of notebook do not have the LargeFileManager #217
from notebook.services.contents.filemanager import FileContentsManager

TextFileContentsManager = build_jupytext_contents_manager_class(
FileContentsManager
)
4 changes: 3 additions & 1 deletion tests/test_pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ def test_no_metadata_when_py_is_pep8(py_file):
if "title" in cell.metadata:
cell.metadata.pop("title") # pragma: no cover
if i == 0 and not cell.source:
assert cell.metadata == {"lines_to_next_cell": 0}, py_file
assert cell.metadata == {
"lines_to_next_cell": 0
}, py_file # pragma: no cover
else:
assert not cell.metadata, (py_file, cell.source)

Expand Down

0 comments on commit 88a5a39

Please sign in to comment.