Skip to content

Commit

Permalink
Load CSS stylesheets on from aiidalab_widgets_base... import
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jul 11, 2024
1 parent a67d272 commit 2db21d2
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions aiidalab_widgets_base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Reusable widgets for AiiDAlab applications."""

from aiida.manage import get_profile

_WARNING_TEMPLATE = """
<div style="background-color: #f7f7f7; border: 2px solid #e0e0e0; padding: 20px; border-radius: 5px;">
<p style="font-size: 16px; font-weight: bold; color: #ff5733;">Warning:</p>
Expand All @@ -27,22 +25,31 @@ def is_running_in_jupyter():
return False


# load the default profile if no profile is loaded, and raise a deprecation warning
# this is a temporary solution to avoid breaking existing notebooks
# this will be removed in the next major release
if is_running_in_jupyter() and get_profile() is None:
# if no profile is loaded, load the default profile and raise a deprecation warning
from aiida import load_profile
if is_running_in_jupyter():
from aiida.manage import get_profile
from IPython.display import HTML, display

load_profile()
# load the default profile if no profile is loaded, and raise a deprecation warning
# this is a temporary solution to avoid breaking existing notebooks
# this will be removed in the next major release
if get_profile() is None:
# if no profile is loaded, load the default profile and raise a deprecation warning
from aiida import load_profile

load_profile()

profile = get_profile()
assert profile is not None, "Failed to load the default profile"

# raise a deprecation warning
warning = HTML(_WARNING_TEMPLATE.format(profile=profile.name, version="v3.0.0"))
display(warning)

from .static import styles
from .utils.loaders import load_css_stylesheet

profile = get_profile()
assert profile is not None, "Failed to load the default profile"
load_css_stylesheet(package=styles)

# raise a deprecation warning
warning = HTML(_WARNING_TEMPLATE.format(profile=profile.name, version="v3.0.0"))
display(warning)

from .computational_resources import (
ComputationalResourcesWidget,
Expand Down

0 comments on commit 2db21d2

Please sign in to comment.