From 5d7a647b0e0c6087a67bbb8bb69ee34636d40609 Mon Sep 17 00:00:00 2001 From: Maria Lainez <98marialainez@gmail.com> Date: Tue, 5 Nov 2024 11:15:39 +0100 Subject: [PATCH] get the prod_id matching the cmd from a dictionary --- src/osa/workflow/stages.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/osa/workflow/stages.py b/src/osa/workflow/stages.py index 313f3ad0..614d7e5a 100644 --- a/src/osa/workflow/stages.py +++ b/src/osa/workflow/stages.py @@ -121,16 +121,13 @@ def _remove_dl1b_output(self, file_prefix): def _write_checkpoint(self): """Write the checkpoint in the history file.""" - dl1_commands = [ - cfg.get("lstchain", "r0_to_dl1"), - cfg.get("lstchain", "dl1ab"), - cfg.get("lstchain", "check_dl1") - ] - if self.command in dl1_commands: - prod_id = options.dl1_prod_id - elif self.command == cfg.get("lstchain", "dl1_to_dl2"): - prod_id = options.dl2_prod_id - + command_to_prod_id = { + cfg.get("lstchain", "r0_to_dl1"): options.prod_id, + cfg.get("lstchain", "dl1ab"): options.dl1_prod_id, + cfg.get("lstchain", "check_dl1"): options.dl1_prod_id, + cfg.get("lstchain", "dl1_to_dl2"): options.dl2_prod_id + } + prod_id = command_to_prod_id.get(self.command) history( run=self.run, prod_id=prod_id,