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 13, 2023
1 parent ed0ec0d commit ab902aa
Show file tree
Hide file tree
Showing 26 changed files with 5,753 additions and 2,639 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

39 changes: 0 additions & 39 deletions .eslintrc.js

This file was deleted.

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
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# jupyterlab-notify


[![PyPI version][pypi-image]][pypi-url] [![PyPI DM][pypi-dm-image]][pypi-url]
[![Github Actions Status][github-status-image]][github-status-url] [![Binder][binder-image]][binder-url]

Expand All @@ -19,6 +18,7 @@ This is inspired by the notebook version [here](https://github.com/ShopRunner/ju
```

### Notify completion of single cell:

```python
%%notify
import time
Expand All @@ -36,18 +36,21 @@ time.sleep(1)
In case this assumption does not hold true for you, please open an issue with relevant details.

### Failure scenarios

```python
%%notify -f 'Long-running cell in <foo> notebook failed'
raise ValueError
```

### Threshold-based notifications (unit in seconds)

```python
%notify_all --threshold 1
time.sleep(1)
```

Once enabled, `notify_all` will raise a notification for cells that either exceed the given threshold or raise exception. This ability can also be used to check if/when all cells in a notebook completes execution. For instance,

```python
# In first cell
%notify_all -t 86400 -f 'Notebook execution failed'
Expand All @@ -58,12 +61,14 @@ Once enabled, `notify_all` will raise a notification for cells that either excee
```

### Disable notifications

```python
%notify_all --disable
time.sleep(1)
```

### Learn more

```python
%%notify?
```
Expand All @@ -75,13 +80,14 @@ time.sleep(1)
## Troubleshoot

If you notice that the desktop notifications are not showing up, check the below:

1. Make sure JupyterLab is running in a secure context (i.e. either using HTTPS or localhost)
2. If you've previously denied notification permissions for the site, update the browser settings accordingly. In Chrome, you can do so by navigating to `Setttings -> Privacy and security -> Site Settings -> Notifications` and updating the permissions against your JupyterLab URL.
3. Verify that notifications work for your browser. You may need to configure an OS setting first. You can test on [this site](https://web-push-book.gauntface.com/demos/notification-examples/).

## Requirements

* JupyterLab >= 3.0
- JupyterLab >= 4.0

## Install

Expand Down Expand Up @@ -175,7 +181,6 @@ twine upload dist/*
pip uninstall jupyterlab_notify
```


## History

This plugin was contributed back to the community by the [D. E. Shaw group](https://www.deshaw.com/).
Expand Down
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"
}
Loading

0 comments on commit ab902aa

Please sign in to comment.