Skip to content

Commit

Permalink
added ability to auto approve
Browse files Browse the repository at this point in the history
  • Loading branch information
aurthurm committed Nov 24, 2024
1 parent 4fcd689 commit 668bae5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions felicity/apps/analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ async def verify_from_result_uids(uids: list[str], user: User) -> list[AnalysisR
# try to verify associated sample
sample_verified = False
try:
sample_verified, _ = await sample_wf.approve(
sample_verified, sample = await sample_wf.approve(
a_result.sample_uid, approved_by=user
)
if sample_verified.qc_set_uid:
await qc_set_workflow.submit(sample_verified.qc_set_uid, user)
if sample_verified and sample.qc_set_uid:
await qc_set_workflow.approve(sample.qc_set_uid, user)
# auto publish QC samples without report generation
await sample_service.change_status(a_result.sample_uid, SampleState.PUBLISHED, user)
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions felicity/apps/analysis/workflow/qcset.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def approve(self, uid, by) -> QCSet:
return await self.qc_set_service.approve(uid, by)

@staticmethod
async def _guard_approve(self, samples):
async def _guard_approve(samples):
all_are_approved = [s.status == SampleState.APPROVED for s in samples]
if not all(all_are_approved):
raise CQSetWorkFlowException(f"Cannot submit this qs set. All samples by the approved")
raise CQSetWorkFlowException(f"Cannot approve this qs set. All samples by the approved")
3 changes: 2 additions & 1 deletion felicity/apps/analysis/workflow/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ async def _guard_approve(self, sample: Sample) -> bool:
match = all([(result.status in statuses) for result in analyses_results])

# ?? cannot approve referred unless u r system_daemon
if match and sample.status == [SampleState.AWAITING, SampleState.PAIRED]:
if match and sample.status in [SampleState.AWAITING, SampleState.PAIRED]:
allow = True

# Are there are results in referred state or some are in pending state
Expand All @@ -272,6 +272,7 @@ async def _guard_approve(self, sample: Sample) -> bool:
):
allow = False

print(f"matches = {match}, allow = {allow}, sample status = {sample.status}")
if not allow:
raise SampleWorkFlowException("Cannot approve this Sample")

Expand Down

0 comments on commit 668bae5

Please sign in to comment.