Skip to content

Commit

Permalink
looooads of pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Apr 3, 2020
1 parent 3ccb9ec commit cd75c51
Show file tree
Hide file tree
Showing 103 changed files with 4,070 additions and 2,721 deletions.
23 changes: 20 additions & 3 deletions .dockerignore
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
2 changes: 1 addition & 1 deletion .github/workflows/mpcontribs-client-tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
run: cd mpcontribs-client && tox
5 changes: 4 additions & 1 deletion .github/workflows/mpcontribs-testing.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: MPContribs Testing
on: [push, pull_request]
on:
push:
branches-ignore:
- '**'
jobs:
test:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.tox
.mypy_cache
__pycache__
*.swp
Expand Down
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/materialsproject/MPContribs?style=flat-square)
![LGTM Alerts](https://img.shields.io/lgtm/alerts/github/materialsproject/MPContribs?style=flat-square)
![Website](https://img.shields.io/website?down_color=red&down_message=down&label=API&style=flat-square&up_color=green&up_message=up&url=https%3A%2F%2Fapi.mpcontribs.org)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/materialsproject/MPContribs?style=flat-square)
Expand Down
81 changes: 47 additions & 34 deletions binder/jupyterhub_config.py
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
15 changes: 11 additions & 4 deletions binder/notebooks/convert.sh
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
9 changes: 4 additions & 5 deletions binder/notebooks/portal.mpcontribs.org/Fe3O4.cif
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#\#CIF1.1
##########################################################################
# Crystallographic Information Format file
# Crystallographic Information Format file
# Produced by PyCifRW module
#
#
# This is a CIF file. CIF has been adopted by the International
# Union of Crystallography as the standard for data archiving and
# Union of Crystallography as the standard for data archiving and
# transmission.
#
# For information on this file format, follow the CIF links at
Expand All @@ -29,7 +29,7 @@ loop_
_symmetry_equiv_pos_site_id
_symmetry_equiv_pos_as_xyz
1 'x, y, z'

loop_
_atom_site_type_symbol
_atom_site_label
Expand All @@ -54,4 +54,3 @@ loop_
Fe Fe12 1 0.132170 0.264340 0.924770 0 . 1
Fe Fe13 1 0.617925 0.235849 0.250000 0 . 1
Fe Fe14 1 0.382075 0.764150 0.750000 0 . 1

2 changes: 0 additions & 2 deletions docs/portal.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,3 @@ how to interact with a contribution programmatically along with the resulting ou
navigation bar at the top provides links to jump to a respective component, toggle buttons
to show/hide components, and a download button to retrieve the contribution in JSON
format.


2 changes: 1 addition & 1 deletion docs/redox_thermo_csp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ perovskites may be used for two-step thermochemical oxygen storage, pumping, or
separation. Moreover, some of them can be used for water splitting or CO<sub>2</sub>
splitting, allowing the generation of solar fuels. Our approach is based upon creating
**solid solutions of perovskites** to tune their thermodynamic properties. These solid
solutions, denoted by
solutions, denoted by

(A</sup>'</sup><sub>x</sub>A</sup>''</sup><sub>1-x</sub>)<sup>(6-n)+</sup>(M</sup>'</sup><sub>y</sub>M</sup>''</sup><sub>1-y</sub>)<sup>(n-2δ)+</sup>O<sub>3-δ</sub>

Expand Down
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@ extra:
link: 'https://twitter.com/persson_group'
- type: 'linkedin'
link: 'https://linkedin.com/in/tschaume'

Loading

0 comments on commit cd75c51

Please sign in to comment.