diff --git a/.gitignore b/.gitignore index b54ac56..0b14b06 100644 --- a/.gitignore +++ b/.gitignore @@ -110,3 +110,9 @@ dmypy.json # OSX files .DS_Store + +# Notebook +*.ipynb + +# Locks +*.lock \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d1329af --- /dev/null +++ b/Makefile @@ -0,0 +1,86 @@ +CONDA_ACTIVATE=source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate ; conda activate +CONDA_DEACTIVATE=source $$(conda info --base)/etc/profile.d/conda.sh ; conda deactivate +CONDA_REMOVE=source $$(conda info --base)/etc/profile.d/conda.sh ; conda remove -y --all -n + +ENV_NAME=jupyterlab-kernel-usage + +.PHONY: clean build dist env cp + +.EXPORT_ALL_VARIABLES: + +default: all ## Default target is all. + +help: ## display this help. + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +all: clean install build dist ## Clean, install and build. + +build: + ($(CONDA_ACTIVATE) ${ENV_NAME}; \ + yarn build ) + +clean: + rm -fr build || true + rm -fr dist || true + rm -fr *.egg-info || true + rm -fr jupyterlab-kernel-usage/labextension || true + find . -name '*.egg-info' -exec rm -fr {} + || true + find . -name '__pycache__' -exec rm -fr {} + || true + +env-rm: + -conda remove -y --all -n ${ENV_NAME} + +env: + -conda env create -f environment.yaml + @echo + @echo -------------------------------- + @echo ✨ ${ENV_NAME} environment is created. + @echo -------------------------------- + @echo + +install-dev: + ($(CONDA_ACTIVATE) ${ENV_NAME}; \ + pip install -e . && \ + jlpm && \ + jlpm build && \ + jupyter server extension enable jupyterlab_kernel_usage && \ + jupyter labextension develop --overwrite .) + +jlab: + ($(CONDA_ACTIVATE) ${ENV_NAME}; \ + jupyter lab \ + --ServerApp.jpserver_extensions="{'jupyterlab': True, 'jupyterlab_kernel_usage': True}" \ + --no-browser \ + --port 8234) + +jlab-dev: + ($(CONDA_ACTIVATE) ${ENV_NAME}; \ + jupyter lab \ + --ServerApp.jpserver_extensions="{'jupyterlab': True, 'jupyterlab_kernel_usage': True}" \ + --no-browser \ + --dev-mode \ + --extensions-in-dev-mode \ + --port 8234) + +jlab-watch: + ($(CONDA_ACTIVATE) ${ENV_NAME}; \ + jupyter lab \ + --watch \ + --ServerApp.jpserver_extensions="{'jupyterlab_resource_usage': True}" \ + --port 8234) + +watch: + ($(CONDA_ACTIVATE) ${ENV_NAME}; \ + yarn watch ) + +main: + ($(CONDA_ACTIVATE) ${ENV_NAME}; \ + python -m jupyterlab_resource_usage ) + +publish: + ($(CONDA_ACTIVATE) ${ENV_NAME}; \ + rm -fr dist/* && \ + yarn clean && \ + yarn build && \ + python setup.py sdist bdist_wheel && \ + twine upload dist/* ) diff --git a/README.md b/README.md index 1737a59..e7fb49c 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,35 @@ for the frontend extension. ## Contributing +### Develop + +Use the provided `environment.yaml` to install the conda environment. + +```base +conda deactivate && \ + make env-rm && \ + make env +conda activate jupyterlab-kernel-usage +``` + +```python +# Install the server and frontend in dev mode. +make install-dev +``` + +```python +# In terminal 1, Start the jupyterlab. +# open http://localhost:8234?token=... +make jlab +``` + +```python +# In terminal 2, start the extension building in watch mode. +make watch +``` + +When making changes to the extension you will need to issue a `jupyter labextension build`, or, start `jlpm run watch` in the root of the repository to rebuild on every changes. You do not need to restart or rebuild JupyterLab for changes on the frontend extensions, but do need to restart the server for changes to the Python code. + ### Development install Note: You will need NodeJS to build the extension package. diff --git a/environment.yaml b/environment.yaml new file mode 100644 index 0000000..7edf2eb --- /dev/null +++ b/environment.yaml @@ -0,0 +1,13 @@ +name: jupyterlab-kernel-usage +channels: + - conda-forge +dependencies: + - pip + - psutil + - setuptools + - tornado + - twine + - yarn + - pip: + - jupyterlab==4.0.0a19 + - jupyter_packaging==0.10.4 diff --git a/package.json b/package.json index 1230253..e6dffb9 100644 --- a/package.json +++ b/package.json @@ -45,15 +45,14 @@ "watch:labextension": "jupyter labextension watch ." }, "dependencies": { - "@jupyterlab/launcher": "^3.1.0", - "@jupyterlab/application": "^3.1.0", - "@jupyterlab/notebook": "^3.1.0", - "@jupyterlab/coreutils": "^5.1.0", - "@jupyterlab/services": "^6.1.0", - "react-json-view": "1.21.3" + "@jupyterlab/launcher": "^4.0.0-alpha.3", + "@jupyterlab/application": "^4.0.0-alpha.3", + "@jupyterlab/notebook": "^4.0.0-alpha.3", + "@jupyterlab/coreutils": "^6.0.0-alpha.3", + "@jupyterlab/services": "^7.0.0-alpha.3" }, "devDependencies": { - "@jupyterlab/builder": "^3.1.0", + "@jupyterlab/builder": "^4.0.0-alpha.3", "@typescript-eslint/eslint-plugin": "^4.8.1", "@typescript-eslint/parser": "^4.8.1", "eslint": "^7.14.0",