summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Aptekarev <aptekarev@gmail.com>2021-09-10 07:34:04 +0300
committerGitHub <noreply@github.com>2021-09-09 21:34:04 -0700
commit4b8a82f3ae657ceadc87435ea65127e4df3d9dc7 (patch)
tree99a6454ad328f10c11f0f17eda53767e5352ecd5
parent42f5b72ddf7694d8f868f31b50d79755eb5c1703 (diff)
Introduce Jupyter Lab extensions (#718)
* Add folder for Jupyter Lab extensions * Add initial settings menu extension code * Add initial terminal launcher extension code * Add lab extension build files to ignore * Update settings form sections to be populated from a loop * Update terminal launcher * Add script load env from settings * Update settings schema * Update settings forms to handle nested schema * Satisfy eslint * Lint python code black * Remove unused python API * Satisfy eslint * Update extension icons * Update terminal launcher menu commands * Update settings infrastructure for both extensions * Update docstrings * Lint python code black * Lint more python code black * Add structure for website * Update labels.yml * Update the settings form population with user settings * Add node_modules of the test folder to gitignore * Add UI tests for the settings extension * WIP: Update terminal launcher extension code and wip settings * Add development setup documentation * Pass settings to environment variables in the launcher * Update settings extension schema to include custom python path * Satisfy eslint and flake8 * Add setup.py to mypy exclude paths The setup.py that goes with the jupyterlab extensions fails the mypy check and excluding them is the only workaround atm * Check mypy hook * Fix linting error raised by pyupgrade * Change setting name to be different from a system variable * Update launcher to set env variables with bash stdin * Clean up unused scripts * Make jupyterlab mandatory in poetry * Add Jupyter Lab extension installation docs Co-authored-by: Chavithra PARANA <chavithra@gmail.com> Co-authored-by: didier <dro.lopes@campus.fct.unl.pt>
-rw-r--r--.github/workflows/test.yml2
-rw-r--r--.gitignore12
-rw-r--r--.pre-commit-config.yaml2
-rw-r--r--README.md4
-rw-r--r--jupyterlab/README.md38
-rw-r--r--jupyterlab/gst-settings/.eslintignore5
-rw-r--r--jupyterlab/gst-settings/.eslintrc.js54
-rw-r--r--jupyterlab/gst-settings/MANIFEST.in22
-rw-r--r--jupyterlab/gst-settings/README.md17
-rw-r--r--jupyterlab/gst-settings/RELEASE.md3
-rw-r--r--jupyterlab/gst-settings/gamestonk_terminal_settings/__init__.py13
-rw-r--r--jupyterlab/gst-settings/gamestonk_terminal_settings/_version.py2
-rw-r--r--jupyterlab/gst-settings/install.json5
-rw-r--r--jupyterlab/gst-settings/package-lock.json17009
-rw-r--r--jupyterlab/gst-settings/package.json82
-rw-r--r--jupyterlab/gst-settings/pyproject.toml17
-rw-r--r--jupyterlab/gst-settings/schema/settings.json428
-rw-r--r--jupyterlab/gst-settings/setup.py86
-rw-r--r--jupyterlab/gst-settings/src/components/FormInput.tsx58
-rw-r--r--jupyterlab/gst-settings/src/index.ts90
-rw-r--r--jupyterlab/gst-settings/src/svg.d.ts4
-rw-r--r--jupyterlab/gst-settings/src/widget.tsx189
-rw-r--r--jupyterlab/gst-settings/style/base.css99
-rw-r--r--jupyterlab/gst-settings/style/index.css1
-rw-r--r--jupyterlab/gst-settings/style/index.js1
-rw-r--r--jupyterlab/gst-settings/style/logo.svg22
-rw-r--r--jupyterlab/gst-settings/style/settings-icon.svg9
-rw-r--r--jupyterlab/gst-settings/tsconfig.json24
-rw-r--r--jupyterlab/gst-settings/ui-tests/README.md117
-rw-r--r--jupyterlab/gst-settings/ui-tests/package.json13
-rw-r--r--jupyterlab/gst-settings/ui-tests/playwright.config.ts18
-rw-r--r--jupyterlab/gst-settings/ui-tests/tests/gst-settings.spec.ts77
-rw-r--r--jupyterlab/gst-settings/yarn.lock6040
-rw-r--r--jupyterlab/gst/.eslintignore5
-rw-r--r--jupyterlab/gst/.eslintrc.js53
-rw-r--r--jupyterlab/gst/MANIFEST.in22
-rw-r--r--jupyterlab/gst/README.md17
-rw-r--r--jupyterlab/gst/RELEASE.md3
-rw-r--r--jupyterlab/gst/gamestonk_terminal_launcher/__init__.py13
-rw-r--r--jupyterlab/gst/gamestonk_terminal_launcher/_version.py2
-rw-r--r--jupyterlab/gst/install.json5
-rw-r--r--jupyterlab/gst/package-lock.json17198
-rw-r--r--jupyterlab/gst/package.json88
-rw-r--r--jupyterlab/gst/pyproject.toml17
-rw-r--r--jupyterlab/gst/setup.py84
-rw-r--r--jupyterlab/gst/src/index.ts170
-rw-r--r--jupyterlab/gst/src/interfaces.ts13
-rw-r--r--jupyterlab/gst/src/svg.d.ts4
-rw-r--r--jupyterlab/gst/style/base.css16
-rw-r--r--jupyterlab/gst/style/index.css1
-rw-r--r--jupyterlab/gst/style/index.js1
-rw-r--r--jupyterlab/gst/style/logo.svg22
-rw-r--r--jupyterlab/gst/style/terminal.svg22
-rw-r--r--jupyterlab/gst/tsconfig.json24
-rw-r--r--pyproject.toml2
55 files changed, 42342 insertions, 3 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 8f7499bdac8..e45bb6c647f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -32,7 +32,7 @@ jobs:
- run: black --check .
- run: codespell --ignore-words-list=pres,coo,navagation,ser,buil,operatio,mape,ba,hist,yeld,ether,hsi --quiet-level=2 --skip=".git" --skip="*.yaml" --skip="*.json" --skip="*.js" --skip="*.css" --skip="*.scss" --skip="*.html" --skip="*.ini" --skip="*.md" --skip="*.lock"
- run: flake8 . --count --ignore=E203,W503 --max-line-length=122 --show-source --statistics
- - run: mypy --ignore-missing-imports .
+ - run: mypy --ignore-missing-imports --exclude '/setup\.py$' .
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py
- run: safety check
- run: |
diff --git a/.gitignore b/.gitignore
index 06a4263ccc2..8e04d57a0ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,15 @@ exports/*
.idea
.coverage
htmlcov
+
+# Jupyter Lab Extension build files
+jupyterlab/*/*.bundle.*
+jupyterlab/*/lib/
+jupyterlab/*/*/labextension/
+jupyterlab/*/node_modules/
+jupyterlab/*/*/node_modules/
+jupyterlab/*/*.egg-info/
+jupyterlab/*/.ipynb_checkpoints
+jupyterlab/*/*.tsbuildinfo
+jupyterlab/*/ui-tests/test-results/
+jupyterlab/*/ui-tests/tests/*.ts-snapshots/
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ce0dd7dcbc7..c39d42d3267 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -26,7 +26,7 @@ repos:
rev: 'v0.812'
hooks:
- id: mypy
- args: [ --ignore-missing-imports ]
+ args: [ --ignore-missing-imports --exclude '/setup\.py$' ]
- repo: https://github.com/pre-commit/mirrors-pylint
rev: 'v3.0.0a4'
hooks:
diff --git a/README.md b/README.md
index 85a3c308b64..63ea3173cce 100644
--- a/README.md
+++ b/README.md
@@ -196,6 +196,10 @@ python terminal.py
After you've installed Gamestonk Terminal, you'll find a file named "Gamestonk Terminal.bat". You can use this file to open Gamestonk Terminal quicker. This file can be moved to your desktop if you'd like. If you run into issues while trying to run the batch file. If you run into issues with the batch files, edit the file and check to see if the directories match up. This file assumes you used the default directories when installing.
+10. Jupyter Lab (Optional. Early alpha). User the Terminal from Jupyter Lab
+
+You can install Jupyter Lab extensions that help you manage settings and launch the terminal in a JL bash console using the commands in the [jupyterlab/README.md](jupyterlab/README.md)
+
**NOTE:** When you close the terminal and re-open it, the only command you need to re-call is `conda activate gst` before you call `python terminal.py` again.
**TROUBLESHOOT:** If you are having troubles to install, check our *newest* <a href="https://github.com/GamestonkTerminal/GamestonkTerminal/blob/master/TROUBLESHOOT.md"><strong>troubleshoot page</strong></a>
diff --git a/jupyterlab/README.md b/jupyterlab/README.md
new file mode 100644
index 00000000000..afc6e9d8d18
--- /dev/null
+++ b/jupyterlab/README.md
@@ -0,0 +1,38 @@
+# Jupyter Lab Extensions for using Gamestonk Terminal
+
+1. Only bash is supported (only macOS, Linux and WSL). No support for Windows powershell or command prompt.
+2. The input values are not escaped
+
+## Installation
+
+To install the Terminal Launcher and the Settings Extensions run the following commands from the [root folder of the project](/):
+
+```bash
+pip install -e jupyterlab/gst
+pip install -e jupyterlab/gst-settings
+jupyter labextension install jupyterlab/gst
+jupyter labextension install jupyterlab/gst-settings
+```
+
+## Development setup
+
+In this section `gst` extension will be used as an example.
+
+- In one terminal window `cd` into the launcher extension folder and build the extension:
+
+```bash
+cd gst
+jlpm
+pip install -e .
+jlpm run build
+jupyter labextension develop . --overwrite
+jlpm run watch
+```
+
+- In the second tab run jupyter lab
+
+```bash
+jupyter lab
+```
+
+---
diff --git a/jupyterlab/gst-settings/.eslintignore b/jupyterlab/gst-settings/.eslintignore
new file mode 100644
index 00000000000..8bd31f70bec
--- /dev/null
+++ b/jupyterlab/gst-settings/.eslintignore
@@ -0,0 +1,5 @@
+node_modules
+dist
+coverage
+**/*.d.ts
+ui-tests
diff --git a/jupyterlab/gst-settings/.eslintrc.js b/jupyterlab/gst-settings/.eslintrc.js
new file mode 100644
index 00000000000..0803d98d862
--- /dev/null
+++ b/jupyterlab/gst-settings/.eslintrc.js
@@ -0,0 +1,54 @@
+module.exports = {
+ extends: [
+ 'eslint:recommended',
+ 'plugin:@typescript-eslint/eslint-recommended',
+ 'plugin:@typescript-eslint/recommended',
+ 'plugin:jsdoc/recommended',
+ 'plugin:prettier/recommended',
+ 'plugin:react/recommended',
+ ],
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ project: 'tsconfig.json',
+ sourceType: 'module',
+ },
+ plugins: ['@typescript-eslint', 'jsdoc'],
+ rules: {
+ "react/react-in-jsx-scope": "off",
+ '@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',
+ 'double',
+ { 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',
+ },
+ },
+};
diff --git a/jupyterlab/gst-settings/MANIFEST.in b/jupyterlab/gst-settings/MANIFEST.in
new file mode 100644
index 00000000000..f4846879d15
--- /dev/null
+++ b/jupyterlab/gst-settings/MANIFEST.in
@@ -0,0 +1,22 @@
+include LICENSE
+include README.md
+include pyproject.toml
+include jupyter-config/gamestonk_terminal_settings.json
+
+include package.json
+include ts*.json
+
+graft gamestonk_terminal_settings/labextension
+
+# Javascript files
+graft src
+graft style
+prune **/node_modules
+prune lib
+
+# Patterns to exclude from any directory
+global-exclude *~
+global-exclude *.pyc
+global-exclude *.pyo
+global-exclude .git
+global-exclude .ipynb_checkpoints
diff --git a/jupyterlab/gst-settings/README.md b/jupyterlab/gst-settings/README.md
new file mode 100644
index 00000000000..213bb611022
--- /dev/null
+++ b/jupyterlab/gst-settings/README.md
@@ -0,0 +1,17 @@
+# Gamestonk Teminal Settings Menu
+
+This extensions allows the user to set API keys and feature flags for the Gamestonk Terminal
+
+## Install, Use and Develop
+
+```bash
+pip install -e .
+jlpm
+jlpm run build:prod
+jupyter labextension install .
+
+# Rebuild Typescript source after making changes
+jlpm build
+# Rebuild JupyterLab after making any changes
+jupyter lab build
+```
diff --git a/jupyterlab/gst-settings/RELEASE.md b/jupyterlab/gst-settings/RELEASE.md
new file mode 100644
index 00000000000..4603959c9af
--- /dev/null
+++ b/jupyterlab/gst-settings/RELEASE.md
@@ -0,0 +1,3 @@
+# Making a new release of gamestonk-settings
+
+Check out the [workflow documentation](https://github.com/jupyter-server/jupyter_releaser#typical-workflow) for information.
diff --git a/jupyterlab/gst-settings/gamestonk_terminal_settings/__init__.py b/jupyterlab/gst-settings/gamestonk_terminal_settings/__init__.py
new file mode 100644
index 00000000000..65fd31bee52
--- /dev/null
+++ b/jupyterlab/gst-settings/gamestonk_terminal_settings/__init__.py
@@ -0,0 +1,13 @@
+import json
+import os.path as osp
+
+from ._version import __version__ # noqa: F401
+
+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"]}]
diff --git a/jupyterlab/gst-settings/gamestonk_terminal_settings/_version.py b/jupyterlab/gst-settings/gamestonk_terminal_settings/_version.py
new file mode 100644
index 00000000000..ee864fc9e71
--- /dev/null
+++ b/jupyterlab/gst-settings/gamestonk_terminal_settings/_version.py
@@ -0,0 +1,2 @@
+version_info = (0, 1, 0)
+__version__ = ".".join(map(str, version_info))
diff --git a/jupyterlab/gst-settings/install.json b/jupyterlab/gst-settings/install.json
new file mode 100644
index 00000000000..9d770785216
--- /dev/null
+++ b/jupyterlab/gst-settings/install.json
@@ -0,0 +1,5 @@
+{
+ "packageManager": "python",
+ "packageName": "gamestonk_terminal_settings",
+ "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package gamestonk_terminal_settings"
+}
diff --git a/jupyterlab/gst-settings/package-lock.json b/jupyterlab/gst-settings/package-lock.json
new file mode 100644
index 00000000000..382b9a8efd9
--- /dev/null
+++ b/jupyterlab/gst-settings/package-lock.json
@@ -0,0 +1,17009 @@
+{
+ "name": "@gamestonk/settings",
+ "version": "0.1.0",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "@gamestonk/settings",
+ "version": "0.1.0",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@jupyterlab/application": "^3.1.0",
+ "@jupyterlab/launcher": "^3.1.0",
+ "@jupyterlab/mainmenu": "^3.1.7",
+ "@jupyterlab/settingregistry": "^3.1.8",
+ "@jupyterlab/ui-components": "^3.1.0"
+ },
+ "devDependencies": {
+ "@jupyterlab/builder": "^3.1.0",
+ "@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-jsdoc": "^36.0.0",
+ "eslint-plugin-prettier": "^3.1.4",
+ "eslint-plugin-react": "^7.18.3",
+ "npm-run-all": "^4.1.5",
+ "prettier": "^2.1.1",
+ "rimraf": "^3.0.2",
+ "typescript": "~4.1.3"
+ }
+ },
+ "node_modules/@babel/code-frame": {
+ "version": "7.12.11",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz",
+ "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==",
+ "dev": true,
+ "dependencies": {
+ "@babel/highlight": "^7.10.4"
+ }
+ },
+ "node_modules/@babel/helper-validator-identifier": {
+ "version": "7.14.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.9.tgz",
+ "integrity": "sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g==",
+ "dev": true,
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@babel/highlight": {
+ "version": "7.14.5",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz",
+ "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==",
+ "dev": true,
+ "dependencies": {
+ "@babel/helper-validator-identifier": "^7.14.5",
+ "chalk": "^2.0.0",
+ "js-tokens": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@babel/runtime": {
+ "version": "7.15.3",
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.3.tgz",
+ "integrity": "sha512-OvwMLqNXkCXSz1kSm58sEsNuhqOx/fKpnUnKnFB5v8uDda5bLNEHNgKPvhDN6IU0LDcnHQ90LlJ0Q6jnyBSIBA==",
+ "dependencies": {
+ "regenerator-runtime": "^0.13.4"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@blueprintjs/colors": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@blueprintjs/colors/-/colors-1.0.0.tgz",
+ "integrity": "sha512-eJh111ucz8HYxLBON6ADkAGQQBACqdbX6Zws/GpuiTkeCFJ3IAjZdBpk7IM7/Y5XuGuSS1ujwjnLDOEtyywtKw=="
+ },
+ "node_modules/@blueprintjs/core": {
+ "version": "3.48.0",
+ "resolved": "https://registry.npmjs.org/@blueprintjs/core/-/core-3.48.0.tgz",
+ "integrity": "sha512-tuAL3dZrNaTq36RRy6O86wjmkiLt8LwHkleZ1zUcn/DC3cXsM3dSsRpV3f