Skip to content

Commit

Permalink
Add IpylabModel and Connections, plugins, pre-commit, ruff and other …
Browse files Browse the repository at this point in the history
…enhancements.
  • Loading branch information
Alan Fleming committed Nov 1, 2024
1 parent 910ce84 commit 95c22d9
Show file tree
Hide file tree
Showing 67 changed files with 10,869 additions and 3,789 deletions.
1 change: 0 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ project_short_description: Control JupyterLab from Python notebooks
python_name: ipylab
repository: https://github.com/jtpio/ipylab
test: false

35 changes: 17 additions & 18 deletions .github/workflows/binder-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@ on:
types: [opened]

permissions:
pull-requests:
write
pull-requests: write

jobs:
binder:
runs-on: ubuntu-latest
steps:
- name: comment on PR with Binder link
uses: actions/github-script@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO;
var PR_HEAD_REF = process.env.PR_HEAD_REF;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab) :point_left: Try it on Binder (branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_)`
})
env:
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}
- name: comment on PR with Binder link
uses: actions/github-script@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO;
var PR_HEAD_REF = process.env.PR_HEAD_REF;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab) :point_left: Try it on Binder (branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_)`
})
env:
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}
97 changes: 46 additions & 51 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,71 @@ name: Build

on:
push:
branches: main
branches: ['main']
pull_request:
branches: '*'
branches:
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

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

- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.2.0,<5"
- name: Build the extension
run: |
set -eux
pip install .[dev]
- name: Build the extension
run: |
set -eux
jlpm
python -m pip install .[test]
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "ipylab.*OK"
python -m jupyterlab.browser_check
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "ipylab.*OK"
python -m jupyterlab.browser_check
- name: Package the extension
run: |
set -eux
- name: Package the extension
run: |
set -eux
hatch build
pip uninstall -y "ipylab" jupyterlab
pip install build
python -m build
pip uninstall -y "ipylab" jupyterlab
- name: Upload extension packages
uses: actions/upload-artifact@v4
with:
name: extension-artifacts
path: dist/ipylab*
if-no-files-found: error
- name: Upload extension packages
uses: actions/upload-artifact@v4
with:
name: extension-artifacts
path: dist/ipylab*
if-no-files-found: error

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

steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
architecture: 'x64'
- uses: actions/download-artifact@v4
with:
name: extension-artifacts
- name: Install and Test
run: |
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.0,<5" ipylab*.whl
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "ipylab.*OK"
python -m jupyterlab.browser_check --no-browser-test
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: 'x64'
- uses: actions/download-artifact@v4
with:
name: extension-artifacts
- name: Install and Test
run: |
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 ipylab*.whl
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "ipylab.*OK"
python -m jupyterlab.browser_check --no-browser-test
check_links:
name: Check Links
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/lint.yml

This file was deleted.

14 changes: 8 additions & 6 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Packaging

on:
push:
branches: [ main ]
branches:
- main
pull_request:
branches: '*'
branches:
- '*'

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
Expand All @@ -23,10 +25,10 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install dependencies
run: |
python -m pip install "jupyterlab>=4,<5" build
python -m pip install "jupyterlab>=4,<5" hatch
- name: Build pypi distributions
run: |
python -m build
hatch build
- name: Build npm distributions
run: |
npm pack
Expand All @@ -48,9 +50,9 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python: ['3.8', '3.12']
python: ['3.10', '3.12']
include:
- python: '3.8'
- python: '3.10'
dist: 'ipylab*.tar.gz'
- python: '3.12'
dist: 'ipylab*.whl'
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Pre-Commit Check
on:
push:
branches: ['main']
pull_request:
branches:
- '*'
jobs:
pre_commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/pre-commit@v1
58 changes: 58 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
ci:
autoupdate_schedule: monthly
skip:
- prettier
default_language_version:
node: system
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-ast
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- id: forbid-new-submodules
- id: end-of-file-fixer
exclude: galata/.*-snapshots
- id: requirements-txt-fixer
- id: check-builtin-literals
- repo: https://gitlab.com/bmares/check-json5
rev: 'v1.0.0'
hooks:
- id: check-json5
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
hooks:
- id: check-github-workflows
- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
hooks:
- id: ruff
types_or: [python, jupyter]
args: ['--fix']
- id: ruff-format
types_or: [python, jupyter]
- repo: https://github.com/codespell-project/codespell
rev: 'v2.3.0'
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/kynan/nbstripout
rev: '0.7.1'
hooks:
- id: nbstripout
67 changes: 67 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
// To debug jupyterlab running in a venv or conda env:
// - set up Python env in your workspace as per https://code.visualstudio.com/docs/python/environments
// - add an "envFile" prop to each backend config pointing to .vscode/debug.env
// - configure the .vscode/debug.env file as needed
// https://github.com/jupyterlab/vscode-config-template/tree/main
// https://github.com/jupyterlab/vscode-config-template/issues/1
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File all-code",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Python Debugger: Current File: just my code",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Ipylab",
"type": "debugpy",
"request": "launch",
"args": [
"--notebook-dir=examples",
"--no-browser",
"--ServerApp.token=''",
"--port=9999"
],
"cwd": "${workspaceFolder}",
"justMyCode": false,
"module": "ipylab",
"presentation": {
"hidden": false
}
},
{
"name": "IPylab frontend with Firefox",
"type": "firefox",
"request": "launch",
"reAttach": true,
"url": "http://localhost:9999",
"webRoot": "${workspaceFolder}",
"pathMappings": [
{
"url": "webpack://ipylab/src",
"path": "${workspaceFolder}/src"
}
],
"presentation": {
"hidden": false
}
}
],
"compounds": [
{
"name": "Debug IPylab with firefox",
"configurations": ["Ipylab", "IPylab frontend with Firefox"]
}
]
}
Loading

0 comments on commit 95c22d9

Please sign in to comment.