Skip to content

SwanProjects extension #252

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions SwanProjects/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[bumpversion]
current_version = 0.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be 0.0.0?

commit = True
tag = True
tag_name = SwanProjects/v{new_version}
message = SwanProjects v{new_version}

[bumpversion:file:package.json]

5 changes: 5 additions & 0 deletions SwanProjects/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
coverage
**/*.d.ts
tests
39 changes: 39 additions & 0 deletions SwanProjects/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
'selector': 'interface',
'format': ['PascalCase'],
'custom': {
'regex': '^I[A-Z]',
'match': true
}
}
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'prefer-arrow-callback': 'error'
}
};
2 changes: 2 additions & 0 deletions SwanProjects/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
swanprojects/labextension
.vscode
5 changes: 5 additions & 0 deletions SwanProjects/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
**/node_modules
**/lib
**/package.json
swanterminal
5 changes: 5 additions & 0 deletions SwanProjects/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
661 changes: 661 additions & 0 deletions SwanProjects/LICENSE

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions SwanProjects/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include LICENSE
include README.md
include pyproject.toml
recursive-include jupyter-config *.json

include swanprojects/kernelmanager/resources/*
include swanprojects/stacks/*/*
include swanprojects/kernels/*/*
Copy link
Contributor

@diocas diocas May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not include stacks or kernels (maybe the kernels are ok...). To me those are specific and should be treated as config, i.e being part of the docker image and not the extension.

include swanprojects/static/index.html
include package.json
include install.json
include ts*.json
include yarn.lock

graft swanprojects/labextensions

# Javascript files
graft src
graft style
prune **/node_modules
prune lib
prune binder

# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
23 changes: 23 additions & 0 deletions SwanProjects/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SwanProjects

Server and Lab extension that provides:

- A jupyter serverextension with handlers to:
- Create custom environments for folders with software stack defined in CVMFS
- Get folder enviornment information
- Get software stack information

- A frontend Jupyterlab extension with a forked version of @jupyterlab/launcher that shows a button to edit folder environments

- A kernel provisioner that dynamically customizes the enviornment of a kernel from metadata files in a folder.

## Requirements

JupyterLab~=3.0

## Install & Configure

- Install the package with pip
- Configure `SWAN_DEFAULT_ENV_FILE` for the default environment for folders without an environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would configure a stacks folder, where we put all these file, and we can have a default one (that we populate from cvmfs)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sorry, even myself had to go back to try to understand what I mean with this comment)
What I mean is, instead of setting this as an extra variable, we just push the file we generate on startup on the "default" folder.

- Configure `c.SwanProjectsConfig,stacks_path` in you jupyter server configuration to configuration of available software stacks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Configure `c.SwanProjectsConfig,stacks_path` in you jupyter server configuration to configuration of available software stacks
- Configure `c.SwanProjectsConfig.stacks_path` in you jupyter server configuration to configuration of available software stacks


5 changes: 5 additions & 0 deletions SwanProjects/install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "swanprojects",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package swanprojects"
}
7 changes: 7 additions & 0 deletions SwanProjects/jupyter-config/nb-config/swanprojects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"NotebookApp": {
"nbserver_extensions": {
"swanprojects": true
}
}
}
7 changes: 7 additions & 0 deletions SwanProjects/jupyter-config/server-config/swanprojects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"swanprojects": true
}
}
}
105 changes: 105 additions & 0 deletions SwanProjects/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"name": "@swan/projects-extension",
"version": "0.0.0",
"private": true,
"description": "SWAN Projects extension for JupyterLab",
"homepage": "https://github.com/swan-cern/jupyter-extensions",
"bugs": {
"url": "https://github.com/swan-cern/jupyter-extensions/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/swan-cern/jupyter-extensions.git"
},
"license": "AGPL-3.0",
"author": "SWAN Admins",
"sideEffects": [
"style/*.css",
"style/index.js"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"style": "style/index.css",
"directories": {
"lib": "lib"
},
"files": [
"lib/*.d.ts",
"lib/*.js.map",
"lib/*.js",
"lib/*.jsx",
"src/*.ts",
"src/*.tsx",
"schema/*.json",
"style/*.css",
"style/*.svg",
"style/index.js"
],
"scripts": {
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc",
"build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension",
"clean": "jlpm run clean:lib",
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
"clean:labextension": "rimraf swanprojects/labextension",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"docs": "typedoc src",
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"install:extension": "jlpm run build",
"prepublishOnly": "npm run build",
"watch": "run-p watch:src watch:labextension",
"watch:labextension": "jupyter labextension watch .",
"watch:src": "tsc -w"
},
"dependencies": {
"@jupyterlab/application": "^3.4.0",
"@jupyterlab/apputils": "^3.4.0",
"@jupyterlab/launcher": "^3.4.0",
"@jupyterlab/mainmenu": "^3.0.10",
"@jupyterlab/translation": "^3.4.0",
"@jupyterlab/ui-components": "^3.4.0",
"@lumino/algorithm": "^1.9.0",
"@lumino/commands": "^1.12.0",
"@lumino/coreutils": "^1.11.0",
"@lumino/disposable": "^1.10.0",
"@lumino/properties": "^1.8.0",
"@lumino/widgets": "^1.30.0",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.58",
"codemirror": "^5.61.0",
"react": "^17.0.1",
"react-markdown": "^6.0.2",
"react-select": "^4.3.0",
"react-tooltip": "^4.2.15"
},
"devDependencies": {
"@jupyterlab/builder": "^3.0.0",
"@types/react": "^17.0.43",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"rimraf": "^3.0.2",
"typedoc": "^0.15.4",
"typescript": "~4.1.3"
},
"publishConfig": {
"access": "public"
},
"jupyterlab": {
"extension": true,
"schemaDir": "schema",
"outputDir": "./swanprojects/labextension/@swan/projects-extension",
"disabledExtensions": [
"@jupyterlab/launcher-extension:plugin"
]
},
"styleModule": "style/index.js"
}
13 changes: 13 additions & 0 deletions SwanProjects/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[build-system]
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"]
build-backend = "jupyter_packaging.build_api"

[tool.jupyter-packaging.builder]
factory = "jupyter_packaging.npm_builder"

[tool.jupyter-packaging.build-args]
build_cmd = "build:prod"
npm = ["jlpm"]

[tool.check-manifest]
ignore = ["swanprojects/labextension/**", "yarn.lock", ".*", "package-lock.json"]
14 changes: 14 additions & 0 deletions SwanProjects/schema/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"title": "Launcher",
"description": "Launcher settings.",
"jupyter.lab.shortcuts": [
{
"command": "launcher:create",
"keys": [""],
"selector": "body"
}
],
"properties": {},
"additionalProperties": false,
"type": "object"
}
68 changes: 68 additions & 0 deletions SwanProjects/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
swanprojects setup
"""
import json
from pathlib import Path

import setuptools

HERE = Path(__file__).parent.resolve()

# The name of the project
name = "swanprojects"

data_files_spec = [
("share/jupyter/labextensions/@swan/projects-extension", "swanprojects/labextension/@swan/projects-extension", "**"),
("etc/jupyter/jupyter_server_config.d", "jupyter-config/server-config", "swanprojects.json"),
# For backward compatibility with notebook server
("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/nb-config", "swanprojects.json")
]

long_description = (HERE / "README.md").read_text()

# Get the package info from package.json
pkg_json = json.loads((HERE / "package.json").read_bytes())

setup_args = dict(
name=name,
version=pkg_json["version"],
url=pkg_json["homepage"],
author=pkg_json["author"],
description=pkg_json["description"],
license=pkg_json["license"],
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
install_requires=[
"jupyter_server>=1.6,<2"
],
zip_safe=False,
include_package_data=True,
python_requires=">=3.6",
platforms="Linux, Mac OS X, Windows",
keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
classifiers=[
"License :: OSI Approved :: GNU Affero General Public License v3",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Framework :: Jupyter",
],
entry_points={
"jupyter_client.kernel_provisioners": [
"swan-provisioner = swanprojects:SwanProvisioner",
],
}
)

try:
from jupyter_packaging import get_data_files
setup_args['data_files'] = get_data_files(data_files_spec)
except ImportError as e:
print(e)

if __name__ == "__main__":
setuptools.setup(**setup_args)
Loading