From d1ae1cc2a93c614e696ce774b92019fa945a06b4 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 19 Nov 2024 22:06:08 +0100 Subject: [PATCH] Fix crash in single_app.ipynb from invalid version (#181) * Fix crash in single_app.ipynb from invalid version This is the same issue that I recently solved in the aiidalab and aiidalab-registry packages, see aiidalab/aiidaslab#339 and aiidalab/aiidalab-registry#103 for details. It did not occur to me that the same issue occurs here right in our AiiDAlab home! * CI: Run tests on push to main branch --- .github/workflows/ci.yml | 2 +- home/app_manager.py | 15 +++++++++------ single_app.ipynb | 12 +----------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66b2e11..b940500 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ name: continuous-integration on: push: branches: - - master + - main pull_request: env: diff --git a/home/app_manager.py b/home/app_manager.py index a18b9e7..c1c6e1b 100644 --- a/home/app_manager.py +++ b/home/app_manager.py @@ -7,7 +7,7 @@ from aiidalab.app import AppRemoteUpdateStatus as AppStatus from aiidalab.app import AppVersion from jinja2 import Template -from packaging.version import parse +from packaging.version import InvalidVersion, parse from home.utils import load_logo from home.widgets import LogOutputWidget, Spinner, StatusHTML @@ -258,11 +258,14 @@ def _refresh_prereleases(self, change): installed_version = app.installed_version has_prereleases = app.has_prereleases - prerelease_installed = ( - parse(installed_version).is_prerelease - if isinstance(installed_version, str) - else False - ) + prerelease_installed = False + if isinstance(installed_version, str): + try: + parsed_version = parse(installed_version) + except InvalidVersion: + pass + else: + prerelease_installed = parsed_version.is_prerelease with self.hold_trait_notifications(): # The checkbox can only be enabled when the app has prereleases, diff --git a/single_app.ipynb b/single_app.ipynb index c38cd6a..5657c6b 100644 --- a/single_app.ipynb +++ b/single_app.ipynb @@ -78,17 +78,7 @@ "source": [ "app_base = AiidaLabApp(name, app_data, AIIDALAB_APPS)\n", "\n", - "try:\n", - " display(AppManagerWidget(app_base, minimalistic=False))\n", - "except Exception as error:\n", - " display(\n", - " ipw.HTML(\n", - " '
'\n", - " f\"Unable to show app widget due to error: {error}\"\n", - " \"
\",\n", - " layout={\"width\": \"600px\"},\n", - " )\n", - " )" + "display(AppManagerWidget(app_base, minimalistic=False))" ] } ],