From 19949a68034552229dca9ad6bd2a41a951c81536 Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Thu, 6 Feb 2025 13:33:56 +0100 Subject: [PATCH] Better error when app version is not found --- bfabric_app_runner/docs/changelog.md | 4 ++++ .../src/bfabric_app_runner/app_runner/resolve_app.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/bfabric_app_runner/docs/changelog.md b/bfabric_app_runner/docs/changelog.md index 23700f8e..98fc2f61 100644 --- a/bfabric_app_runner/docs/changelog.md +++ b/bfabric_app_runner/docs/changelog.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). symlinks instead of copying the file, as needed. - `BfabricOrderFastaSpec.required` which allows specifying whether the order fasta is required or not +### Changed + +- Better error when app version is not found. + ## \[0.0.14\] - 2025-01-30 ### Fixed diff --git a/bfabric_app_runner/src/bfabric_app_runner/app_runner/resolve_app.py b/bfabric_app_runner/src/bfabric_app_runner/app_runner/resolve_app.py index 091ebb11..bde67446 100644 --- a/bfabric_app_runner/src/bfabric_app_runner/app_runner/resolve_app.py +++ b/bfabric_app_runner/src/bfabric_app_runner/app_runner/resolve_app.py @@ -22,6 +22,14 @@ def resolve_app(versions: AppSpec, workunit_definition: WorkunitDefinition) -> A raise ValueError("The workunit definition does not contain an application version.") app_version = workunit_definition.execution.raw_parameters["application_version"] # TODO graceful handling of invalid versions + if app_version in versions and versions[app_version] is not None: + return app_version + else: + msg = ( + f"application_version '{app_version}' is not defined in the app spec,\n" + f" available versions: {sorted(versions.keys())}" + ) + raise ValueError(msg) return versions[app_version]