diff --git a/cg/cli/workflow/balsamic/base.py b/cg/cli/workflow/balsamic/base.py index 82b5e70666..895fe6632f 100644 --- a/cg/cli/workflow/balsamic/base.py +++ b/cg/cli/workflow/balsamic/base.py @@ -135,7 +135,7 @@ def report_deliver(context: CGConfig, case_id: str, dry_run: bool, force: bool): analysis_api: AnalysisAPI = context.meta_apis["analysis_api"] try: analysis_api.status_db.verify_case_exists(case_id) - analysis_api.verify_case_config_file_exists(case_id=case_id) + analysis_api.verify_case_config_file_exists(case_id=case_id, dry_run=dry_run) analysis_api.trailblazer_api.verify_latest_analysis_is_completed( case_id=case_id, force=force ) @@ -151,8 +151,9 @@ def report_deliver(context: CGConfig, case_id: str, dry_run: bool, force: bool): @balsamic.command("store-housekeeper") @ARGUMENT_CASE_ID @FORCE +@DRY_RUN @click.pass_obj -def store_housekeeper(context: CGConfig, case_id: str, force: bool): +def store_housekeeper(context: CGConfig, case_id: str, dry_run: bool, force: bool): """Store a finished analysis in Housekeeper and StatusDB.""" analysis_api: AnalysisAPI = context.meta_apis["analysis_api"] @@ -161,11 +162,11 @@ def store_housekeeper(context: CGConfig, case_id: str, force: bool): try: analysis_api.status_db.verify_case_exists(case_internal_id=case_id) - analysis_api.verify_case_config_file_exists(case_id=case_id) + analysis_api.verify_case_config_file_exists(case_id=case_id, dry_run=dry_run) analysis_api.verify_deliverables_file_exists(case_id=case_id) - analysis_api.upload_bundle_housekeeper(case_id=case_id, force=force) - analysis_api.upload_bundle_statusdb(case_id=case_id) - analysis_api.set_statusdb_action(case_id=case_id, action=None) + analysis_api.upload_bundle_housekeeper(case_id=case_id, dry_run=dry_run, force=force) + analysis_api.upload_bundle_statusdb(case_id=case_id, dry_run=dry_run, force=force) + analysis_api.set_statusdb_action(case_id=case_id, action=None, dry_run=dry_run) except ValidationError as error: LOG.warning("Deliverables file is malformed") raise error diff --git a/cg/cli/workflow/commands.py b/cg/cli/workflow/commands.py index 3fb90f2952..7afe643123 100644 --- a/cg/cli/workflow/commands.py +++ b/cg/cli/workflow/commands.py @@ -106,9 +106,9 @@ def store(context: CGConfig, case_id: str, dry_run: bool, force: bool): LOG.info(f"Dry run: Would have stored deliverables for {case_id}") return try: - analysis_api.upload_bundle_housekeeper(case_id=case_id, force=force) - analysis_api.upload_bundle_statusdb(case_id=case_id) - analysis_api.set_statusdb_action(case_id=case_id, action=None) + analysis_api.upload_bundle_housekeeper(case_id=case_id, dry_run=dry_run, force=force) + analysis_api.upload_bundle_statusdb(case_id=case_id, dry_run=dry_run, force=force) + analysis_api.set_statusdb_action(case_id=case_id, action=None, dry_run=dry_run) except Exception as exception_object: housekeeper_api.rollback() status_db.session.rollback() diff --git a/cg/meta/workflow/analysis.py b/cg/meta/workflow/analysis.py index 922cee01c6..d4e6cc2902 100644 --- a/cg/meta/workflow/analysis.py +++ b/cg/meta/workflow/analysis.py @@ -241,7 +241,9 @@ def upload_bundle_housekeeper( f"Analysis successfully stored in Housekeeper: {case_id} ({bundle_version.created_at})" ) - def upload_bundle_statusdb(self, case_id: str, dry_run: bool = False) -> None: + def upload_bundle_statusdb( + self, case_id: str, dry_run: bool = False, force: bool = False + ) -> None: """Storing an analysis bundle in StatusDB for a provided case.""" LOG.info(f"Storing analysis in StatusDB for {case_id}") case_obj: Case = self.status_db.get_case_by_internal_id(case_id) @@ -250,7 +252,7 @@ def upload_bundle_statusdb(self, case_id: str, dry_run: bool = False) -> None: new_analysis: Case = self.status_db.add_analysis( workflow=self.workflow, version=workflow_version, - completed_at=datetime.now(), + completed_at=datetime.now() if not force else None, primary=(len(case_obj.analyses) == 0), started_at=analysis_start, ) diff --git a/cg/meta/workflow/nf_analysis.py b/cg/meta/workflow/nf_analysis.py index 1847e6689a..e007055008 100644 --- a/cg/meta/workflow/nf_analysis.py +++ b/cg/meta/workflow/nf_analysis.py @@ -789,7 +789,7 @@ def store_analysis_housekeeper( self.trailblazer_api.verify_latest_analysis_is_completed(case_id=case_id, force=force) self.verify_deliverables_file_exists(case_id) self.upload_bundle_housekeeper(case_id=case_id, dry_run=dry_run, force=force) - self.upload_bundle_statusdb(case_id=case_id, dry_run=dry_run) + self.upload_bundle_statusdb(case_id=case_id, dry_run=dry_run, force=force) self.set_statusdb_action(case_id=case_id, action=None, dry_run=dry_run) except ValidationError as error: raise HousekeeperStoreError(f"Deliverables file is malformed: {error}")