Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt the Jupyter Releaser, update Jupyter Packaging #115

Merged
merged 23 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
19 changes: 4 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install node
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Checkout
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
architecture: 'x64'
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install jupyterlab~=3.0
Expand All @@ -38,9 +33,3 @@ jobs:
jupyter nbextension list 2>&1 | grep -ie "jupyter_resource_usage/main.*enabled"
jupyter labextension list 2>&1 | grep -ie "@jupyter-server/resource-usage.*OK"
python -m jupyterlab.browser_check

- name: Lint
run: |
cd packages/labextension/
jlpm
jlpm run lint:check
40 changes: 40 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check Release
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

permissions:
contents: write

jobs:
check_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

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

- name: Upgrade packaging dependencies
run: |
pip install --upgrade jupyter-packaging~=0.10 --user

- name: Install Dependencies
run: |
pip install .

- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Distributions
uses: actions/upload-artifact@v2
with:
name: jupyter-resource-usage-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
11 changes: 11 additions & 0 deletions .github/workflows/enforce-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Enforce PR label

on:
pull_request:
types: [labeled, unlabeled, opened, edited, synchronize]
jobs:
enforce-label:
runs-on: ubuntu-latest
steps:
- name: enforce-triage-label
uses: jupyterlab/maintainer-tools/.github/actions/enforce-label@v1
37 changes: 22 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@ name: Lint

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

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install black
- name: Lint Python
run: |
black --check .
- name: Checkout
uses: actions/checkout@v2

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip black jupyterlab~=3.0

- name: Lint Python
run: |
black --check .

- name: Lint JS
run: |
jlpm
jlpm run lint:check
19 changes: 11 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Checkout
uses: actions/checkout@v2

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

- name: Lint with flake8
run: python -m flake8 jupyter_resource_usage
run: |
python -m flake8 jupyter_resource_usage

- name: Test with pytest
run: |
python -m pytest -vvv jupyter_resource_usage --cov=jupyter_resource_usage --junitxml=python_junit.xml --cov-report=xml --cov-branch
13 changes: 8 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.3.5
rev: v1.9.0
hooks:
- id: reorder-python-imports
language_version: python3
- repo: https://github.com/ambv/black
rev: 18.9b0
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: "3.8.4"
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
rev: v3.4.0
hooks:
- id: end-of-file-fixer
- id: check-json
Expand All @@ -18,4 +22,3 @@ repos:
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- id: flake8
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
**/node_modules
**/lib
**/package.json

jupyter_resource_usage/labextension
jupyter_resource_usage/static
File renamed without changes.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Changelog

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

## 0.6.0

- `executor` as ApiHandle class attribute [\#95](https://github.com/jupyter-server/jupyter-resource-usage/pull/95) ([jtpio](https://github.com/jtpio))
- Update RELEASE.md [\#94](https://github.com/jupyter-server/jupyter-resource-usage/pull/94) ([jtpio](https://github.com/jtpio))
- Clarify notebook/jupyter\_server usage [\#93](https://github.com/jupyter-server/jupyter-resource-usage/pull/93) ([fcollonval](https://github.com/fcollonval))
- Clarify notebook/jupyter_server usage [\#93](https://github.com/jupyter-server/jupyter-resource-usage/pull/93) ([fcollonval](https://github.com/fcollonval))
- Bump ssri from 8.0.0 to 8.0.1 in /packages/labextension [\#90](https://github.com/jupyter-server/jupyter-resource-usage/pull/90) ([dependabot[bot]](https://github.com/apps/dependabot))
- Update to JupyterLab 3.0 final packages [\#87](https://github.com/jupyter-server/jupyter-resource-usage/pull/87) ([jtpio](https://github.com/jtpio))
- Add instructions to install with conda [\#83](https://github.com/jupyter-server/jupyter-resource-usage/pull/83) ([jtpio](https://github.com/jtpio))
- Add Changelog for 0.5.1 [\#82](https://github.com/jupyter-server/jupyter-resource-usage/pull/82) ([jtpio](https://github.com/jtpio))

<!-- <END NEW CHANGELOG ENTRY> -->

## 0.5.1

- Skip building js assets if they already exist: [#81](https://github.com/jupyter-server/jupyter-resource-usage/pull/81)
Expand All @@ -31,7 +35,6 @@ pip install jupyter-resource-usage
- Add a JupyterLab extension for the memory usage status bar item: [#69](https://github.com/jupyter-server/jupyter-resource-usage/pull/69)
- Drop the deprecated `/metrics` endpoint: [#77](https://github.com/jupyter-server/jupyter-resource-usage/pull/77)


### Migrating to 0.5.0

For classic notebook users, there shouldn't be any major change or action to take. The classic notebook extension is still distributed with the Python package as before.
Expand Down Expand Up @@ -71,7 +74,7 @@ jupyter lab --ResourceUseDisplay.disable_legacy_endpoint=False
## 0.3.6

- Fix handling of cpu percent in the API endpoint [#56](https://github.com/jupyter-server/jupyter-resource-usage/pull/56)
- Added Binder [#53](https://github.com/jupyter-server/jupyter-resource-usage/pull/53) & RELEASE.md [#54](https://github.com/jupyter-server/jupyter-resource-usage/pull/54)
- Added Binder [#53](https://github.com/jupyter-server/jupyter-resource-usage/pull/53) & RELEASE.md [#54](https://github.com/jupyter-server/jupyter-resource-usage/pull/54)

## 0.3.5

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Enable the server extension:
jupyter serverextension enable --py jupyter_resource_usage --sys-prefix
```

*Note: if you're using Jupyter Server:*
_Note: if you're using Jupyter Server:_

```bash
jupyter server extension enable --py jupyter_resource_usage --sys-prefix
Expand Down Expand Up @@ -150,7 +150,7 @@ into your text editor to format code automatically.

If you have already committed files before setting up the pre-commit
hook with `pre-commit install`, you can fix everything up using
`pre-commit run --all-files`. You need to make the fixing commit
`pre-commit run --all-files`. You need to make the fixing commit
yourself after that.

## Tests
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include LICENSE

include README.md
include *.md
include pyproject.toml
include package.json
include install.json
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ The threshold for this warning can be configured as a fraction of the memory lim
If you want to flash the warning to the user when they are within 10% of the memory limit, you
can set the parameter `--ResourceUseDisplay.mem_warning_threshold=0.1`.


### CPU Usage

`jupyter-resource-usage` can also track CPU usage and report a `cpu_percent` value as part of the `/api/metrics/v1` response.
Expand Down
56 changes: 3 additions & 53 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,6 @@
# Making a new release of `jupyter-resource-usage`

## Getting a clean environment
## Automated Releases with `jupyter_releaser`

Creating a new environment can help avoid pushing local changes and any extra tag.

```bash
mamba create -n jupyter-resource-usage-release -c conda-forge twine keyring jupyter-packaging=0.7 jupyterlab=3 python
conda activate jupyter-resource-usage-release
```

Alternatively, the local repository can be cleaned with:

```bash
git clean -fdx
```

## Releasing on PyPI

Make sure the `dist/` folder is empty.

1. Update the version in `setup.py`
2. If the JupyterLab extension has changed, make sure to bump the version number in `packages/labextension/package.json`
3. `python setup.py sdist bdist_wheel`
4. Double check the size of the bundles in the `dist/` folder
5. Run the tests
- `pip install "dist/jupyter-resource-usage-X.Y.Z-py3-none-any.whl[dev]"`
- `python -m pytest`
6. `export TWINE_USERNAME=mypypi_username`
7. `twine upload dist/*`

## Releasing on conda-forge

The easiest is to wait for the bot to open the PR automatically.

To do the release manually:

1. Open a new PR on https://github.com/conda-forge/jupyter-resource-usage-feedstock to update the `version` and the `sha256` hash
2. Wait for the tests
3. Merge the PR

The new version will be available on `conda-forge` soon after.

## Committing and tagging

Commit the changes, create a new release tag, and update the `stable` branch (for Binder), where `x.y.z` denotes the new version:

```bash
git checkout master
git add setup.py
git commit -m "Release x.y.z"
git tag x.y.z
git checkout stable
git reset --hard master
git push origin master stable x.y.z
```
The recommended way to make a release is to use
[`jupyter_releaser`](https://jupyter-releaser.readthedocs.io/en/latest/).
1 change: 0 additions & 1 deletion binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ channels:
dependencies:
- python=3
- jupyterlab=3
- jupyter_resource_usage=0.6.0
- nodejs
4 changes: 4 additions & 0 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -euo pipefail

python -m pip install . --upgrade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"load_extensions": {
"jupyter_resource_usage/main": true
"jupyter_resource_usage/main": true
}
}
29 changes: 3 additions & 26 deletions jupyter_resource_usage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import json
import os.path as osp

from jupyter_server.utils import url_path_join
from tornado import ioloop

from jupyter_resource_usage.api import ApiHandler
from jupyter_resource_usage.config import ResourceUseDisplay
from jupyter_resource_usage.metrics import PSUtilMetricsLoader
from jupyter_resource_usage.prometheus import PrometheusHandler
from ._version import __version__
from .server_extension import load_jupyter_server_extension

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

Expand Down Expand Up @@ -40,22 +35,4 @@ def _jupyter_nbextension_paths():
]


def _load_jupyter_server_extension(server_app):
"""
Called during notebook start
"""
resuseconfig = ResourceUseDisplay(parent=server_app)
server_app.web_app.settings["jupyter_resource_usage_display_config"] = resuseconfig
base_url = server_app.web_app.settings["base_url"]

server_app.web_app.add_handlers(
".*", [(url_path_join(base_url, "/api/metrics/v1"), ApiHandler)]
)

callback = ioloop.PeriodicCallback(
PrometheusHandler(PSUtilMetricsLoader(server_app)), 1000
)
callback.start()


load_jupyter_server_extension = _load_jupyter_server_extension
load_jupyter_server_extension = load_jupyter_server_extension
1 change: 1 addition & 0 deletions jupyter_resource_usage/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.6.0"
Loading