diff --git a/bfabric_app_runner/docs/changelog.md b/bfabric_app_runner/docs/changelog.md index 04111342..23700f8e 100644 --- a/bfabric_app_runner/docs/changelog.md +++ b/bfabric_app_runner/docs/changelog.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - New input type `file` which replaces `file_scp` and preserves timestamps whenever possible and allows to create symlinks instead of copying the file, as needed. +- `BfabricOrderFastaSpec.required` which allows specifying whether the order fasta is required or not ## \[0.0.14\] - 2025-01-30 diff --git a/bfabric_app_runner/src/bfabric_app_runner/input_preparation/prepare.py b/bfabric_app_runner/src/bfabric_app_runner/input_preparation/prepare.py index 6243443a..98c3a07b 100644 --- a/bfabric_app_runner/src/bfabric_app_runner/input_preparation/prepare.py +++ b/bfabric_app_runner/src/bfabric_app_runner/input_preparation/prepare.py @@ -109,12 +109,22 @@ def prepare_dataset(self, spec: BfabricDatasetSpec) -> None: dataset.write_csv(path=target_path, separator=spec.separator) def prepare_order_fasta(self, spec: BfabricOrderFastaSpec) -> None: + # Determine the result file. + result_name = self._working_dir / spec.filename + result_name.parent.mkdir(exist_ok=True, parents=True) + # Find the order. match spec.entity: case "workunit": workunit = Workunit.find(id=spec.id, client=self._client) if not isinstance(workunit.container, Order): - raise ValueError(f"Workunit {workunit.id} is not associated with an order") + msg = f"Workunit {workunit.id} is not associated with an order" + if spec.required: + raise ValueError(msg) + else: + logger.warning(msg) + result_name.write_text("") + return order = workunit.container case "order": order = Order.find(id=spec.id, client=self._client) @@ -122,8 +132,6 @@ def prepare_order_fasta(self, spec: BfabricOrderFastaSpec) -> None: assert_never(spec.entity) # Write the result into the file - result_name = self._working_dir / spec.filename - result_name.parent.mkdir(exist_ok=True, parents=True) fasta_content = order.data_dict.get("fastasequence", "") if fasta_content and fasta_content[-1] != "\n": fasta_content += "\n" diff --git a/bfabric_app_runner/src/bfabric_app_runner/specs/inputs/bfabric_order_fasta_spec.py b/bfabric_app_runner/src/bfabric_app_runner/specs/inputs/bfabric_order_fasta_spec.py index ee63e439..82ea5762 100644 --- a/bfabric_app_runner/src/bfabric_app_runner/specs/inputs/bfabric_order_fasta_spec.py +++ b/bfabric_app_runner/src/bfabric_app_runner/specs/inputs/bfabric_order_fasta_spec.py @@ -16,6 +16,7 @@ class BfabricOrderFastaSpec(BaseModel): id: int entity: Literal["workunit", "order"] filename: RelativeFilePath + required: bool = False def resolve_filename(self, client: Bfabric) -> str: return self.filename