diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ae8cae18..85e6189e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,6 @@ concurrency: jobs: pre-commit: - # Adapted from: https://github.com/CasperWA/voila-optimade-client runs-on: ubuntu-latest @@ -32,11 +31,7 @@ jobs: **/pyproject.toml **/requirements*.txt - - name: Install dependencies - run: python -m pip install pre-commit~=2.20 - - - name: Run pre-commit - run: pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) + - uses: pre-commit/action@v3.0.0 test-package: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 462cd85bb..c53412e0f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python 3.10 uses: actions/setup-python@v2 diff --git a/pyproject.toml b/pyproject.toml index 1eb0ca77d..cf6e5fffe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,3 +4,42 @@ requires = [ "wheel" ] build-backend = "setuptools.build_meta" + +[tool.pytest.ini_options] +filterwarnings = [ + 'error', + 'ignore:Creating AiiDA configuration:UserWarning:aiida', + # For some reason we get this error, perhaps because we do + # not unload the AiiDA profile? Let's ignore this for now. + # E pytest.PytestUnraisableExceptionWarning: Exception ignored in: + # E Traceback (most recent call last): + # E File "/opt/conda/lib/python3.9/subprocess.py", line 1052, in __del__ + # E _warn("subprocess %s is still running" % self.pid, + # E ResourceWarning: subprocess 382685 is still running + 'ignore:Exception ignored in:pytest.PytestUnraisableExceptionWarning:_pytest', + # TODO: This comes from a transitive dependency of optimade_client + # Remove this when this issue is addressed: + # https://github.com/CasperWA/ipywidgets-extended/issues/85 + 'ignore::DeprecationWarning:ipywidgets_extended', + # TODO: StructureManagerWidget pass arguments by kwargs to StructureDataViewer and will be deprecated. + # E DeprecationWarning: Passing unrecognized arguments to super(StructureManagerWidget).__init__(configuration_tabs=['Cell', 'Selection', 'Appearance', 'Download']). + # E object.__init__() takes exactly one argument (the instance to initialize) + # E This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets. + 'ignore::DeprecationWarning:ipywidgets', + 'ignore::DeprecationWarning:ase.atoms', + # TODO: bandsplot_widget has an issue in schema validation + # > result._update_view() + # + # tests/test_plugins_bands.py:12: + # _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + # src/aiidalab_qe/plugins/bands/result.py:40: in _update_view + # _bands_plot_view = BandsPlotWidget( + # ../../.local/lib/python3.9/site-packages/widget_bandsplot/bandsplot.py:112: in __init__ + # validate(instance=i, schema=BANDS_SCHEMA) + # /opt/conda/lib/python3.9/site-packages/jsonschema/validators.py:928: in validate + # cls = validator_for(schema) + 'ignore::DeprecationWarning:jsonschema', + # TODO: use uuid instead of node object in WorkChainViewer. + # Otherwise, the `Instance '' is not persistent within this Session` exception is raised. + 'ignore::pytest.PytestUnhandledThreadExceptionWarning:_pytest', +] diff --git a/setup.cfg b/setup.cfg index 606a21fa5..0b94e8d2c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,7 +27,7 @@ install_requires = aiida-core~=2.2,<3 Jinja2~=3.0 aiida-quantumespresso~=4.3.0 - aiidalab-widgets-base~=2.0.2 + aiidalab-widgets-base==2.1.0a0 filelock~=3.8 importlib-resources~=5.2 widget-bandsplot~=0.5.1 diff --git a/src/aiidalab_qe/app/configuration/advanced.py b/src/aiidalab_qe/app/configuration/advanced.py index 1279cb7a2..01e2284f2 100644 --- a/src/aiidalab_qe/app/configuration/advanced.py +++ b/src/aiidalab_qe/app/configuration/advanced.py @@ -39,6 +39,7 @@ class AdvancedSettings(Panel): # protocol interface protocol = tl.Unicode(allow_none=True) + # TODO: (unckpz) the DbNode persistence issue will be raised if using AiiDA Node as the trait. input_structure = tl.Instance(orm.StructureData, allow_none=True) spin_type = tl.Unicode() electronic_type = tl.Unicode() diff --git a/src/aiidalab_qe/app/result/workchain_viewer.py b/src/aiidalab_qe/app/result/workchain_viewer.py index 47c2212d8..8d5f589d6 100644 --- a/src/aiidalab_qe/app/result/workchain_viewer.py +++ b/src/aiidalab_qe/app/result/workchain_viewer.py @@ -111,11 +111,11 @@ def toggle_camera(): **kwargs, ) self._process_monitor = ProcessMonitor( - process=self.node, callbacks=[ self._update_view, ], ) + self._process_monitor.value = self.node.uuid def _update_view(self): with self.hold_trait_notifications(): diff --git a/src/aiidalab_qe/common/widgets.py b/src/aiidalab_qe/common/widgets.py index 8360ce783..fae5cee90 100644 --- a/src/aiidalab_qe/common/widgets.py +++ b/src/aiidalab_qe/common/widgets.py @@ -245,7 +245,7 @@ def _observe_value(self, change): class CalcJobOutputFollower(traitlets.HasTraits): calcjob_uuid = traitlets.Unicode(allow_none=True) filename = traitlets.Unicode(allow_none=True) - output = traitlets.List(trait=traitlets.Unicode) + output = traitlets.List(trait=traitlets.Unicode()) lineno = traitlets.Int() def __init__(self, **kwargs): @@ -430,8 +430,8 @@ class AddingTagsEditor(ipw.VBox): """Editor for adding tags to atoms.""" structure = traitlets.Instance(ase.Atoms, allow_none=True) - selection = traitlets.List(traitlets.Int, allow_none=True) - input_selection = traitlets.List(traitlets.Int, allow_none=True) + selection = traitlets.List(traitlets.Int(), allow_none=True) + input_selection = traitlets.List(traitlets.Int(), allow_none=True) structure_node = traitlets.Instance(orm_Data, allow_none=True, read_only=True) def __init__(self, title=""): diff --git a/tests/conftest.py b/tests/conftest.py index 3f4a6fbfa..e9a8eac67 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import pathlib import tempfile @@ -301,15 +303,10 @@ def app(pw_code, dos_code, projwfc_code): app.submit_step.pw_code.refresh() app.submit_step.codes["dos"].refresh() app.submit_step.codes["projwfc"].refresh() - app.submit_step.pw_code.value = ( - app.submit_step.pw_code.code_select_dropdown.options[pw_code.full_label] - ) - app.submit_step.codes["dos"].value = app.submit_step.codes[ - "dos" - ].code_select_dropdown.options[dos_code.full_label] - app.submit_step.codes["projwfc"].value = app.submit_step.codes[ - "projwfc" - ].code_select_dropdown.options[projwfc_code.full_label] + + app.submit_step.pw_code.value = pw_code.uuid + app.submit_step.codes["dos"].value = dos_code.uuid + app.submit_step.codes["projwfc"].value = projwfc_code.uuid yield app @@ -558,12 +555,15 @@ def _generate_bands_workchain(structure): @pytest.fixture def generate_qeapp_workchain( - app, generate_workchain, generate_pdos_workchain, generate_bands_workchain + app, + generate_workchain, + generate_pdos_workchain, + generate_bands_workchain, ): """Generate an instance of the WorkChain.""" def _generate_qeapp_workchain( - structure=None, + structure: orm.StructureData | None = None, relax_type="positions_cell", run_bands=True, run_pdos=True, @@ -580,17 +580,13 @@ def _generate_qeapp_workchain( s1 = app.structure_step if structure is None: from_example = s1.manager.children[0].children[3] + # TODO: (unkpcz) using options to set value in test is cranky, instead, use fixture which will make the test more static and robust. from_example.children[0].value = from_example.children[0].options[1][1] else: structure.store() aiida_database = s1.manager.children[0].children[2] aiida_database.search() - key = [ - key - for key in aiida_database.results.options - if key.startswith(f"PK: {structure.pk}") - ][0] - aiida_database.results.value = aiida_database.results.options[key] + aiida_database.results.value = structure s1.confirm() structure = s1.confirmed_structure # step 2 configure diff --git a/tests/test_plugins_bands.py b/tests/test_plugins_bands.py index a5cd895b5..8dcd10013 100644 --- a/tests/test_plugins_bands.py +++ b/tests/test_plugins_bands.py @@ -4,7 +4,6 @@ def test_result(generate_qeapp_workchain): from aiidalab_qe.plugins.bands.result import Result, export_bands_data wkchain = generate_qeapp_workchain() - # data = export_bands_data(wkchain.node.outputs.bands) assert data is not None # generate structure for scf calculation diff --git a/tests/test_result.py b/tests/test_result.py index 2a4c17f1d..e67216f38 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -76,5 +76,5 @@ def test_summary_view(generate_qeapp_workchain): "Initial Magnetic Moments": "", } for key, value in parameters.items(): - td = parsed.find("td", text=key).find_next_sibling("td") + td = parsed.find("td", string=key).find_next_sibling("td") assert td.text == value