diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acb62f926..cc5ec9c17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/aiidalab_widgets_base/databases.py b/aiidalab_widgets_base/databases.py index 9b7bd149a..5ca7b41e3 100644 --- a/aiidalab_widgets_base/databases.py +++ b/aiidalab_widgets_base/databases.py @@ -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( + """ +
+ +  This widget requires the optimade-client package to be installed. + Please run pip install optimade-client to install the missing package. +
""" + ) + ] + ) + return providers_header = ipw.HTML("

Select a provider

") providers = query_provider.OptimadeQueryProviderWidget( diff --git a/setup.cfg b/setup.cfg index 97de33e0f..ad6e95c5e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 @@ -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 diff --git a/tests_notebooks/conftest.py b/tests_notebooks/conftest.py index 5d94186bc..3992340d0 100644 --- a/tests_notebooks/conftest.py +++ b/tests_notebooks/conftest.py @@ -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)