Skip to content

Commit

Permalink
completed at to None if force storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ivadym committed Jul 29, 2024
1 parent 36c50aa commit 0e1140e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
13 changes: 7 additions & 6 deletions cg/cli/workflow/balsamic/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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"]
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cg/cli/workflow/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions cg/meta/workflow/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion cg/meta/workflow/nf_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit 0e1140e

Please sign in to comment.