-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added pre-qc-failed status filter #24
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,6 +272,7 @@ def default_status(cls): | |
cls.ASSEMBLY_UPLOADED: False, | ||
cls.ASSEMBLY_UPLOAD_FAILED: False, | ||
cls.ASSEMBLY_UPLOAD_BLOCKED: False, | ||
cls.PRE_ASSEMBLY_QC_FAILED: False, | ||
} | ||
|
||
status = models.JSONField( | ||
|
@@ -504,7 +505,7 @@ class AnalysisStates(str, Enum): | |
ANALYSIS_COMPLETED = "analysis_completed" | ||
ANALYSIS_BLOCKED = "analysis_blocked" | ||
ANALYSIS_FAILED = "analysis_failed" | ||
ANALYSIS_QC_FAILED = "analysis_qc_failed" | ||
ANALYSIS_PRE_QC_FAILED = "analysis_pre_qc_failed" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For analyses we don't have a "pre-qc".. it's just QC, right? |
||
ANALYSIS_POST_SANITY_CHECK_FAILED = "analysis_post_sanity_check_failed" | ||
|
||
@classmethod | ||
|
@@ -514,6 +515,7 @@ def default_status(cls): | |
cls.ANALYSIS_COMPLETED: False, | ||
cls.ANALYSIS_BLOCKED: False, | ||
cls.ANALYSIS_FAILED: False, | ||
cls.ANALYSIS_PRE_QC_FAILED: False, | ||
} | ||
|
||
status = models.JSONField( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,7 @@ def get_assemblies_to_attempt(study: analyses.models.Study) -> List[Union[str, i | |
**{ | ||
f"status__{analyses.models.Assembly.AssemblyStates.ASSEMBLY_COMPLETED}": False, | ||
f"status__{analyses.models.Assembly.AssemblyStates.ASSEMBLY_BLOCKED}": False, | ||
f"status__{analyses.models.Assembly.AssemblyStates.PRE_ASSEMBLY_QC_FAILED}": False, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one should go first; it doesn't change how it works—just improves readability There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A little manager mixin helper would be nice for building these more readably: class SelectByStatusManagerMixin:
STATUS_FIELDNAME = "status"
def filter_by_statuses(self, statuses_to_be_true: List[Union[str, Enum]] = None, statuses_to_be_false: List[Union[str, Enum]] = None):
"""
Filter queryset by a combination of statuses in the objects status json field.
"""
filters = {}
if statuses_true:
filters = {
f"{self.STATUS_FIELDNAME}__{must_be}": True
for must_be in statuses_true
}
if statuses_false:
filters.update({
f"{self.STATUS_FIELDNAME}__{must_not_be}": True
for must_not_be in statuses_false
})
return super().get_queryset().filter(**filters) Then we can do and select more readably, like assemblies_worth_trying = study.assemblies_reads.filter_by_statuses(
statuses_to_be_false=[
analyses.models.Assembly.AssemblyStates.ASSEMBLY_COMPLETED,
analyses.models.Assembly.AssemblyStates.ASSEMBLY_BLOCKED,
analyses.models.Assembly.AssemblyStates.PRE_ASSEMBLY_QC_FAILED,
]
).values_list("id", flat=True) (or maybe better yet include an Happy to add this later as it will need a couple of new tests. Just documenting whilst it came to mind! |
||
} | ||
).values_list("id", flat=True) | ||
return assemblies_worth_trying | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put "cls.PRE_ASSEMBLY_QC_FAILED: False," after "cls.ASSEMBLY_STARTED: False," :)