Skip to content

Commit

Permalink
Updates kernel-messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Apr 7, 2023
1 parent de9821d commit 9ee44ae
Show file tree
Hide file tree
Showing 34 changed files with 485 additions and 337 deletions.
32 changes: 9 additions & 23 deletions kernel-messaging/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:jsdoc/recommended',
'plugin:prettier/recommended',
'plugin:react/recommended',
'plugin:prettier/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
sourceType: 'module'
},
plugins: ['@typescript-eslint', 'jsdoc'],
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
Expand All @@ -21,9 +19,9 @@ module.exports = {
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true,
},
},
match: true
}
}
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
Expand All @@ -32,22 +30,10 @@ module.exports = {
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false },
{ avoidEscape: true, allowTemplateLiterals: false }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'jsdoc/require-param-type': 'off',
'jsdoc/require-property-type': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/no-types': 'warn',
'prefer-arrow-callback': 'error',
},
settings: {
jsdoc: {
mode: 'typescript',
},
react: {
version: 'detect',
},
},
'prefer-arrow-callback': 'error'
}
};
7 changes: 7 additions & 0 deletions kernel-messaging/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ node_modules/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo

# Integration tests
ui-tests/test-results/
ui-tests/playwright-report/

# Yarn cache
.yarn/
6 changes: 6 additions & 0 deletions kernel-messaging/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
**/node_modules
**/lib
**/package.json
!/package.json
jupyterlab_examples_kernel_messaging
6 changes: 6 additions & 0 deletions kernel-messaging/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "auto"
}
12 changes: 12 additions & 0 deletions kernel-messaging/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-standard",
"stylelint-prettier/recommended"
],
"rules": {
"property-no-vendor-prefix": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null
}
}
3 changes: 3 additions & 0 deletions kernel-messaging/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enableImmutableInstalls: false

nodeLinker: node-modules
5 changes: 5 additions & 0 deletions kernel-messaging/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

<!-- <START NEW CHANGELOG ENTRY> -->

<!-- <END NEW CHANGELOG ENTRY> -->
29 changes: 29 additions & 0 deletions kernel-messaging/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023, Project Jupyter Contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 changes: 0 additions & 22 deletions kernel-messaging/MANIFEST.in

This file was deleted.

30 changes: 18 additions & 12 deletions kernel-messaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ that manages a single kernel session. Here is the code to initialize such sessio
this._sessionContext = new SessionContext({
sessionManager: manager.sessions,
specsManager: manager.kernelspecs,
name: 'Extension Examples',
name: 'Extension Examples'
});
```

<!-- prettier-ignore-start -->
<!-- embedme src/panel.ts#L51-L62 -->
<!-- embedme src/panel.ts#L56-L67 -->

```ts
void this._sessionContext
.initialize()
.then(async (value) => {
.then(async value => {
if (value) {
await sessionContextDialogs.selectKernel(this._sessionContext);
await this._sessionContextDialogs.selectKernel(this._sessionContext);
}
})
.catch((reason) => {
.catch(reason => {
console.error(
`Failed to initialize the session in ExamplePanel.\n${reason}`
);
Expand All @@ -81,7 +81,7 @@ to free the kernel session resources if the panel is closed. The whole adapted
panel class looks like this:

```ts
// src/panel.ts#L31-L85
// src/panel.ts#L31-L91

export class ExamplePanel extends StackedPanel {
constructor(manager: ServiceManager.IManager, translator?: ITranslator) {
Expand All @@ -96,21 +96,26 @@ export class ExamplePanel extends StackedPanel {
this._sessionContext = new SessionContext({
sessionManager: manager.sessions,
specsManager: manager.kernelspecs,
name: 'Extension Examples',
name: 'Extension Examples'
});

this._model = new KernelModel(this._sessionContext);
this._example = new KernelView(this._model);

this.addWidget(this._example);

this._sessionContextDialogs = new SessionContextDialogs({
translator: translator
});

void this._sessionContext
.initialize()
.then(async (value) => {
.then(async value => {
if (value) {
await sessionContextDialogs.selectKernel(this._sessionContext);
await this._sessionContextDialogs.selectKernel(this._sessionContext);
}
})
.catch((reason) => {
.catch(reason => {
console.error(
`Failed to initialize the session in ExamplePanel.\n${reason}`
);
Expand All @@ -134,6 +139,7 @@ export class ExamplePanel extends StackedPanel {
private _model: KernelModel;
private _sessionContext: SessionContext;
private _example: KernelView;
private _sessionContextDialogs: SessionContextDialogs;

private _translator: ITranslator;
private _trans: TranslationBundle;
Expand All @@ -148,7 +154,7 @@ Once a kernel is initialized and ready, code can be executed with the following
// src/model.ts#L46-L48

this.future = this._sessionContext.session?.kernel?.requestExecute({
code,
code
});
```

Expand Down Expand Up @@ -205,7 +211,7 @@ export class KernelModel {
return;
}
this.future = this._sessionContext.session?.kernel?.requestExecute({
code,
code
});
}

Expand Down
56 changes: 48 additions & 8 deletions kernel-messaging/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,62 @@
# Making a new release of jupyterlab_examples_kernel_messaging

The extension can be published to `PyPI` and `npm` using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).
The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).

## Manual release

### Python package

This extension can be distributed as Python packages. All of the Python
packaging instructions are in the `pyproject.toml` file to wrap your extension in a
Python package. Before generating a package, you first need to install some tools:

```bash
pip install build twine hatch
```

Bump the version using `hatch`. By default this will create a tag.
See the docs on [hatch-nodejs-version](https://github.com/agoose77/hatch-nodejs-version#semver) for details.

```bash
hatch version <new-version>
```

To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do:

```bash
python -m build
```

> `python setup.py sdist bdist_wheel` is deprecated and will not work for this package.
Then to upload the package to PyPI, do:

```bash
twine upload dist/*
```

### NPM package

To publish the frontend part of the extension as a NPM package, do:

```bash
npm login
npm publish --access public
```

## Automated releases with the Jupyter Releaser

The extension repository should already be compatible with the Jupyter Releaser.

Check out the [workflow documentation](https://github.com/jupyter-server/jupyter_releaser#typical-workflow) for more information.
Check out the [workflow documentation](https://jupyter-releaser.readthedocs.io/en/latest/get_started/making_release_from_repo.html) for more information.

Here is a summary of the steps to cut a new release:

- Fork the [`jupyter-releaser` repo](https://github.com/jupyter-server/jupyter_releaser)
- Add `ADMIN_GITHUB_TOKEN`, `PYPI_TOKEN` and `NPM_TOKEN` to the Github Secrets in the fork
- Add `ADMIN_GITHUB_TOKEN`, `PYPI_TOKEN` and `NPM_TOKEN` to the [Github Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) in the repository
- Go to the Actions panel
- Run the "Draft Changelog" workflow
- Merge the Changelog PR
- Run the "Draft Release" workflow
- Run the "Publish Release" workflow
- Run the "Step 1: Prep Release" workflow
- Check the draft changelog
- Run the "Step 2: Publish Release" workflow

## Publishing to `conda-forge`

Expand Down
1 change: 1 addition & 0 deletions kernel-messaging/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
21 changes: 21 additions & 0 deletions kernel-messaging/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const jestJupyterLab = require('@jupyterlab/testutils/lib/jest-config');

const esModules = ['@jupyterlab/'].join('|');

const baseConfig = jestJupyterLab(__dirname);

module.exports = {
...baseConfig,
automock: false,
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/.ipynb_checkpoints/*'
],
coverageReporters: ['lcov', 'text'],
testRegex: 'src/.*/.*.spec.ts[x]?$',
transformIgnorePatterns: [
...baseConfig.transformIgnorePatterns,
`/node_modules/(?!${esModules}).+`
]
};
14 changes: 2 additions & 12 deletions kernel-messaging/jupyterlab_examples_kernel_messaging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@

import json
import os.path as osp

from ._version import __version__

HERE = osp.abspath(osp.dirname(__file__))

with open(osp.join(HERE, 'labextension', 'package.json')) as fid:
data = json.load(fid)

def _jupyter_labextension_paths():
return [{
'src': 'labextension',
'dest': data['name']
"src": "labextension",
"dest": "@jupyterlab-examples/kernel-messaging"
}]



Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
version_info = (0, 1, 0)
__version__ = ".".join(map(str, version_info))
# 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 = '0.1.0'
Loading

0 comments on commit 9ee44ae

Please sign in to comment.