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

Fixtures: Add support for Process inputs to submit_and_await #5780

Merged
merged 1 commit into from
Nov 18, 2022
Merged
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
13 changes: 10 additions & 3 deletions aiida/manage/tests/pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import asyncio
import copy
import inspect
import pathlib
import shutil
import tempfile
Expand Down Expand Up @@ -288,20 +289,26 @@ def submit_and_await(started_daemon_client):
def _factory(
submittable: Process | ProcessBuilder | ProcessNode,
state: plumpy.ProcessState = plumpy.ProcessState.FINISHED,
timeout: int = 20
timeout: int = 20,
**kwargs
):
"""Submit a process and wait for it to achieve the given state.

:param submittable: A process, a process builder or a process node. If it is a process or builder, it is
submitted first before awaiting the desired state.
:param state: The process state to wait for, by default it waits for the submittable to be ``FINISHED``.
:param timeout: The time to wait for the process to achieve the state.
:param kwargs: If the ``submittable`` is a process class, it is instantiated with the ``kwargs`` as inputs.
:raises RuntimeError: If the process fails to achieve the specified state before the timeout expires.
"""
if not isinstance(submittable, ProcessNode):
if inspect.isclass(submittable) and issubclass(submittable, Process):
node = submit(submittable, **kwargs)
elif isinstance(submittable, ProcessBuilder):
node = submit(submittable)
else:
elif isinstance(submittable, ProcessNode):
node = submittable
else:
raise ValueError(f'type of submittable `{type(submittable)}` is not supported.')

start_time = time.time()

Expand Down