Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 9 additions & 3 deletions aiidalab_widgets_base/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ def export_aiida_subgraph(self, change=None): # pylint: disable=unused-argument
from IPython.display import Javascript, display

fname = os.path.join(tempfile.mkdtemp(), "export.aiida")
subprocess.call(
["verdi", "archive", "create", fname, "-N", str(self.process.pk)]
)
try:
subprocess.check_output(
["verdi", "archive", "create", fname, "-N", str(self.process.pk)],
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError as e:
print(e)
print(e.output)
raise
with open(fname, "rb") as fobj:
b64 = base64.b64encode(fobj.read())
payload = b64.decode()
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ zip_safe = False
[options.extras_require]
dev =
bumpver>=2023.1129
packaging>=22.0
pgtest~=1.3
pre-commit>=3.5
pytest~=8.3.0
Expand Down
58 changes: 51 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,49 @@

import numpy as np
import pytest
from aiida import __version__ as aiida_version
from aiida import engine, orm, plugins
from packaging.version import Version

pytest_plugins = ["aiida.manage.tests.pytest_fixtures"]
# Load aiida's pytest fixtures
# For aiida-core>=2.6 we load new fixtures which use sqlite backend.
if Version(aiida_version) >= Version("2.6.0"):
pytest_plugins = ["aiida.tools.pytest_fixtures"]

@pytest.fixture(scope="session")
def aiida_profile(aiida_config, aiida_profile_factory, config_sqlite_dos):
"""Create and load a profile with ``core.psql_dos`` as a storage backend and RabbitMQ as the broker.

This overrides the ``aiida_profile`` fixture provided by ``aiida-core`` which runs with ``core.sqlite_dos`` and
without broker. However, tests in this package make use of the daemon which requires a broker and the tests should
be run against the main storage backend, which is ``core.sqlite_dos``.
"""
broker = "core.rabbitmq"

storage = "core.sqlite_dos"
config = config_sqlite_dos()

with aiida_profile_factory(
aiida_config,
storage_backend=storage,
storage_config=config,
broker_backend=broker,
) as profile:
yield profile

else:
pytest_plugins = ["aiida.manage.tests.pytest_fixtures"]

@pytest.fixture
def aiida_code_installed(aiida_local_code_factory):
def _code(filepath_executable, default_calc_job_plugin, label=None):
return aiida_local_code_factory(
executable=filepath_executable,
entry_point=default_calc_job_plugin,
label=label,
)

return _code


@pytest.fixture
Expand Down Expand Up @@ -270,9 +310,11 @@ def folder_data_object():


@pytest.fixture
def aiida_local_code_bash(aiida_local_code_factory):
"""Return a `Code` configured for the bash executable."""
return aiida_local_code_factory(executable="bash", entry_point="bash")
def aiida_local_code_bash(aiida_code_installed):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new fixtures have aiida_code_installed instead of aiida_local_code_factory.

"""Return `InstalledCode` configured for bash executable."""
return aiida_code_installed(
filepath_executable="/bin/bash", default_calc_job_plugin="bash"
)


@pytest.fixture
Expand Down Expand Up @@ -339,9 +381,11 @@ def get(self):


@pytest.fixture
def pw_code(aiida_local_code_factory):
def pw_code(aiida_code_installed):
"""Return a `Code` configured for the pw.x executable."""

return aiida_local_code_factory(
label="pw", executable="bash", entry_point="quantumespresso.pw"
return aiida_code_installed(
label="pw",
filepath_executable="/bin/bash",
default_calc_job_plugin="quantumespresso.pw",
)
2 changes: 0 additions & 2 deletions tests/test_viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ def test_structure_data_viewer_storage(monkeypatch, tmp_path, structure_data_obj
-1.6859999895095825, -1.6859999895095825, -0.6669999957084656, 1,
]
# fmt: on
# Avoid producing temporary files from povray in the repo
monkeypatch.chdir(tmp_path)
v._render_structure()

# Make sure we don't polute current working dir with tempfiles
Expand Down