Skip to content

Commit

Permalink
Move optimade dependency as extra dependency (aiidalab#554)
Browse files Browse the repository at this point in the history
Move the optimade-client as the extra dependency.
If it is not installed and used in the structure manage widget, a warning will popped to ask user to run pip to install the package.
  • Loading branch information
unkcpz authored Feb 16, 2024
1 parent 21dfc5d commit 089247c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ jobs:
**/requirements*.txt
- name: Install package test dependencies
# Test test will actually happened in the container, here only need to install
# the pytest-docker dependency.
# To add the dependencies to the container, we need to add them to the
# installation command in the `test_notebooks/conftest.py`.
run: pip install -e .[dev]

- name: Set jupyter token env
Expand Down Expand Up @@ -133,7 +137,7 @@ jobs:
**/requirements*.txt
- name: Install package
run: pip install -e .[dev,smiles]
run: pip install -e .[dev,smiles,optimade]

- name: Run pytest
run: pytest -v tests --cov
Expand Down
17 changes: 16 additions & 1 deletion aiidalab_widgets_base/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,22 @@ def __init__(
title: str = None,
**kwargs,
) -> None:
from optimade_client import default_parameters, query_filter, query_provider
try:
from optimade_client import default_parameters, query_filter, query_provider
except ImportError:
super().__init__(
[
ipw.HTML(
"""
<div style="margin: 10px 0; padding: 10px; background-color: #ffcc00; color: black; border-left: 6px solid #ffeb3b;">
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
&nbsp;This widget requires the <code>optimade-client</code> package to be installed.
Please run <code>pip install optimade-client</code> to install the missing package.
</div>"""
)
]
)
return

providers_header = ipw.HTML("<h4>Select a provider</h4>")
providers = query_provider.OptimadeQueryProviderWidget(
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ install_requires =
more-itertools~=8.0
pymysql~=0.9
nglview~=3.0
optimade-client==2022.9.19
spglib>=1.14,<3
vapory~=0.1.2
python_requires = >=3.8
Expand All @@ -56,6 +55,8 @@ dev =
pytest-timeout~=2.2
selenium~=4.7.0
webdriver-manager~=3.8
optimade =
optimade-client==2022.9.19
smiles =
rdkit>=2021.09.2
scikit-learn~=1.0.0
Expand Down
2 changes: 1 addition & 1 deletion tests_notebooks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def notebook_service(docker_ip, docker_services, aiidalab_exec):
aiidalab_exec("chmod -R a+rw /home/jovyan/apps/aiidalab-widgets-base", user="root")

# Install AWB with extra dependencies for SmilesWidget
aiidalab_exec("pip install --no-cache-dir .[smiles]")
aiidalab_exec("pip install --no-cache-dir .[smiles,optimade]")

# `port_for` takes a container port and returns the corresponding host port
port = docker_services.port_for("aiidalab", 8888)
Expand Down

0 comments on commit 089247c

Please sign in to comment.