Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ELN widgets optional #609

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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