-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
4,070 additions
and
2,721 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
.git | ||
mpcontribs-ingester | ||
docs | ||
.git* | ||
*.pyc | ||
*.egg-info | ||
__pycache__ | ||
.ipynb_checkpoints | ||
.local | ||
.ipython | ||
.jupyter | ||
.DS_Store | ||
.dependabot | ||
.cache | ||
.tox | ||
|
||
./cloudformation | ||
./src | ||
|
||
docs | ||
build | ||
dist | ||
static | ||
node_modules | ||
|
||
mpcontribs-api/flasgger | ||
mpcontribs-api/flask-mongorest | ||
mpcontribs-api/marshmallow-mongoengine | ||
mpcontribs-api/mimerender | ||
mpcontribs-api/mpcontribs/api/swagger | ||
|
||
mpcontribs-portal/mpcontribs/users/qmcdb | ||
mpcontribs-portal/mpcontribs/portal/templates/notebooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.tox | ||
.mypy_cache | ||
__pycache__ | ||
*.swp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
exclude: | | ||
(?x)( | ||
^mpcontribs-portal/mpcontribs/users/| | ||
^binder/| | ||
^mpcontribs-ingester/| | ||
^mpcontribs-api/mpcontribs/api/redox_thermo_csp/ | ||
) | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: check-added-large-files | ||
- id: check-merge-conflict | ||
- id: fix-encoding-pragma | ||
- id: forbid-new-submodules | ||
- id: requirements-txt-fixer | ||
|
||
#- repo: https://gitlab.com/pycqa/flake8 | ||
# rev: 3.7.9 | ||
# hooks: | ||
# - id: flake8 | ||
# args: [--max-line-length=99] | ||
|
||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
hooks: | ||
- id: black | ||
language_version: python3.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,89 @@ | ||
import os | ||
from jhub_remote_user_authenticator.remote_user_auth import RemoteUserLocalAuthenticator | ||
from fargatespawner import FargateSpawner#, FargateSpawnerECSRoleAuthentication | ||
from fargatespawner import FargateSpawner # , FargateSpawnerECSRoleAuthentication | ||
from fargatespawner import FargateSpawnerSecretAccessKeyAuthentication | ||
|
||
RemoteUserLocalAuthenticator.header_name = 'X-Consumer-Username' | ||
RemoteUserLocalAuthenticator.header_name = "X-Consumer-Username" | ||
c.JupyterHub.authenticator_class = RemoteUserLocalAuthenticator | ||
c.Authenticator.username_pattern = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$' | ||
c.Authenticator.username_pattern = "^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" | ||
c.Authenticator.create_system_users = True | ||
c.Authenticator.add_user_cmd = ['adduser', '-q', '--gecos', '""', '--disabled-password', '--force-badname'] | ||
c.Authenticator.add_user_cmd = [ | ||
"adduser", | ||
"-q", | ||
"--gecos", | ||
'""', | ||
"--disabled-password", | ||
"--force-badname", | ||
] | ||
c.Authenticator.whitelist = whitelist = set() | ||
c.Authenticator.admin_users = admin = {'[email protected]'} | ||
c.Authenticator.admin_users = admin = {"[email protected]"} | ||
|
||
NODE_ENV = os.environ.get('NODE_ENV') | ||
NODE_ENV = os.environ.get("NODE_ENV") | ||
|
||
if NODE_ENV == 'development': | ||
if NODE_ENV == "development": | ||
c.NotebookApp.open_browser = False | ||
c.JupyterHub.hub_ip = 'jhub' | ||
c.JupyterHub.hub_ip = "jhub" | ||
|
||
#c.JupyterHub.spawner_class = 'simplespawner.SimpleLocalProcessSpawner' | ||
#c.Spawner.args = ['--allow-root'] | ||
c.JupyterHub.spawner_class = 'repo2dockerspawner.Repo2DockerSpawner' | ||
c.Repo2DockerSpawner.repo = 'https://github.com/materialsproject/MPContribs' | ||
# c.JupyterHub.spawner_class = 'simplespawner.SimpleLocalProcessSpawner' | ||
# c.Spawner.args = ['--allow-root'] | ||
c.JupyterHub.spawner_class = "repo2dockerspawner.Repo2DockerSpawner" | ||
c.Repo2DockerSpawner.repo = "https://github.com/materialsproject/MPContribs" | ||
c.DockerSpawner.http_timeout = 10 * 60 | ||
network_name = os.environ['DOCKER_NETWORK_NAME'] | ||
network_name = os.environ["DOCKER_NETWORK_NAME"] | ||
c.DockerSpawner.use_internal_ip = True | ||
c.DockerSpawner.network_name = network_name | ||
c.DockerSpawner.extra_host_config = {'network_mode': network_name} | ||
notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan/work' | ||
c.DockerSpawner.extra_host_config = {"network_mode": network_name} | ||
notebook_dir = os.environ.get("DOCKER_NOTEBOOK_DIR") or "/home/jovyan/work" | ||
c.DockerSpawner.notebook_dir = notebook_dir | ||
c.DockerSpawner.volumes = {'mpcontribs_data-volume': notebook_dir} | ||
c.DockerSpawner.volumes = {"mpcontribs_data-volume": notebook_dir} | ||
c.DockerSpawner.remove_containers = True | ||
c.DockerSpawner.debug = True | ||
c.DockerSpawner.host_ip = "0.0.0.0" | ||
c.Spawner.env_keep.extend(['NODE_ENV', 'MAPI_KEY']) | ||
#c.JupyterHub.services = [ | ||
c.Spawner.env_keep.extend(["NODE_ENV", "MAPI_KEY"]) | ||
# c.JupyterHub.services = [ | ||
# { | ||
# 'name': 'cull_idle', | ||
# 'admin': True, | ||
# 'command': 'python /srv/jupyterhub/cull_idle_servers.py --timeout=3600'.split(), | ||
# }, | ||
#] | ||
# ] | ||
else: | ||
c.JupyterHub.spawner_class = FargateSpawner | ||
c.FargateSpawner.aws_region = 'us-east-1' | ||
c.FargateSpawner.aws_ecs_host = 'ecs.us-east-1.amazonaws.com' | ||
c.FargateSpawner.task_role_arn = os.environ['TASK_ROLE_ARN'] | ||
c.FargateSpawner.task_cluster_name = os.environ['TASK_CLUSTER_NAME'] | ||
c.FargateSpawner.task_container_name = 'singleuser' | ||
c.FargateSpawner.task_definition_arn = os.environ['TASK_DEFINITION_ARN'] | ||
c.FargateSpawner.task_security_groups = os.environ['TASK_SECURITY_GROUPS'].split(',') | ||
c.FargateSpawner.task_subnets = os.environ['TASK_SUBNETS'].split(',') | ||
c.FargateSpawner.aws_region = "us-east-1" | ||
c.FargateSpawner.aws_ecs_host = "ecs.us-east-1.amazonaws.com" | ||
c.FargateSpawner.task_role_arn = os.environ["TASK_ROLE_ARN"] | ||
c.FargateSpawner.task_cluster_name = os.environ["TASK_CLUSTER_NAME"] | ||
c.FargateSpawner.task_container_name = "singleuser" | ||
c.FargateSpawner.task_definition_arn = os.environ["TASK_DEFINITION_ARN"] | ||
c.FargateSpawner.task_security_groups = os.environ["TASK_SECURITY_GROUPS"].split( | ||
"," | ||
) | ||
c.FargateSpawner.task_subnets = os.environ["TASK_SUBNETS"].split(",") | ||
c.FargateSpawner.debug = True | ||
c.FargateSpawner.notebook_port = 8888 | ||
c.FargateSpawner.notebook_scheme = 'http' | ||
c.FargateSpawner.notebook_scheme = "http" | ||
c.FargateSpawner.notebook_args = [] | ||
#c.FargateSpawner.authentication_class = FargateSpawnerECSRoleAuthentication | ||
# c.FargateSpawner.authentication_class = FargateSpawnerECSRoleAuthentication | ||
c.FargateSpawner.authentication_class = FargateSpawnerSecretAccessKeyAuthentication | ||
c.FargateSpawnerSecretAccessKeyAuthentication.aws_access_key_id = os.environ['AWS_ACCESS_KEY_ID'] | ||
c.FargateSpawnerSecretAccessKeyAuthentication.aws_secret_access_key = os.environ['AWS_SECRET_ACCESS_KEY'] | ||
c.FargateSpawnerSecretAccessKeyAuthentication.aws_access_key_id = os.environ[ | ||
"AWS_ACCESS_KEY_ID" | ||
] | ||
c.FargateSpawnerSecretAccessKeyAuthentication.aws_secret_access_key = os.environ[ | ||
"AWS_SECRET_ACCESS_KEY" | ||
] | ||
|
||
c.JupyterHub.admin_access = True | ||
c.JupyterHub.default_url = '/hub/home' | ||
c.JupyterHub.default_url = "/hub/home" | ||
c.JupyterHub.cleanup_proxy = False | ||
c.JupyterHub.cleanup_servers = False | ||
c.JupyterHub.active_server_limit = 10 | ||
c.JupyterHub.concurrent_spawn_limit = 5 | ||
#c.JupyterHub.db_url = 'sqlite:///jupyterhub.sqlite' # TODO https://github.com/uktrade/jupyters3 | ||
# c.JupyterHub.db_url = 'sqlite:///jupyterhub.sqlite' # TODO https://github.com/uktrade/jupyters3 | ||
c.JupyterHub.shutdown_on_logout = True | ||
c.JupyterHub.upgrade_db = True | ||
|
||
c.Spawner.consecutive_failure_limit = 3 | ||
c.Spawner.cpu_limit = 0.25 | ||
c.Spawner.debug = True | ||
c.Spawner.mem_limit = '512M' | ||
c.Spawner.mem_limit = "512M" | ||
c.Spawner.start_timeout = 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
#!/bin/bash | ||
|
||
out=/app/mpcontribs/portal/templates/notebooks/ | ||
[[ -d $out ]] && rm -rv $out && mkdir -pv $out | ||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 INDIR OUTDIR" | ||
exit 1 | ||
fi | ||
|
||
for d in `ls -1d /app/notebooks/*/`; do | ||
indir=$1 | ||
[[ ! -d $indir ]] && echo "$indir does not exist!" && exit 1 | ||
outdir=$2 | ||
[[ -d $outdir ]] && rm -rv $outdir && mkdir -pv $outdir | ||
|
||
for d in `ls -1d $indir/*/`; do | ||
name=`basename $d` | ||
for i in `ls -1 $d*.ipynb`; do | ||
echo $i | ||
/venv/bin/jupyter nbconvert --to html --template basic --output-dir=$out$name $i | ||
jupyter nbconvert --to html --template basic --output-dir=$outdir$name $i | ||
done | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,3 @@ extra: | |
link: 'https://twitter.com/persson_group' | ||
- type: 'linkedin' | ||
link: 'https://linkedin.com/in/tschaume' | ||
|
Oops, something went wrong.