Skip to content

Commit

Permalink
fix max number of running process
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Dec 1, 2024
1 parent ec17796 commit 521ba97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions aiida_workgraph/engine/awaitable_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def resolve_awaitable(self, awaitable: Awaitable, value: Any) -> None:
raise AssertionError(f"Unsupported awaitable action: {awaitable.action}")

awaitable.resolved = True
# remove awaitabble from the list
self._awaitables = [a for a in self._awaitables if a.pk != awaitable.pk]
# remove awaitabble from the list, and use the same list reference
self._awaitables[:] = [a for a in self._awaitables if a.pk != awaitable.pk]

if not self.process.has_terminated():
# the process may be terminated, for example, if the process was killed or excepted
Expand Down
4 changes: 3 additions & 1 deletion tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_reset_node(wg_engine: WorkGraph) -> None:
assert len(wg.process.base.extras.get("_workgraph_queue")) == 1


@pytest.mark.usefixtures("started_daemon_client")
def test_max_number_jobs(add_code) -> None:
from aiida_workgraph import WorkGraph
from aiida.orm import Int
Expand All @@ -46,6 +47,7 @@ def test_max_number_jobs(add_code) -> None:
)
# Set the maximum number of running jobs inside the WorkGraph
wg.max_number_jobs = 2
wg.submit(wait=True, timeout=100)
wg.submit(wait=True, timeout=40)
report = get_workchain_report(wg.process, "REPORT")
assert "tasks ready to run: add2" in report
wg.tasks["add2"].outputs["sum"].value == 2
2 changes: 1 addition & 1 deletion tests/test_workgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_pause_play_task(wg_calcjob):
wg.pause_tasks(["add2"])
wg.play_tasks(["add1"])
# wait for the workgraph to launch add2
wg.wait(tasks={"add2": ["CREATED"]}, timeout=20)
wg.wait(tasks={"add2": ["CREATED"]}, timeout=40)
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
Expand Down

0 comments on commit 521ba97

Please sign in to comment.