Skip to content

Commit

Permalink
Upgrade to jupyterlab 4
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed May 10, 2023
1 parent ed0ec0d commit 1a2dd67
Show file tree
Hide file tree
Showing 20 changed files with 5,657 additions and 2,578 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/binder-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Binder Badge
on:
pull_request_target:
types: [opened]

jobs:
binder:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: jupyterlab/maintainer-tools/.github/actions/binder-link@v1
with:
github_token: ${{ secrets.github_token }}
91 changes: 77 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,95 @@ name: Build

on:
push:
branches: master
branches: main
pull_request:
branches: '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install node
uses: actions/setup-node@v1
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0b0,<5"

- name: Lint the extension
run: |
set -eux
jlpm
jlpm run lint:check
- name: Build the extension
run: |
set -eux
python -m pip install .[test]
jupyter server extension list
jupyter server extension list 2>&1 | grep -ie "jupyterlab_notify.*OK"
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab-notify.*OK"
python -m jupyterlab.browser_check
- name: Package the extension
run: |
set -eux
pip install build
python -m build
pip uninstall -y "jupyterlab_notify" jupyterlab
- name: Upload extension packages
uses: actions/upload-artifact@v3
with:
node-version: '14.x'
name: extension-artifacts
path: dist/jupyterlab_notify*
if-no-files-found: error

test_isolated:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.9'
architecture: 'x64'
- name: Install dependencies
run: python -m pip install jupyterlab
- name: Build the extension
- uses: actions/download-artifact@v3
with:
name: extension-artifacts
- name: Install and Test
run: |
jlpm
jlpm run eslint:check
python -m pip install .
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab>=4.0.0b0,<5" jupyterlab_notify*.whl
jupyter server extension list
jupyter server extension list 2>&1 | grep -ie "jupyterlab_notify.*OK"
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab-notify.*OK"
python -m jupyterlab.browser_check
python -m jupyterlab.browser_check --no-browser-test
check_links:
name: Check Links
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
.vscode
_temp_extension

*.bundle.*
lib/
node_modules/
*.log
.eslintcache
.stylelintcache
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
jupyterlab_notify/labextension
# Version file is handled by hatchling
jupyterlab_notify/_version.py

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python
Expand Down Expand Up @@ -59,6 +61,7 @@ htmlcov/
.coverage.*
.cache
nosetests.xml
coverage/
coverage.xml
*.cover
.hypothesis/
Expand Down Expand Up @@ -113,3 +116,6 @@ dmypy.json

# OSX files
.DS_Store

# Yarn cache
.yarn/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
**/node_modules
**/lib
**/package.json
!/package.json
jupyterlab_notify
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enableImmutableInstalls: false

nodeLinker: node-modules
17 changes: 9 additions & 8 deletions binder/environment.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# a mybinder.org-ready environment for demoing jupyterlab_execute_time
# a mybinder.org-ready environment for demoing jupyterlab_notify
# this environment may also be used locally on Linux/MacOS/Windows, e.g.
#
# conda env update --file binder/environment.yml
# conda activate jupyterlab_execute_time-demo
# conda activate jupyterlab-notify-demo
#
name: jupyterlab_notify-demo
name: jupyterlab-notify-demo

channels:
- conda-forge

dependencies:
# runtime dependencies
- python >=3.8,<4.0.0a0
- jupyterlab >=3.0.16,<4.0.0a0
- python >=3.10,<3.11.0a0
- jupyterlab >=4.0.0b0,<5
# labextension build dependencies
- nodejs >=14,<15
- wheel
- nodejs >=18,<19
- pip
- yarn
- wheel
# additional packages for demos
# - ipywidgets
19 changes: 13 additions & 6 deletions binder/postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,37 @@
"""
import subprocess
import sys
from os.path import expanduser
from pathlib import Path


ROOT = Path.cwd()


def _(*args, **kwargs):
"""Run a command, echoing the args
""" Run a command, echoing the args
fails hard if something goes wrong
fails hard if something goes wrong
"""
print("\n\t", " ".join(args), "\n")
return_code = subprocess.call(args, **kwargs)
if return_code != 0:
print("\nERROR", return_code, " ".join(args))
sys.exit(return_code)


# verify the environment is self-consistent before even starting
_(sys.executable, "-m", "pip", "check")

# install the labextension in develop mode
# install the labextension
_(sys.executable, "-m", "pip", "install", "-e", ".")
_(sys.executable, "-m", "jupyter", "labextension", "develop", "--overwrite", ".")
_(
sys.executable,
"-m",
"jupyter",
"server",
"extension",
"enable",
"jupyterlab_notify",
)

# verify the environment the extension didn't break anything
_(sys.executable, "-m", "pip", "check")
Expand All @@ -45,5 +51,6 @@ _("jupyter", "server", "extension", "list")
# initially list installed extensions to determine if there are any surprises
_("jupyter", "labextension", "list")


print("JupyterLab with jupyterlab_notify is ready to run with:\n")
print("\tjupyter lab\n")
8 changes: 4 additions & 4 deletions install.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packageManager": "python",
"packageName": "jupyterlab_notify",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_notify"
}
"packageManager": "python",
"packageName": "jupyterlab_notify",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_notify"
}
7 changes: 7 additions & 0 deletions jupyter-config/nb-config/jupyterlab_notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"NotebookApp": {
"nbserver_extensions": {
"jupyterlab_notify": true
}
}
}
7 changes: 7 additions & 0 deletions jupyter-config/server-config/jupyterlab_notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"jupyterlab_notify": true
}
}
}
17 changes: 9 additions & 8 deletions jupyterlab_notify/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import json
from pathlib import Path
from .magics import NotifyCellCompletionMagics
from ._version import __version__

HERE = Path(__file__).parent.resolve()

with (HERE / "labextension" / "package.json").open() as fid:
data = json.load(fid)
def _jupyter_labextension_paths():
return [{
"src": "labextension",
"dest": "jupyterlab-notify"
}]


def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": data["name"]}]
def _jupyter_server_extension_points():
return [{
"module": "jupyterlab_notify"
}]


def _load_jupyter_server_extension(server_app):
# Nothing to do for now
pass


Expand Down
24 changes: 4 additions & 20 deletions jupyterlab_notify/_version.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
import json
from pathlib import Path

__all__ = ["__version__"]


def _fetchVersion():
HERE = Path(__file__).parent.resolve()

for settings in HERE.rglob("package.json"):
try:
with settings.open() as f:
return json.load(f)["version"]
except FileNotFoundError:
pass

raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}")


__version__ = _fetchVersion()
# This file is auto-generated by Hatchling. As such, do not:
# - modify
# - track in version control e.g. be sure to add to .gitignore
__version__ = VERSION = '1.0.1'
Loading

0 comments on commit 1a2dd67

Please sign in to comment.