-
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
added pre-qc-failed status filter #24
Conversation
a9a01d7
to
4dea336
Compare
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.
Good catch.. not sure if we should rename the analyses QC to PRE-QC
workflows/flows/assemble_study.py
Outdated
@@ -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 comment
The 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 comment
The 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 class AssemblyManager(SelectByStatusManagerMixin, ENADerivedManager): ...
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 exclude_by_statuses
chainable method on the mixin).
Happy to add this later as it will need a couple of new tests. Just documenting whilst it came to mind!
workflows/flows/assemble_study.py
Outdated
@@ -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 comment
The 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 class AssemblyManager(SelectByStatusManagerMixin, ENADerivedManager): ...
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 exclude_by_statuses
chainable method on the mixin).
Happy to add this later as it will need a couple of new tests. Just documenting whilst it came to mind!
@KateSakharova I ended up implementing the suggested |
@SandyRogers thank you, I will rebase from your branch! |
3654927
to
562ba4f
Compare
Added filtering for not re-trying pre-qc failed assemlies and amplicons