Skip to content

Commit

Permalink
Use .get instead of [] for strand classifcations (#391)
Browse files Browse the repository at this point in the history
* .get instead of [] for strand classifcations

This gets around an uniformative KeyError raised when the run is not on.
The missing Keys are not logged (and should be), I have created a separate issue for that.

* Format for pre-commit

AAAAA

* Forgive me pre-commit for I have sinned

I should just do this in an IDE

* Edit default for missing classifications
  • Loading branch information
Adoni5 authored Jan 29, 2025
1 parent 2c63712 commit c6e52c7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/readfish/read_until/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,13 @@ def __init__(
self.CacheType.__name__,
filter_to,
)

# When there is no run on, MinKNOW only returns a subset of read classifications, and our prefilter classes are not amongst them.
# This would then throw an uniformative KeyError. We now just carry on, and get to the point where we try to query about the run
# Which raises a more informative gRPC error instead.
# TODO - log the missing strands
self.strand_classes = set(
self.lookup_read_class[x] for x in self.prefilter_classes
self.lookup_read_class.get(x, f"{x}_classification_unavailable")
for x in self.prefilter_classes
)

self.logger.debug("Strand-like classes are %s.", self.strand_classes)
Expand Down

0 comments on commit c6e52c7

Please sign in to comment.