From 4ce7ed6ed1044c4f9803038f58b50eb3ac804d4f Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Wed, 18 Sep 2024 11:30:03 +0200 Subject: [PATCH] set the workunit status in app_runner --- bfabric/experimental/app_interface/app_runner/runner.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bfabric/experimental/app_interface/app_runner/runner.py b/bfabric/experimental/app_interface/app_runner/runner.py index 750bd816..72078f61 100644 --- a/bfabric/experimental/app_interface/app_runner/runner.py +++ b/bfabric/experimental/app_interface/app_runner/runner.py @@ -1,4 +1,5 @@ from __future__ import annotations + import shlex import subprocess from pathlib import Path @@ -58,6 +59,11 @@ def run_app( ssh_user: str | None = None, read_only: bool = False, ) -> None: + # TODO future: the workunit definition must be loaded from bfabric exactly once! this is quite inefficient right now + workunit_definition = WorkunitDefinition.from_ref(workunit_ref, client=client) + if not read_only: + client.save("workunit", {"id": workunit_definition.registration.workunit_id, "status": "processing"}) + runner = Runner(spec=app_spec, client=client, ssh_user=ssh_user) runner.run_dispatch(workunit_ref=workunit_ref, work_dir=work_dir) chunks_file = ChunksFile.model_validate(yaml.safe_load((work_dir / "chunks.yml").read_text())) @@ -67,3 +73,6 @@ def run_app( runner.run_process(chunk_dir=chunk) if not read_only: runner.run_register_outputs(chunk_dir=chunk, workunit_ref=workunit_ref) + + if not read_only: + client.save("workunit", {"id": workunit_definition.registration.workunit_id, "status": "available"})