Skip to content

Commit

Permalink
Test with aiida-core=2.5 (#599)
Browse files Browse the repository at this point in the history
* Ignore sqlalchemy warnings
* Bump test dependencies
* Remove fixture_localhost
* add FORCE_COLOR to CI
* pk -> id
  • Loading branch information
danielhollas authored May 27, 2024
1 parent 102a7f5 commit d8a95dd
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 37 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- main
pull_request:

env:
FORCE_COLOR: 1

# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
Expand All @@ -23,7 +25,8 @@ jobs:
strategy:
matrix:
browser: [Chrome, Firefox]
aiida-core-version: [2.1.2, 2.4.3] # test on the latest and the oldest supported version
# test on the latest and the oldest supported version
aiida-core-version: [2.1.2, 2.5.1]
fail-fast: false

runs-on: ubuntu-latest
Expand Down Expand Up @@ -84,7 +87,7 @@ jobs:
matrix:
python-version: ['3.9', '3.10']
# Test on the latest and oldest supported version
aiida-core-version: [2.2.2, 2.4.3]
aiida-core-version: [2.2.2, 2.5.1]
fail-fast: false

runs-on: ubuntu-latest
Expand Down
5 changes: 2 additions & 3 deletions aiidalab_widgets_base/elns.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ def _observe_node(self, _=None):
if self.node is None or self.eln is None:
return

if "eln" in self.node.extras:
info = self.node.extras["eln"]
else:
info = self.node.base.extras.get("eln", {})
if not info:
try:
q = orm.QueryBuilder().append(
orm.Node,
Expand Down
6 changes: 3 additions & 3 deletions aiidalab_widgets_base/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ExportButtonWidget(ipw.Button):
def __init__(self, process, **kwargs):
self.process = process
if "description" not in kwargs:
kwargs["description"] = f"Export workflow ({self.process.id})"
kwargs["description"] = f"Export workflow ({self.process.pk})"
if "layout" not in kwargs:
kwargs["layout"] = {}
kwargs["layout"]["width"] = "initial"
Expand All @@ -28,7 +28,7 @@ def export_aiida_subgraph(self, change=None): # pylint: disable=unused-argument

fname = os.path.join(tempfile.mkdtemp(), "export.aiida")
subprocess.call(
["verdi", "archive", "create", fname, "-N", str(self.process.id)]
["verdi", "archive", "create", fname, "-N", str(self.process.pk)]
)
with open(fname, "rb") as fobj:
b64 = base64.b64encode(fobj.read())
Expand All @@ -41,6 +41,6 @@ def export_aiida_subgraph(self, change=None): # pylint: disable=unused-argument
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
""".format(payload=payload, filename=f"export_{self.process.id}.aiida")
""".format(payload=payload, filename=f"export_{self.process.pk}.aiida")
)
display(javas)
6 changes: 3 additions & 3 deletions aiidalab_widgets_base/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def show_selected_output(self, change=None):
clear_output()
if change["new"]:
selected_output = self.process.outputs[change["new"]]
self.info.value = f"PK: {selected_output.id}"
self.info.value = f"PK: {selected_output.pk}"
display(viewer(selected_output))


Expand Down Expand Up @@ -537,7 +537,7 @@ def __init__(self, title="Running Job Output", **kwargs):
self.title = title
self.selection = ipw.Dropdown(
description="Select calculation:",
options=tuple((p.id, p) for p in get_running_calcs(self.process)),
options=tuple((p.pk, p) for p in get_running_calcs(self.process)),
style={"description_width": "initial"},
)
self.output = CalcJobOutputWidget()
Expand All @@ -551,7 +551,7 @@ def update(self):
with self.hold_trait_notifications():
old_label = self.selection.label
self.selection.options = tuple(
(str(p.id), p) for p in get_running_calcs(self.process)
(str(p.pk), p) for p in get_running_calcs(self.process)
)
# If the selection remains the same.
if old_label in self.selection.options:
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
filterwarnings = [
'error',
# This is needed since SQLAlchemy 2.0, see
# https://github.com/aiidalab/aiidalab-widgets-base/issues/605
'ignore:Object of type .* not in session, .* operation along .* will not proceed:sqlalchemy.exc.SAWarning',
'ignore::DeprecationWarning:bokeh.core.property.primitive',
'ignore:Creating AiiDA configuration:UserWarning:aiida',
'ignore:The `Code` class:aiida.common.warnings.AiidaDeprecationWarning:',
'ignore:crystal system:UserWarning:ase.io.cif',
'ignore::DeprecationWarning:ase.atoms',
# TODO: This comes from a transitive dependency of ipyoptimade
Expand All @@ -20,10 +24,7 @@ filterwarnings = [
# For some reason we get this error, see
# https://github.com/aiidalab/aiidalab-widgets-base/issues/551
'ignore:Exception ignored in:pytest.PytestUnraisableExceptionWarning:_pytest',
'ignore::DeprecationWarning:pytest_html',
'ignore::DeprecationWarning:jupyter_client',
'ignore::DeprecationWarning:selenium',
'ignore::DeprecationWarning:pytest_selenium',
]

[tool.ruff]
Expand Down
18 changes: 7 additions & 11 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,15 @@ zip_safe = False

[options.extras_require]
dev =
bumpver~=2023.1129
bumpver>=2023.1129
pgtest~=1.3
pre-commit~=3.5
# NOTE: pytest-selenium currently incompatible with pytest>=7.2
# Maybe could be made to work by installing 'py' dependency, see:
# https://docs.pytest.org/en/7.4.x/changelog.html#pytest-7-2-0-2022-10-23
pytest~=7.1.0
pytest-cov~=4.0
pytest-docker~=2.0
pytest-selenium~=4.0
pre-commit>=3.5
pytest~=8.2.0
pytest-cov~=5.0
pytest-docker~=3.0
pytest-selenium~=4.1
pytest-timeout~=2.2
selenium~=4.7.0
webdriver-manager~=3.8
selenium==4.20.0
optimade =
ipyoptimade~=0.1
smiles =
Expand Down
12 changes: 2 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@


@pytest.fixture
def fixture_localhost(aiida_localhost):
"""Return a localhost `Computer`."""
localhost = aiida_localhost
localhost.set_default_mpiprocs_per_machine(1)
return localhost


@pytest.fixture
def generate_calc_job_node(fixture_localhost):
def generate_calc_job_node(aiida_localhost):
"""Fixture to generate a mock `CalcJobNode` for testing parsers."""

def flatten_inputs(inputs, prefix=""):
Expand Down Expand Up @@ -60,7 +52,7 @@ def _generate_calc_job_node(
from plumpy import ProcessState

if computer is None:
computer = fixture_localhost
computer = aiida_localhost

filepath_folder = None

Expand Down
2 changes: 1 addition & 1 deletion tests/test_computational_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def test_aiida_code_setup(aiida_localhost):
assert code.label == "bash"
assert code.description == "Bash interpreter"
assert str(code.filepath_executable) == "/bin/bash"
assert code.get_input_plugin_name() == "core.arithmetic.add"
assert code.default_calc_job_plugin == "core.arithmetic.add"

# Reset the widget and check that a few attributes are reset.
widget.code_setup = {}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_export_button_widget(multiply_add_completed_workchain, monkeypatch, tmp

process = multiply_add_completed_workchain
button = export.ExportButtonWidget(process)
assert button.description == f"Export workflow ({process.id})"
assert button.description == f"Export workflow ({process.pk})"

# Test the export button. monkeypatch the `mkdtemp` function to return a
# temporary directory in the `tmp_path` fixture to store the export file.
Expand Down

0 comments on commit d8a95dd

Please sign in to comment.