-
Notifications
You must be signed in to change notification settings - Fork 174
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
[FEAT] Allow passing on_error="null" to ignore decoding errors in image decode #2033
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2033 +/- ##
==========================================
+ Coverage 84.69% 84.71% +0.02%
==========================================
Files 62 62
Lines 6787 6803 +16
==========================================
+ Hits 5748 5763 +15
- Misses 1039 1040 +1
|
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.
Just left a couple comments/questions!
@@ -1076,16 +1076,27 @@ def __repr__(self) -> str: | |||
class ExpressionImageNamespace(ExpressionNamespace): | |||
"""Expression operations for image columns.""" | |||
|
|||
def decode(self) -> Expression: | |||
def decode(self, on_error: Literal["raise"] | Literal["null"] = "raise") -> Expression: |
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.
why not make this a raise_error_on_failure : bool
like the internal methods? Would we expect other options in the future?
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.
I was following the semantics of our current .url.download(on_error: "null" | "raise")
, so that our APIs could be more consistent.
|
||
with pytest.raises(ValueError, match="Decoding image from bytes failed"): | ||
s.image.decode(on_error="raise") | ||
|
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.
add test for parameter input that isn't raise
or null
?
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.
LGTM overall!
@@ -1076,16 +1076,27 @@ def __repr__(self) -> str: | |||
class ExpressionImageNamespace(ExpressionNamespace): | |||
"""Expression operations for image columns.""" | |||
|
|||
def decode(self) -> Expression: | |||
def decode(self, on_error: Literal["raise"] | Literal["null"] = "raise") -> Expression: |
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.
If we expect this to always have boolean semantics, a better user-facing API might be raise_on_error: bool
or the like.
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.
I was following the semantics of our current .url.download(on_error: "null" | "raise")
, so that our APIs could be more consistent.
Allows for loose decoding of images, when we expect some bytes to be bad images
API: