Skip to content

Commit

Permalink
Compatibility with Notebook7 and jupyterLab4 (#1684)
Browse files Browse the repository at this point in the history
* Update dependencies to jupyterlab>=4, fix menu entries and fix mathjax error

* Includes assignment-list, course-list and formgrader extensions as main panel tab

* Remove required dependency to LabShell

* Make it work with Notebook7 and JupyterLab4

* update dependencies

* Refactore create_assignment_extension to depend on CellModel instead of Cell widget, and to simplify the listeners

* Update the tests according to the updates of JupyterLab

* Reintegrate the cellPrompt in create assignment cell widget

* Activate by default the new created tab in Notebook (assignment list, course list and formgrader)

* add test for extensions in notebook

* Fix docs tests and insert nbextensions test in UI-tests

* Update dependencies to jupyterlab-4.0.0a32 and notebook-7.0.0a10

* Downgrade dependency to Notebook as it breaks installation

* bump to Notebook-7.0.0a10

* update dependencies

* Refactor the extensions for a better managment of the menu and palettecommand in Notebook

* Update to Jlab 4.0.0a34 and Notebook 7.0.0a13

* Open the existing Formgrader tab if already loaded from courses list tab

* fix UI tests

* Removal of python 3.7 support and integration of python 3.11 in tests

* Update actions and node version in tests

* Update to jupyterlab 4.0.0a37 and notebook 7.0.0a17

* Fix before-build-npm

* Includes #1756

* Remove nbextensions and related code

* Update dependencies to lab 4 released and notebook 7b.4

* Add the playwright report as artifact
  • Loading branch information
brichet authored Jul 18, 2023
1 parent ba72a9f commit 1b5ffa9
Show file tree
Hide file tree
Showing 92 changed files with 12,638 additions and 19,066 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
group: [check_release, link_check]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Check Release
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
#
name: Test python-nbextensions-doc
name: Test python-doc

on:
pull_request:
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-22.04]
group: ["docs", "nbextensions", "python"]
group: ["docs", "python"]
python: ["3.8", "3.9", "3.10", "3.11"]
exclude:
- os: windows-latest
Expand All @@ -40,8 +40,6 @@ jobs:
group: docs
- python: "3.10"
group: docs
- python: "3.8"
group: nbextensions
steps:
# This is how you set an environment variable in a GitHub workflow that
# will be available in following steps as if you would used `export
Expand All @@ -52,19 +50,15 @@ jobs:
echo "GROUP=docs" >> $GITHUB_ENV
echo "TIMEOUT_MINUTES=15" >> $GITHUB_ENV
fi
if [ "${{ matrix.group }}" == "nbextensions" ]; then
echo "GROUP=nbextensions" >> $GITHUB_ENV
echo "TIMEOUT_MINUTES=25" >> $GITHUB_ENV
fi
if [ "${{ matrix.group }}" == "python" ]; then
echo "GROUP=python" >> $GITHUB_ENV
echo "TIMEOUT_MINUTES=20" >> $GITHUB_ENV
fi
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '17.x'
node-version: '18.x'
# NOTE: actions/setup-python@v2 can make use of a cache within the GitHub
# Action virtual environment and setup extremely fast. 3.9 isn't
# available in this cache as of November 2020.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
#
name: Test labextensions
name: Test extensions

on:
pull_request:
Expand All @@ -15,7 +15,7 @@ defaults:
shell: bash

jobs:
test_labextensions:
ui-test:
runs-on: ${{ matrix.os }}
timeout-minutes: 40

Expand All @@ -30,18 +30,19 @@ jobs:
matrix:
os: [windows-latest, ubuntu-22.04]
python: ["3.10", "3.11"]
group: ["labextensions", "nbextensions"]
steps:
# This is how you set an environment variable in a GitHub workflow that
# will be available in following steps as if you would used `export
# MY_ENV=my-value`.
- name: Configure environment variables from job flags
run: |
echo "GROUP=labextensions" >> $GITHUB_ENV
- uses: actions/checkout@v2
echo "GROUP=${{ matrix.group }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '17.x'
node-version: '18.x'
# NOTE: actions/setup-python@v2 can make use of a cache within the GitHub
# Action virtual environment and setup extremely fast. 3.9 isn't
# available in this cache as of November 2020.
Expand All @@ -52,18 +53,18 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python tasks.py install --group=labextensions
python tasks.py install --group=${{ matrix.group }}
pip freeze
- name: Install Playwright
run: |
npx playwright install
- name: Run playwright tests
run: |
python tasks.py tests --group=labextensions
python tasks.py tests --group=${{ matrix.group }}
- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v2
with:
name: nbgrader-playwright-tests-os_${{ matrix.os }}-python_${{ matrix.python }}
name: nbgrader-uitests-${{ matrix.group }}-${{ matrix.os }}-python${{ matrix.python }}
path: |
playwright-tests
playwright-report
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var/
# built labextension
tsconfig.tsbuildinfo
nbgrader/labextension/
# Yarn cache
.yarn/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -62,9 +64,6 @@ target/

# Coverage files
.coverage.*
.selenium.screenshot.png
nbgrader/tests/formgrader/selenium.screenshot.png
nbgrader/tests/nbextensions/selenium.screenshot.png

# Autogenerated docs
nbgrader/docs/build
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
15 changes: 6 additions & 9 deletions demos/restart_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,16 @@ install_nbgrader () {

# Install global extensions, and disable them globally. We will re-enable
# specific ones for different user accounts in each demo.
jupyter nbextension install --symlink --sys-prefix --py nbgrader --overwrite
jupyter nbextension disable --sys-prefix --py nbgrader
jupyter labextension develop --overwrite .
jupyter labextension disable --level=sys_prefix nbgrader/assignment-list
jupyter labextension disable --level=sys_prefix nbgrader/formgrader
jupyter labextension disable --level=sys_prefix nbgrader/course-list
jupyter labextension disable --level=sys_prefix nbgrader/create-assignment
jupyter serverextension disable --sys-prefix --py nbgrader
jupyter labextension disable --level=sys_prefix nbgrader:assignment-list
jupyter labextension disable --level=sys_prefix nbgrader:formgrader
jupyter labextension disable --level=sys_prefix nbgrader:course-list
jupyter labextension disable --level=sys_prefix nbgrader:create-assignment
jupyter server extension disable --sys-prefix --py nbgrader

# Everybody gets the validate extension, however.
jupyter nbextension enable --sys-prefix validate_assignment/main --section=notebook
jupyter labextension enable --level=sys_prefix nbgrader/validate_assignment
jupyter serverextension enable --sys-prefix nbgrader.server_extensions.validate_assignment
jupyter server extension enable --sys-prefix nbgrader.server_extensions.validate_assignment

# Reset exchange.
rm -rf "${exchange_root}"
Expand Down
26 changes: 11 additions & 15 deletions demos/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,42 +69,38 @@ enable_create_assignment () {
HOME="/home/${USER}"
local runas="sudo -u ${USER}"

${runas} jupyter nbextension enable --user create_assignment/main
${runas} jupyter labextension disable --level=user nbgrader/create-assignment
${runas} jupyter labextension enable --level=user nbgrader/create-assignment
${runas} jupyter labextension disable --level=user nbgrader:create-assignment
${runas} jupyter labextension enable --level=user nbgrader:create-assignment
}

enable_formgrader () {
USER="${1}"
HOME="/home/${USER}"
local runas="sudo -u ${USER}"

${runas} jupyter nbextension enable --user formgrader/main --section=tree
${runas} jupyter labextension disable --level=user nbgrader/formgrader
${runas} jupyter labextension enable --level=user nbgrader/formgrader
${runas} jupyter serverextension enable --user nbgrader.server_extensions.formgrader
${runas} jupyter labextension disable --level=user nbgrader:formgrader
${runas} jupyter labextension enable --level=user nbgrader:formgrader
${runas} jupyter server extension enable --user nbgrader.server_extensions.formgrader
}

enable_assignment_list () {
USER="${1}"
HOME="/home/${USER}"
local runas="sudo -u ${USER}"

${runas} jupyter nbextension enable --user assignment_list/main --section=tree
${runas} jupyter labextension disable --level=user nbgrader/assignment-list
${runas} jupyter labextension enable --level=user nbgrader/assignment-list
${runas} jupyter serverextension enable --user nbgrader.server_extensions.assignment_list
${runas} jupyter labextension disable --level=user nbgrader:assignment-list
${runas} jupyter labextension enable --level=user nbgrader:assignment-list
${runas} jupyter server extension enable --user nbgrader.server_extensions.assignment_list
}

enable_course_list () {
USER="${1}"
HOME="/home/${USER}"
local runas="sudo -u ${USER}"

${runas} jupyter nbextension enable --user course_list/main --section=tree
${runas} jupyter labextension disable --level=user nbgrader/course-list
${runas} jupyter labextension enable --level=user nbgrader/course-list
${runas} jupyter serverextension enable --user nbgrader.server_extensions.course_list
${runas} jupyter labextension disable --level=user nbgrader:course-list
${runas} jupyter labextension enable --level=user nbgrader:course-list
${runas} jupyter server extension enable --user nbgrader.server_extensions.course_list
}

create_course () {
Expand Down
59 changes: 0 additions & 59 deletions nbgrader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,65 +33,6 @@ def _jupyter_server_extension_points():
"module": "nbgrader"
}]


# Classic notebook extensions
def _jupyter_nbextension_paths():
paths = [
dict(
section="notebook",
src=os.path.join('nbextensions', 'create_assignment'),
dest="create_assignment",
require="create_assignment/main"
),
dict(
section="tree",
src=os.path.join('nbextensions', 'formgrader'),
dest="formgrader",
require="formgrader/main"
),
dict(
section="notebook",
src=os.path.join('nbextensions', 'validate_assignment'),
dest="validate_assignment",
require="validate_assignment/main"
),
]

if sys.platform != 'win32':
paths.append(
dict(
section="tree",
src=os.path.join('nbextensions', 'assignment_list'),
dest="assignment_list",
require="assignment_list/main"
)
)
paths.append(
dict(
section="tree",
src=os.path.join('nbextensions', 'course_list'),
dest="course_list",
require="course_list/main"
)
)

return paths


# Classic notebook server extensions
def _jupyter_server_extension_paths():
paths = [
dict(module="nbgrader.server_extensions.formgrader"),
dict(module="nbgrader.server_extensions.validate_assignment")
]

if sys.platform != 'win32':
paths.append(dict(module="nbgrader.server_extensions.assignment_list"))
paths.append(dict(module="nbgrader.server_extensions.course_list"))

return paths


def _load_jupyter_server_extension(app):
load_assignments(app)
load_courses(app)
Expand Down
12 changes: 6 additions & 6 deletions nbgrader/docs/source/contributor_guide/releasing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ The version number should have been changed in the following files :
- ``pyproject.toml``
- ``package.json``
- ``nbgrader/_version.py``
- ``nbgrader/nbextensions/assignment_list/main.js``
- ``nbgrader/nbextensions/course_list/main.js``
- ``nbgrader/nbextensions/validate_assignment/main.js``
- ``src/assignment_list/index.ts``
- ``src/course_list/index.ts``
- ``src/validate_assignment/index.ts``

Rebuild the documentation
-------------------------
Expand Down Expand Up @@ -173,6 +173,6 @@ As a reminder, the files concerned are :
- ``pyproject.toml``
- ``package.json``
- ``nbgrader/_version.py``
- ``nbgrader/nbextensions/assignment_list/main.js``
- ``nbgrader/nbextensions/course_list/main.js``
- ``nbgrader/nbextensions/validate_assignment/main.js``
- ``src/assignment_list/index.ts``
- ``src/course_list/index.ts``
- ``src/validate_assignment/index.ts``
Loading

0 comments on commit 1b5ffa9

Please sign in to comment.