Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test with aiida-core=2.5 #599

Merged
merged 26 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 15 additions & 18 deletions aiidalab_widgets_base/elns.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,21 @@ 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:
try:
q = orm.QueryBuilder().append(
orm.Node,
filters={"extras": {"has_key": "eln"}},
tag="source_node",
project="extras.eln",
)
q.append(
orm.Node,
filters={"uuid": self.node.uuid},
with_ancestors="source_node",
)
info = q.all(flat=True)[0]
except IndexError:
info = {}
if not (info := self.node.base.extras.get("eln", {})):
q = orm.QueryBuilder().append(
orm.Node,
filters={"extras": {"has_key": "eln"}},
tag="source_node",
project="extras.eln",
)
q.append(
orm.Node,
filters={"uuid": self.node.uuid},
with_ancestors="source_node",
)
res = q.all(flat=True)
if len(res) > 0:
info = res[0]

self.eln.set_sample_config(**info)

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
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
filterwarnings = [
'error',
# https://github.com/aiidalab/aiidalab-widgets-base/issues/605
'ignore:Object of type <DbNode> not in session: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 +23,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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the source code of the aiida_localhost fixture, and it seems to set this up by default, so I am not sure why this was here...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember the fixture was directly copied from https://github.com/aiidateam/aiida-quantumespresso/blob/7b6c210a80942aed8ed08fa78f0d123d3227e750/tests/conftest.py#L42
Maybe it is not needed anymore? Then we can also remove it from aiida-quantumespresso.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good to know, thanks. Looking at git blame, that fixture is five years old, so indeed most likely can be removed from there as well.

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