-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
217 additions
and
43 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
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,18 +1,46 @@ | ||
--- | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 20.8b1 | ||
hooks: | ||
- id: black | ||
language_version: python3 # Should be a command that runs python3.6+ | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: '3.8.4' | ||
hooks: | ||
- id: flake8 | ||
args: [--count, --show-source, --statistics] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: check-json | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
exclude: miscellaneous/structures/SiO2.xyz | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.6.4 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black", "--filter-files"] | ||
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt | ||
rev: 0.2.2 | ||
hooks: | ||
- id: yamlfmt | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 22.6.0 | ||
hooks: | ||
- id: black | ||
language_version: python3 # Should be a command that runs python3.6+ | ||
|
||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 4.0.1 | ||
hooks: | ||
- id: flake8 | ||
args: [--count, --show-source, --statistics] | ||
additional_dependencies: | ||
- flake8-bugbear==21.3.1 | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
args: [--profile, black, --filter-files] | ||
|
||
- repo: https://github.com/asottile/setup-cfg-fmt | ||
rev: v1.20.2 | ||
hooks: | ||
- id: setup-cfg-fmt | ||
|
||
- repo: https://github.com/sirosen/check-jsonschema | ||
rev: 0.17.1 | ||
hooks: | ||
- id: check-github-workflows |
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1e6a8c8c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import urllib.parse as urlparse\n", | ||
"import ipywidgets as ipw" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7e7e205e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import sys\n", | ||
"from aiidalab.__main__ import _find_version_to_install, _parse_requirement\n", | ||
"from aiidalab.utils import PEP508CompliantUrl\n", | ||
"\n", | ||
"\n", | ||
"def identify_app_and_version(app_query, prereleases, force): \n", | ||
" try:\n", | ||
" requirement = _parse_requirement(app_query)\n", | ||
" except Exception as error:\n", | ||
" raise RuntimeError(str(error)) from error\n", | ||
" \n", | ||
" try:\n", | ||
" return _find_version_to_install(\n", | ||
" requirement,\n", | ||
" dependencies=\"install\",\n", | ||
" force=force,\n", | ||
" python_bin=sys.executable,\n", | ||
" prereleases=prereleases)\n", | ||
" except Exception as error:\n", | ||
" raise RuntimeError(str(error)) from error" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b3e749de", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"url = urlparse.urlsplit(jupyter_notebook_url)\n", | ||
"\n", | ||
"query = urlparse.parse_qs(url.query)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "c25a71a5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from home.widgets import LogOutputWidget, Spinner, StatusHTML\n", | ||
"from IPython.display import Javascript\n", | ||
"\n", | ||
"header = ipw.HTML()\n", | ||
"logs = LogOutputWidget(layout=ipw.Layout(min_height=\"250px\", max_height=\"100px\"))\n", | ||
"spinner = Spinner()\n", | ||
"\n", | ||
"display(ipw.VBox([ipw.HBox([header, spinner]), logs]))\n", | ||
"\n", | ||
"try:\n", | ||
" try:\n", | ||
" app_query = query[\"app\"][0]\n", | ||
" except KeyError:\n", | ||
" raise RuntimeError(\"No app to install specified.\")\n", | ||
" \n", | ||
" force = query.get(\"force\", [False])[0]\n", | ||
" prereleases = query.get(\"prereleases\", [False])[0]\n", | ||
" \n", | ||
" app, version = identify_app_and_version(query[\"app\"][0], force=force, prereleases=prereleases)\n", | ||
"except Exception as error:\n", | ||
" header.value = f\"Error: {error}\"\n", | ||
"\n", | ||
"try:\n", | ||
" if version is None:\n", | ||
" header.value = \"App already installed.\"\n", | ||
" else:\n", | ||
" header.value = f\"Installing app '{app.name}': {version}...\"\n", | ||
"\n", | ||
" spinner.enabled = True\n", | ||
" app.install(\n", | ||
" version=version,\n", | ||
" install_dependencies=True,\n", | ||
" python_bin=sys.executable,\n", | ||
" stdout=logs,\n", | ||
" )\n", | ||
"except Exception as error:\n", | ||
" header.value = f\"Error while trying to install the app: {error}\"\n", | ||
"else:\n", | ||
" redirect = query.get(\"redirect\", None)\n", | ||
" if redirect:\n", | ||
" redirect_url = urlparse.urlunsplit(url._replace(path=redirect[0], query=None, fragment=None))\n", | ||
" header.value = f'Redirecting now to <a href=\"{redirect_url}\">{redirect_url}</a>...'\n", | ||
" js = Javascript(f\"window.location = '{redirect_url}'\")\n", | ||
" display(js)\n", | ||
"finally:\n", | ||
" spinner.enabled = False" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,38 +1,42 @@ | ||
[metadata] | ||
name = aiidalab-home | ||
name = aiidalab_home | ||
version = attr: home.__version__ | ||
author = The AiiDAlab Team | ||
author_email = [email protected] | ||
description = Package for the AiiDAlab Home app. | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/aiidalab/aiidalab-home | ||
project_urls = | ||
Bug Tracker = https://github.com/aiidalab/aiidalab-home/issues | ||
author = The AiiDAlab Team | ||
author_email = [email protected] | ||
license = MIT | ||
license_file = LICENSE.txt | ||
classifiers = | ||
Development Status :: 4 - Beta | ||
Framework :: AiiDA | ||
License :: OSI Approved :: MIT License | ||
Programming Language :: Python :: 3.7 | ||
Programming Language :: Python :: 3 | ||
Programming Language :: Python :: 3 :: Only | ||
Programming Language :: Python :: 3.8 | ||
Programming Language :: Python :: 3.9 | ||
Programming Language :: Python :: 3.10 | ||
project_urls = | ||
Bug Tracker = https://github.com/aiidalab/aiidalab-home/issues | ||
|
||
[options] | ||
packages = find: | ||
python_requires = >=3.7 | ||
install_requires = | ||
aiidalab>=v21.06.0 | ||
ipython~=7.25 | ||
Jinja2>=2.11.3,<4 | ||
Markdown>=3.4 | ||
aiidalab>=v21.10.2 | ||
ipython~=7.0 | ||
ipywidgets~=7.6 | ||
jinja2~=2.11 | ||
traitlets~=4.3 | ||
traitlets~=5.0 | ||
python_requires = >=3.8 | ||
|
||
[options.extras_require] | ||
pre_commit = | ||
pre-commit==2.15.0 | ||
|
||
[flake8] | ||
# Adapted from: https://github.com/CasperWA/voila-optimade-client | ||
ignore = | ||
E501 # Line length handled by black. | ||
W503 # Line break before binary operator, preferred formatting for black. | ||
|