Skip to content

Commit

Permalink
increase check interval
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Dec 2, 2024
1 parent a193376 commit a464882
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

strategy:
matrix:
python-version: ['3.11', '3.12']
python-version: ['3.9', '3.11', '3.12']
aiida-core-version: ['2.5', '2.6']

services:
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
AIIDA_WARN_v3: 1
run: |
# Have to split tests into see issue #225
pytest -m "not frontend and not backend" -v --cov==aiida-workgraph --durations=0
pytest -m "not frontend and not backend" -v --cov --durations=0
pytest -m backend -v --cov-append --durations=0
pytest -m frontend -v --cov-append --durations=0
Expand Down
7 changes: 4 additions & 3 deletions aiida_workgraph/workgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def submit(
inputs: Optional[Dict[str, Any]] = None,
wait: bool = False,
timeout: int = 60,
interval: int = 1,
metadata: Optional[Dict[str, Any]] = None,
) -> aiida.orm.ProcessNode:
"""Submit the AiiDA workgraph process and optionally wait for it to finish.
Expand All @@ -140,7 +141,7 @@ def submit(
# as long as we submit the process, it is a new submission, we should set restart_process to None
self.restart_process = None
if wait:
self.wait(timeout=timeout)
self.wait(timeout=timeout, interval=interval)
return self.process

def save(self, metadata: Optional[Dict[str, Any]] = None) -> None:
Expand Down Expand Up @@ -232,7 +233,7 @@ def get_error_handlers(self) -> Dict[str, Any]:
task["exit_codes"] = exit_codes
return error_handlers

def wait(self, timeout: int = 50, tasks: dict = None) -> None:
def wait(self, timeout: int = 50, tasks: dict = None, interval: int = 1) -> None:
"""
Periodically checks and waits for the AiiDA workgraph process to finish until a given timeout.
Args:
Expand All @@ -259,7 +260,7 @@ def wait(self, timeout: int = 50, tasks: dict = None) -> None:
finished = all(states)
else:
finished = self.state in terminating_states
time.sleep(0.5)
time.sleep(interval)
if time.time() - start > timeout:
break

Expand Down
10 changes: 5 additions & 5 deletions tests/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ def test_pause_play_task(wg_calcjob):
wg.pause_tasks(["add1"])
wg.submit()
# wait for the workgraph to launch add1
wg.wait(tasks={"add1": ["CREATED"]}, timeout=40)
wg.wait(tasks={"add1": ["CREATED"]}, timeout=40, interval=5)
assert wg.tasks["add1"].node.process_state.value.upper() == "CREATED"
assert wg.tasks["add1"].node.process_status == "Paused through WorkGraph"
# pause add2 after submit
wg.pause_tasks(["add2"])
wg.play_tasks(["add1"])
# wait for the workgraph to launch add2
wg.wait(tasks={"add2": ["CREATED"]}, timeout=40)
wg.wait(tasks={"add2": ["CREATED"]}, timeout=40, interval=5)
assert wg.tasks["add2"].node.process_state.value.upper() == "CREATED"
assert wg.tasks["add2"].node.process_status == "Paused through WorkGraph"
# I disabled the following lines because the test is not stable
# Seems the daemon is not responding to the play signal
# wg.play_tasks(["add2"])
# wg.wait()
# assert wg.tasks["add2"].outputs["sum"].value == 9
wg.play_tasks(["add2"])
wg.wait(interval=5)
assert wg.tasks["add2"].outputs["sum"].value == 9


def test_pause_play_error_handler(wg_calcjob, finished_process_node):
Expand Down

0 comments on commit a464882

Please sign in to comment.