Skip to content

Commit

Permalink
Fix crash in single_app.ipynb from invalid version
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
danielhollas committed Nov 19, 2024
1 parent 2b6ea6d commit ca71baa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions aiidalab
19 changes: 11 additions & 8 deletions home/app_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import ipywidgets as ipw
import traitlets
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 aiidalab.app import AppRemoteUpdateStatus as AppStatus
from aiidalab.app import AppVersion
from home.utils import load_logo
from home.widgets import LogOutputWidget, Spinner, StatusHTML

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions segfault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from home.app_store import AiidaLabAppStore

store = AiidaLabAppStore()
9 changes: 1 addition & 8 deletions single_app.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,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: # pylint: disable=broad-except\n",
" display(ipw.HTML(\n",
" '<div style=\"font-size: 30px; text-align:center;\">'\n",
" f'Unable to show app widget due to error: {error}'\n",
" '</div>',\n",
" layout={'width': '600px'}))"
"display(AppManagerWidget(app_base, minimalistic=False))"
]
}
],
Expand Down

0 comments on commit ca71baa

Please sign in to comment.