diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml deleted file mode 100644 index b21aa07..0000000 --- a/.github/workflows/check-release.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Check Release -on: - push: - branches: ["main"] - pull_request: - branches: ["*"] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - check_release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - name: Check Release - uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2 - with: - - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload Distributions - uses: actions/upload-artifact@v4 - with: - name: resource_warning-releaser-dist-${{ github.run_number }} - path: .jupyter_releaser_checkout/dist diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 55d427c..903052b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -31,3 +31,6 @@ jobs: VALIDATE_ALL_CODEBASE: false # Fail on errors DISABLE_ERRORS: false + # this is already done by the other linting action + # and the tsconfig conflicts, so removing + VALIDATE_TYPESCRIPT_STANDARD: false diff --git a/CHANGELOG.md b/CHANGELOG.md index d838b0b..2d352af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,5 @@ # Changelog -All notable changes to this project will be documented in this file. + -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -### Added - -- First implementation of a simple notification emiter whenever the resource - usage gets into warning + diff --git a/README.md b/README.md index b1ada5c..ce5952a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # notebooks-resource-warning -[![Github Actions Status](https://github.com/EGI-Federation/notebooks-resource-warnings/workflows/Build/badge.svg)](https://github.com/EGI-Federation/notebooks-resource-warnings/actions/workflows/build.yml) +[![Github Actions Status](https://github.com/EGI-Federation/notebooks-resource-warning/workflows/Build/badge.svg)](https://github.com/EGI-Federation/notebooks-resource-warning/actions/workflows/build.yml) -A JupyterLab extension that shows a notification whenever the usage of memory goes into `warn` status (as provided by the [Jupyter Resource Usage extension](https://github.com/jupyter-server/jupyter-resource-usage) +A JupyterLab extension that shows a notification whenever the usage of memory +goes into `warn` status (as provided by the +[Jupyter Resource Usage extension](https://github.com/jupyter-server/jupyter-resource-usage) ## Requirements @@ -45,7 +47,9 @@ jupyter labextension develop . --overwrite jlpm build ``` -You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension. +You can watch the source directory and run JupyterLab at the same time in +different terminals to watch for changes in the extension's source and +automatically rebuild the extension. ```bash # Watch the source directory in one terminal, automatically rebuilding when needed @@ -54,9 +58,15 @@ jlpm watch jupyter lab ``` -With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt). +With the watch command running, every saved change will immediately be built +locally and available in your running JupyterLab. Refresh JupyterLab to load the +change in your browser (you may need to wait several seconds for the extension +to be rebuilt). -By default, the `jlpm build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command: +By default, the `jlpm build` command generates the source maps for this +extension to make it easier to debug using the browser dev tools. To also +generate source maps for the JupyterLab core extensions, you can run the +following command: ```bash jupyter lab build --minimize=False @@ -68,9 +78,11 @@ jupyter lab build --minimize=False pip uninstall notebooks-resource-warning ``` -In development mode, you will also need to remove the symlink created by `jupyter labextension develop` -command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions` -folder is located. Then you can remove the symlink named `resource_warning` within that folder. +In development mode, you will also need to remove the symlink created by +`jupyter labextension develop` command. To find its location, you can run +`jupyter labextension list` to figure out where the `labextensions` folder is +located. Then you can remove the symlink named `resource_warning` within that +folder. ### Packaging the extension diff --git a/package.json b/package.json index 875fc2e..a7e14a8 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "jupyterlab", "jupyterlab-extension" ], - "homepage": "https://github.com/EGI-Federation/resource-warnings", + "homepage": "https://github.com/EGI-Federation/notebooks-resource-warning", "bugs": { - "url": "https://github.com/EGI-Federation/resource-warnings/issues" + "url": "https://github.com/EGI-Federation/notebooks-resource-warning/issues" }, "license": "BSD-3-Clause", "author": { @@ -26,7 +26,7 @@ "style": "style/index.css", "repository": { "type": "git", - "url": "https://github.com/EGI-Federation/resource-warnings.git" + "url": "https://github.com/EGI-Federation/notebooks-resource-warning.git" }, "scripts": { "build": "jlpm build:lib && jlpm build:labextension:dev", diff --git a/src/index.ts b/src/index.ts index 56c3c35..b11d44d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,7 @@ const plugin: JupyterFrontEndPlugin = { description: 'A JupyterLab extension.', autoStart: true, activate: async (app: JupyterFrontEnd) => { - let refreshRate = DEFAULT_REFRESH_RATE; + const refreshRate = DEFAULT_REFRESH_RATE; const model = new ResourceUsage.Model({ refreshRate }); model.refresh(); } diff --git a/src/model.ts b/src/model.ts index 4dc29e4..f12830c 100644 --- a/src/model.ts +++ b/src/model.ts @@ -85,12 +85,14 @@ export namespace ResourceUsage { ? Math.min(numBytes / memoryLimit, 1) * 100 : 0; const memwarn = value.limits.memory?.warn; - if (memwarn && !this._previousWarn) { - this._previousWarn = true; - Notification.warning( - 'Memory usage reached ' + memoryPercent.toFixed() + '%.', - { autoClose: 3000 } - ); + if (memwarn) { + if (!this._previousWarn) { + this._previousWarn = true; + Notification.warning( + 'Memory usage reached ' + memoryPercent.toFixed() + '%.', + { autoClose: 3000 } + ); + } } else { this._previousWarn = false; }