Skip to content

Commit

Permalink
Make ELN widgets optional (#609)
Browse files Browse the repository at this point in the history
Move `aiidalab-eln` dependency into a new `eln` extras.
  • Loading branch information
danielhollas authored May 31, 2024
1 parent d8a95dd commit df106c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
# Ideally, these would be fixed, but vapory is largely unmaintained,
# so here we simply keep the pip behaviour with the --compile flag.
# See https://github.com/astral-sh/uv/issues/1928#issuecomment-1968857514
run: uv pip install --compile --system .[dev,smiles,optimade] aiida-core==${{ matrix.aiida-core-version }}
run: uv pip install --compile --system .[dev,smiles,optimade,eln] aiida-core==${{ matrix.aiida-core-version }}

- name: Run pytest
run: pytest -v tests --cov
Expand Down
17 changes: 16 additions & 1 deletion aiidalab_widgets_base/elns.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import requests_cache
import traitlets as tl
from aiida import orm
from aiidalab_eln import get_eln_connector
from IPython.display import clear_output, display

ELN_CONFIG = Path.home() / ".aiidalab" / "aiidalab-eln-config.json"
Expand All @@ -15,6 +14,13 @@


def connect_to_eln(eln_instance=None, **kwargs):
try:
from aiidalab_eln import get_eln_connector
except ImportError:
return (
None,
"AiiDAlab-ELN connector not installed. Install with `pip install aiidalab-eln`",
)
# assuming that the connection can only be established to the ELNs
# with the stored configuration.
try:
Expand Down Expand Up @@ -276,6 +282,15 @@ def check_connection(self, _=None):

def display_eln_config(self, value=None):
"""Display ELN configuration specific to the selected type of ELN."""
try:
from aiidalab_eln import get_eln_connector
except ImportError:
with self._output:
clear_output()
msg = "AiiDAlab-ELN connector not installed. Install with `pip install aiidalab-eln`"
display(ipw.HTML(f"❌ {msg}"))
return

try:
eln_class = get_eln_connector(self.eln_types.value)
except NotImplementedError as err:
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ install_requires =
PyCifRW~=4.4
aiida-core>=2.1,<3
aiidalab>=21.11.2
aiidalab-eln>=0.1.2,~=0.1
ansi2html~=1.6
ase~=3.18
bokeh~=2.0
Expand Down Expand Up @@ -54,6 +53,8 @@ dev =
selenium==4.20.0
optimade =
ipyoptimade~=0.1
eln =
aiidalab-eln>=0.1.2,~=0.1
smiles =
rdkit>=2021.09.2
scikit-learn~=1.0.0
Expand Down

0 comments on commit df106c5

Please sign in to comment.