diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e727c0878..d4e533255 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,7 @@ concurrency: env: FORCE_COLOR: 1 + UV_VERSION: 0.3.0 jobs: @@ -20,9 +21,8 @@ jobs: strategy: matrix: - tag: [latest] - python-version: ['3.9', '3.10'] - aiida-core-version: [2.3, 2.5] + python-version: ['3.9', '3.11'] + aiida-core-version: ['2.3', '2.6'] fail-fast: false runs-on: ubuntu-latest @@ -45,15 +45,16 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install uv - run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.2.13/uv-installer.sh | sh + run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/${{ env.UV_VERSION }}/uv-installer.sh | sh - name: Install package run: uv pip install --system -e .[dev] aiida-core==${{ matrix.aiida-core-version }} - name: Run pytest - run: pytest -v tests --cov=aiidalab_qe - env: - TAG: ${{ matrix.tag }} + # Only collect code coverage with aiida-core=2.3, to speed up tests + # with higher aiida versions that for some reason run slower, see: + # https://github.com/aiidalab/aiidalab-qe/issues/766 + run: pytest -v tests ${{ matrix.aiida-core-version == '2.3' && '--cov=aiidalab_qe' || '' }} - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 658562e09..7a5a29698 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: - id: nbstripout - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.5 + rev: v0.6.1 hooks: - id: ruff types_or: [python, pyi, jupyter] diff --git a/README.md b/README.md index 59eca0b83..9172dd71e 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ Additional notes: ## Acknowledgements We acknowledge support from: * the European Union\'s Horizon 2020 research and innovation programme (Grant No. 957189, [project BIG-MAP](https://www.big-map.eu)). -* the [MARVEL National Centre for Competency in Research]() funded by the [Swiss National Science Foundation](). +* the [MARVEL National Centre for Competency in Research](https://nccr-marvel.ch/) funded by the [Swiss National Science Foundation](https://www.snf.ch/en). * the MARKETPLACE project funded by [Horizon 2020](https://ec.europa.eu/programmes/horizon2020/) under the H2020-NMBP-25-2017 call (Grant No. 760173). -* the [MaX European Centre of Excellence]() funded by the Horizon 2020 EINFRA-5 program (Grant No. 676598). +* the [MaX European Centre of Excellence](https://www.max-centre.eu/) funded by the Horizon 2020 EINFRA-5 program (Grant No. 676598).
MARVEL diff --git a/pyproject.toml b/pyproject.toml index dd0525383..fc5478f42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,12 +5,22 @@ requires = [ ] build-backend = "setuptools.build_meta" +[tool.pytest.ini_options] +addopts = '--strict-config --strict-markers --durations=30 --durations-min=1 -ra' +filterwarnings = [ + 'ignore:Object of type .* not in session, .* operation along .* will not proceed:', + 'ignore:Creating AiiDA configuration:UserWarning:', + 'ignore:metadata.*traitlets.traitlets.Unicode object:DeprecationWarning:', + # For some reason we get this error, see + # https://github.com/aiidalab/aiidalab-widgets-base/issues/551 + 'ignore:Exception ignored in:pytest.PytestUnraisableExceptionWarning:_pytest', +] + [tool.ruff] line-length = 88 show-fixes = true output-format = "full" target-version = "py39" -extend-include = ["*.ipynb"] [tool.ruff.lint] ignore = ["E501", "E402", "TRY003", "RUF012", "N806"] diff --git a/qe.ipynb b/qe.ipynb index cac6b0014..bd76c667e 100644 --- a/qe.ipynb +++ b/qe.ipynb @@ -42,12 +42,12 @@ "from datetime import datetime\n", "\n", "import ipywidgets as ipw\n", - "from aiidalab_qe.app import App, static\n", - "from aiidalab_qe.version import __version__\n", "from importlib_resources import files\n", "from IPython.display import display\n", "from jinja2 import Environment\n", "\n", + "from aiidalab_qe.app import App, static\n", + "from aiidalab_qe.version import __version__\n", "from aiidalab_widgets_base.bug_report import (\n", " install_create_github_issue_exception_handler,\n", ")" diff --git a/setup.cfg b/setup.cfg index 43eef8f43..ebab1ee38 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,10 +40,10 @@ where = src dev = bumpver~=2023.1124 pre-commit~=3.2 - pytest~=6.2 + pytest~=7.4 pytest-regressions~=2.2 pgtest==1.3.1 - pytest-cov~=4.0 + pytest-cov~=5.0 [options.package_data] aiidalab_qe.app.parameters = qeapp.yaml diff --git a/tests/configuration/test_advanced.py b/tests/configuration/test_advanced.py index 800436bd7..7891db223 100644 --- a/tests/configuration/test_advanced.py +++ b/tests/configuration/test_advanced.py @@ -120,9 +120,8 @@ def test_advanced_tot_charge_settings(): def test_advanced_kpoints_mesh(): """Test Mesh Grid HTML widget.""" - from aiidalab_qe.app.configuration.advanced import AdvancedSettings - from aiida import orm + from aiidalab_qe.app.configuration.advanced import AdvancedSettings w = AdvancedSettings() diff --git a/tests/conftest.py b/tests/conftest.py index 6c3e98e7d..316445d32 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,9 +5,9 @@ import tempfile import pytest -from aiidalab_qe.setup.pseudos import SSSP_VERSION from aiida import orm +from aiidalab_qe.setup.pseudos import SSSP_VERSION pytest_plugins = ["aiida.manage.tests.pytest_fixtures"] @@ -630,12 +630,11 @@ def _generate_qeapp_workchain( ): from copy import deepcopy + from aiida.orm.utils.serialize import serialize from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep from aiidalab_qe.app.submission import SubmitQeAppWorkChainStep from aiidalab_qe.workflows import QeAppWorkChain - from aiida.orm.utils.serialize import serialize - # Step 1: select structure from example s1 = app.structure_step if structure is None: diff --git a/tests/test_cli.py b/tests/test_cli.py index d3076fe2c..93cb52229 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,9 +1,9 @@ import time -import aiidalab_qe.__main__ as cli from click.testing import CliRunner, Result import aiida +import aiidalab_qe.__main__ as cli # To learn more about testing click applications, see: https://click.palletsprojects.com/en/8.1.x/testing/ diff --git a/tests/test_plugins_bands.py b/tests/test_plugins_bands.py index b3c2a9dc8..aaa34225a 100644 --- a/tests/test_plugins_bands.py +++ b/tests/test_plugins_bands.py @@ -4,6 +4,7 @@ @pytest.mark.usefixtures("sssp") def test_result(generate_qeapp_workchain): import plotly.graph_objects as go + from aiidalab_qe.common.bandpdoswidget import BandPdosWidget from aiidalab_qe.plugins.bands.result import Result diff --git a/tests/test_plugins_electronic_structure.py b/tests/test_plugins_electronic_structure.py index 271adfd1b..c64c4e778 100644 --- a/tests/test_plugins_electronic_structure.py +++ b/tests/test_plugins_electronic_structure.py @@ -1,12 +1,12 @@ def test_electronic_structure(generate_qeapp_workchain): """Test the electronic structure tab.""" import plotly.graph_objects as go + + from aiida import engine from aiidalab_qe.app.result.workchain_viewer import WorkChainViewer from aiidalab_qe.common.bandpdoswidget import BandPdosWidget from aiidalab_qe.plugins.electronic_structure.result import Result - from aiida import engine - wkchain = generate_qeapp_workchain() wkchain.node.set_exit_status(0) wkchain.node.set_process_state(engine.ProcessState.FINISHED) diff --git a/tests/test_plugins_pdos.py b/tests/test_plugins_pdos.py index 426393694..3fda29b76 100644 --- a/tests/test_plugins_pdos.py +++ b/tests/test_plugins_pdos.py @@ -4,6 +4,7 @@ @pytest.mark.usefixtures("sssp") def test_result(generate_qeapp_workchain): import plotly.graph_objects as go + from aiidalab_qe.common.bandpdoswidget import BandPdosWidget from aiidalab_qe.plugins.pdos.result import Result diff --git a/tests/test_plugins_xps.py b/tests/test_plugins_xps.py index 8f15c3b80..91e0633a5 100644 --- a/tests/test_plugins_xps.py +++ b/tests/test_plugins_xps.py @@ -5,10 +5,10 @@ def test_settings(): """Test the settings of the xps app.""" - from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep from ase.build import molecule from aiida.orm import StructureData + from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep configure_step = ConfigureQeAppWorkChainStep() # set the input structure diff --git a/tests/test_pseudo.py b/tests/test_pseudo.py index 4aa971922..ce2481928 100644 --- a/tests/test_pseudo.py +++ b/tests/test_pseudo.py @@ -1,4 +1,6 @@ import pytest + +from aiida import orm from aiidalab_qe.setup.pseudos import ( PSEUDODOJO_VERSION, SSSP_VERSION, @@ -7,8 +9,6 @@ pseudos_to_install, ) -from aiida import orm - def test_setup_pseudos_cmd(tmp_path): """Test _construct_cmd function in setup.pseudos""" diff --git a/tests/test_result.py b/tests/test_result.py index 9deb51f0a..c6e087d17 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -43,9 +43,10 @@ def test_summary_report_advanced_settings(data_regression, generate_qeapp_workch def test_summary_view(generate_qeapp_workchain): """Test the report html can be properly generated.""" - from aiidalab_qe.app.result.summary_viewer import SummaryView from bs4 import BeautifulSoup + from aiidalab_qe.app.result.summary_viewer import SummaryView + wkchain = generate_qeapp_workchain() viewer = SummaryView(wkchain.node) report_html = viewer.report_html