From 97809c7d928ff0db297a44ea0e52251ae7328a5b Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Fri, 27 Sep 2024 10:22:22 +0200 Subject: [PATCH] improve the reuse default resource logic --- .../app_interface/output_registration/register.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bfabric/experimental/app_interface/output_registration/register.py b/src/bfabric/experimental/app_interface/output_registration/register.py index 971b306a..8816dff2 100644 --- a/src/bfabric/experimental/app_interface/output_registration/register.py +++ b/src/bfabric/experimental/app_interface/output_registration/register.py @@ -75,10 +75,10 @@ def find_default_resource_id(workunit: Workunit) -> int | None: candidate_resources = [ resource for resource in workunit.resources if resource["name"] not in ["slurm_stdout", "slurm_stderr"] ] - if len(candidate_resources) != 1: - return None - else: + # We also check that the resource is pending, as else we might re-use a resource that was created by the app... + if len(candidate_resources) == 1 and candidate_resources[0]["status"] == "pending": return candidate_resources[0].id + return None def register_all(