Skip to content

Commit

Permalink
Merge branch 'main' into feature/aiida-control-page
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Jun 21, 2024
2 parents 15a9d10 + eddcf10 commit 885537f
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 54 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
gha-dependencies:
patterns:
- '*'
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.11

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: softprops/action-gh-release@v0.1.14
- uses: softprops/action-gh-release@v2.0.5
name: Create release.
with:
generate_release_notes: true
36 changes: 12 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,38 @@ ci:
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.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/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
- id: ruff-format
exclude: ^docs/.*
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args: [--count, --show-source, --statistics]
additional_dependencies:
- flake8-bugbear

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black, --filter-files]

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.4.0
rev: v2.5.0
hooks:
- id: setup-cfg-fmt

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.23.2
rev: 0.28.1
hooks:
- id: check-github-workflows

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
3 changes: 3 additions & 0 deletions appstore.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"%%javascript\n",
"IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
" return false;\n",
"}\n",
"if (document.getElementById('appmode-busy')) {\n",
" window.onbeforeunload = function() {return}\n",
"}"
]
},
Expand Down
6 changes: 3 additions & 3 deletions home/app_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Module that contains widgets for managing AiiDAlab applications."""

from subprocess import CalledProcessError

import ipywidgets as ipw
Expand Down Expand Up @@ -69,9 +69,9 @@ def __init__(self, *args, **kwargs):
)

super().__init__(
*args,
children=[self.installed_version, self.version_to_install, self.info],
layout={"min_width": "300px"},
*args,
**kwargs,
)

Expand Down Expand Up @@ -207,7 +207,7 @@ def __init__(self, app, minimalistic=False):
self.app.observe(
self._refresh_prereleases, names=["has_prereleases", "installed_version"]
)
self._refresh_prereleases(change=dict(owner=self.app)) # initialize
self._refresh_prereleases(change={"owner": self.app}) # initialize

children = [
ipw.HBox([self.header_warning]),
Expand Down
12 changes: 4 additions & 8 deletions home/app_store.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""AiiDAlab app store."""

import logging

import ipywidgets as ipw
Expand All @@ -21,7 +21,7 @@ def __init__(self):
self.index = load_app_registry_index()
except RuntimeError as error:
logger.warning(error)
self.index = dict(apps=[], categories=[])
self.index = {"apps": [], "categories": []}
self.output = ipw.Output()

# Apps per page.
Expand Down Expand Up @@ -120,12 +120,8 @@ def change_vis_list(self, _=None):

if self.category_filter.value:
all_apps = self.apps_to_display
self.apps_to_display = (
[]
) # clear the array that contains all the apps to be displayed
self.app_corresponding_categories = (
[]
) # create a parallel array that contains corresponding category names
self.apps_to_display = [] # clear the array that contains all the apps to be displayed
self.app_corresponding_categories = [] # create a parallel array that contains corresponding category names
# iterate over all categories
for category in self.category_filter.value:
category_key = self.category_title_key_mapping[category]
Expand Down
7 changes: 4 additions & 3 deletions home/start_page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to generate AiiDAlab home page."""

import json
from functools import wraps
from glob import glob
Expand Down Expand Up @@ -60,7 +61,7 @@ class AiidaLabHome:
def __init__(self):
self.config_fn = ".launcher.json"
self.output = ipw.Output()
self._app_widgets = dict()
self._app_widgets = {}

def _create_app_widget(self, name):
"""Create the widget representing the app on the home screen."""
Expand Down Expand Up @@ -92,7 +93,7 @@ def write_config(self, config):

def read_config(self):
if path.exists(self.config_fn):
return json.load(open(self.config_fn, "r"))
return json.load(open(self.config_fn))
return {"order": [], "hidden": []} # default config

def render(self):
Expand Down Expand Up @@ -124,7 +125,7 @@ def load_apps(self):
apps.sort(key=lambda x: order.index(x) if x in order else -1)
config["order"] = apps
self.write_config(config)
return ["home"] + apps
return ["home", *apps]

def move_updown(self, name, delta):
"""Move the app up/down on the start page."""
Expand Down
6 changes: 3 additions & 3 deletions home/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def load_start_py(name):
except TypeError:
return mod.get_start_widget(appbase=appbase, jupbase=jupbase)
except Exception: # pylint: disable=broad-except
return ipw.HTML("<pre>{}</pre>".format(sys.exc_info()))
return ipw.HTML(f"<pre>{sys.exc_info()}</pre>")


def load_start_md(name):
"""Load app appearance from a Markdown file."""
fname = path.join(AIIDALAB_APPS, name, "start.md")
try:
md_src = open(fname).read()
md_src = md_src.replace("](./", "](../{}/".format(name))
md_src = md_src.replace("](./", f"](../{name}/")
html = markdown(md_src)

# open links in new window/tab
Expand All @@ -52,7 +52,7 @@ def load_start_md(name):
return ipw.HTML(html)

except Exception as exc: # pylint: disable=broad-except
return ipw.HTML("Could not load start.md: {}".format(str(exc)))
return ipw.HTML(f"Could not load start.md: {exc!s}")


def load_logo(app):
Expand Down
3 changes: 1 addition & 2 deletions home/widgets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""AiiDAlab basic widgets."""

from threading import Timer
Expand Down Expand Up @@ -104,7 +103,7 @@ class AppStatusInfoWidget(ipw.HTML):
"and avoid compatibility isssues."
)

MESSAGES_UPDATES = {
MESSAGES_UPDATES = { # noqa: RUF012
AppStatus.CANNOT_REACH_REGISTRY: f'<div title="Unable to reach the registry server ({AIIDALAB_REGISTRY}).">'
f'<font color="{Theme.COLORS.GRAY}">{Theme.ICONS.APP_UPDATE_AVAILABLE_UNKNOWN} '
"Cannot reach server.</font></div>",
Expand Down
8 changes: 4 additions & 4 deletions open_app.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1e6a8c8c",
"id": "0",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -14,7 +14,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7e7e205e",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -43,7 +43,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b3e749de",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -55,7 +55,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c25a71a5",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand Down
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[build-system]
# this version is required to support reading of version in setup.cfg
requires = ["setuptools>=46.4.0"]
build-backend = "setuptools.build_meta"

[tool.ruff]
line-length = 88
show-fixes = true
target-version = "py38"

[tool.ruff.lint]
ignore = ["E501", "E402", "B904", "TRY003"]
select = [
"A", # flake8-builtins
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"N", # pep8-naming
"PLE", # pylint error rules
"PLW", # pylint warning rules
"PLC", # pylint convention rules
"RUF", # ruff-specific rules
"TRY", # Tryceratops
"UP" # pyupgrade
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["ARG001"]
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ install_requires =
ipywidgets~=7.6
traitlets~=5.0
widgetsnbextension<3.6.3 # Hotfix. Remove when #149 is fixed
python_requires = >=3.8
python_requires = >=3.9

[options.extras_require]
dev =
bumpver==2022.1118
pre-commit==2.15.0
pre-commit==3.6.0

[flake8]
ignore =
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf8 -*-
"""This file is required for editable installs of the package."""

from setuptools import setup

setup()
3 changes: 3 additions & 0 deletions single_app.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"%%javascript\n",
"IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
" return false;\n",
"}\n",
"if (document.getElementById('appmode-busy')) {\n",
" window.onbeforeunload = function() {return}\n",
"}"
]
},
Expand Down

0 comments on commit 885537f

Please sign in to comment.