Skip to content

Commit

Permalink
Support path links (JupyterLab 4.1+) and fix CI (#20)
Browse files Browse the repository at this point in the history
* Support navigation from traceback by using `renderError`
* Fix failing tests/local installation with hatch
  • Loading branch information
krassowski authored Apr 1, 2024
1 parent b6cd79c commit 9dc41c6
Show file tree
Hide file tree
Showing 13 changed files with 1,449 additions and 1,141 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

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

- name: Lint the extension
run: |
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Build the extension
run: |
set -eux
python -m pip install .[test]
python -m pip install .
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab-skip-traceback.*OK"
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules
**/lib
**/package.json
!/package.json
jupyterlab-skip-traceback
jupyterlab_skip_traceback
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [5.1.0](https://github.com/deshaw/jupyterlab-skip-traceback/compare/v5.0.0...v5.1.0) (20240331)

### Added

- Support for clicking on paths in tracebacks (requires >=jupyterlab@4.1) #20

## [5.0.0](https://github.com/deshaw/jupyterlab-skip-traceback/compare/v4.0.4...v5.0.0) (20220519)

### Changed
Expand Down
24 changes: 0 additions & 24 deletions MANIFEST.in

This file was deleted.

13 changes: 0 additions & 13 deletions jupyterlab-skip-traceback/__init__.py

This file was deleted.

4 changes: 0 additions & 4 deletions jupyterlab-skip-traceback/_version.py

This file was deleted.

13 changes: 13 additions & 0 deletions jupyterlab_skip_traceback/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
try:
from ._version import __version__
except ImportError:
# Fallback when using the package in dev mode without installing
# in editable mode with pip. It is highly recommended to install
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
import warnings
warnings.warn("Importing 'jupyterlab_skip_traceback' outside a proper installation.")
__version__ = "dev"


def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": "jupyterlab_skip_traceback"}]
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jupyterlab-skip-traceback",
"version": "5.0.0",
"version": "5.1.0",
"description": "A JupyterLab extension for rendering Errors with a copy/paste button and expand/collapse",
"license": "BSD-3-Clause",
"author": {
Expand Down Expand Up @@ -31,7 +31,7 @@
"jupyterlab": {
"extension": true,
"schemaDir": "schema",
"outputDir": "jupyterlab-skip-traceback/labextension"
"outputDir": "jupyterlab_skip_traceback/labextension"
},
"scripts": {
"build": "jlpm build:lib && jlpm build:labextension:dev",
Expand All @@ -42,7 +42,7 @@
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
"clean": "jlpm clean:lib",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"clean:labextension": "rimraf jupyterlab-skip-traceback/labextension jupyterlab-skip-traceback/_version.py",
"clean:labextension": "rimraf jupyterlab_skip_traceback/labextension jupyterlab_skip_traceback/_version.py",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"eslint": "jlpm eslint:check --fix",
Expand All @@ -66,13 +66,13 @@
"watch:src": "tsc -w --sourceMap"
},
"dependencies": {
"@jupyterlab/application": "^4.0.0",
"@jupyterlab/rendermime": "^4.0.0",
"@jupyterlab/settingregistry": "^4.0.0",
"@lumino/widgets": "^2.1.1"
"@jupyterlab/application": "^4.1.0",
"@jupyterlab/rendermime": "^4.1.0",
"@jupyterlab/settingregistry": "^4.1.0",
"@lumino/widgets": "^2.3.1"
},
"devDependencies": {
"@jupyterlab/builder": "^4.0.0",
"@jupyterlab/builder": "^4.1.0",
"@types/json-schema": "^7.0.11",
"@types/react": "^18.0.26",
"@typescript-eslint/eslint-plugin": "^5.55.0",
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version"]
requires = ["hatchling>=1.5.0", "jupyterlab>=4.1.0,<5", "hatch-nodejs-version>=0.3.2"]
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -32,24 +32,24 @@ source = "nodejs"
fields = ["description", "authors", "urls"]

[tool.hatch.build.targets.sdist]
artifacts = ["jupyterlab-skip-traceback/labextension"]
artifacts = ["jupyterlab_skip_traceback/labextension"]
exclude = [".github", "binder"]

[tool.hatch.build.targets.wheel.shared-data]
"jupyterlab-skip-traceback/labextension" = "share/jupyter/labextensions/jupyterlab-skip-traceback"
"jupyterlab_skip_traceback/labextension" = "share/jupyter/labextensions/jupyterlab-skip-traceback"
"install.json" = "share/jupyter/labextensions/jupyterlab-skip-traceback/install.json"

[tool.hatch.build.hooks.version]
path = "jupyterlab-skip-traceback/_version.py"
path = "jupyterlab_skip_traceback/_version.py"

[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.5"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"jupyterlab-skip-traceback/labextension/static/style.js",
"jupyterlab-skip-traceback/labextension/package.json",
"jupyterlab_skip_traceback/labextension/static/style.js",
"jupyterlab_skip_traceback/labextension/package.json",
]
skip-if-exists = ["jupyterlab-skip-traceback/labextension/static/style.js"]
skip-if-exists = ["jupyterlab_skip_traceback/labextension/static/style.js"]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
Expand All @@ -59,14 +59,14 @@ npm = ["jlpm"]
build_cmd = "install:extension"
npm = ["jlpm"]
source_dir = "src"
build_dir = "jupyterlab-skip-traceback/labextension"
build_dir = "jupyterlab_skip_traceback/labextension"

[tool.jupyter-releaser.options]
version_cmd = "hatch version"

[tool.jupyter-releaser.hooks]
before-build-npm = [
"python -m pip install 'jupyterlab>=4.0.0b0,<5'",
"python -m pip install 'jupyterlab>=4.1.0a4,<5'",
"jlpm",
"jlpm build:prod"
]
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__("setuptools").setup()
34 changes: 22 additions & 12 deletions src/SkipTracebackWidget.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../style/index.css';

import { Widget } from '@lumino/widgets';
import { IRenderMime, renderText } from '@jupyterlab/rendermime';
import { IRenderMime, renderText, renderError } from '@jupyterlab/rendermime';
import { Clipboard } from '@jupyterlab/apputils/lib/clipboard';

const BTN_BASE_CLASS = 'minimal jp-Button';
Expand Down Expand Up @@ -39,7 +39,7 @@ export default class SkipTracebackWidget
constructor(options: IRenderMime.IRendererOptions) {
super();
this._mimeType = options.mimeType;
this._sanitizer = options.sanitizer;
this._options = options;
}

private static _defaults = {
Expand Down Expand Up @@ -100,14 +100,24 @@ export default class SkipTracebackWidget
span.appendChild(shortError);

const traceback = document.createElement('pre');
const rt = renderText({
host: traceback,
sanitizer: this._sanitizer,
// It should look like stderr
source:
(model.data['application/vnd.jupyter.stderr'] as string) ||
this._data.traceback.join('\n'),
});
// It should look like stderr
const source = (model.data['application/vnd.jupyter.stderr'] as string) ||
this._data.traceback.join('\n');

let renderedPromise: Promise<void>;
if (typeof renderError !== 'undefined') {
renderedPromise = renderError({
...this._options,
host: traceback,
source
});
} else {
renderedPromise = renderText({
...this._options,
host: traceback,
source
});
}
const tbDiv = document.createElement('div');
tbDiv.className = 'jp-RenderedText';
tbDiv.setAttribute('data-mime-type', 'application/vnd.jupyter.stderr');
Expand All @@ -121,12 +131,12 @@ export default class SkipTracebackWidget
this._toggleTraceback();
}
// Don't finish until we render the text
return rt;
return renderedPromise;
}

private _toggleBtn?: HTMLButtonElement;
private _tracebackNode?: HTMLDivElement;
private _sanitizer: IRenderMime.ISanitizer;
private _options: IRenderMime.IRendererOptions;
private _data?: IError;
private _mimeType: string;
private _shortError?: HTMLPreElement;
Expand Down
Loading

0 comments on commit 9dc41c6

Please sign in to comment.