This PR introduces several improvements to the ImageRequest class, focusing on enhanced initialization, validation, and backward compatibility, along with updated unit tests to ensure robust functionality.
Key Changes:
Initialization Improvements:
Updated the class to ensure sensible defaults (e.g., post_processing) are only applied when attributes are not explicitly set.
Added support for legacy fields like outputBucket and outputPrefix to ensure backward compatibility for outputs initialization.
Refactoring and Cleaner Structure:
Decomposed complex logic into private helper methods (e.g., _parse_outputs, _parse_post_processing) to improve readability and maintainability.
Enhanced the from_external_message method to correctly handle both modern and legacy input formats, ensuring reliable parsing of attributes.
Enhanced Validation Logic:
Improved the is_valid() method to check for valid SinkType values in outputs, ensuring that only recognized sink types (e.g., S3, KINESIS) are allowed. This prevents configuration errors.
Replaced direct access to protected enum members with a cleaner, safer approach using public methods.
Updated and Expanded Unit Tests:
Added new tests to cover legacy output handling, including cases where outputBucket and outputPrefix are used instead of modern outputs fields.
Introduced tests for invalid sink types, ensuring the class correctly raises exceptions for unsupported configurations.
Improved tests for handling None values and verifying correct application of defaults.
Checklist
Before you submit a pull request, please make sure you have the following:
[x] Code changes are compact and well-structured to facilitate easy review
[x] Changes are documented in the README.md and other relevant documentation pages
[x] PR title and description accurately reflect the changes and are detailed enough for historical tracking
[x] PR contains tests that cover all new code and the code has been manual tested
[x] All new dependencies are declared (if any), and no unnecessary libraries are added
[x] Performance impacts (if any) of the changes are evaluated and documented
[x] Security implications of the changes (if any) are reviewed and addressed
Issue #, if available: n/a
Notes
This PR introduces several improvements to the
ImageRequest
class, focusing on enhanced initialization, validation, and backward compatibility, along with updated unit tests to ensure robust functionality.Key Changes:
Initialization Improvements:
post_processing
) are only applied when attributes are not explicitly set.outputBucket
andoutputPrefix
to ensure backward compatibility foroutputs
initialization.Refactoring and Cleaner Structure:
_parse_outputs
,_parse_post_processing
) to improve readability and maintainability.from_external_message
method to correctly handle both modern and legacy input formats, ensuring reliable parsing of attributes.Enhanced Validation Logic:
is_valid()
method to check for validSinkType
values inoutputs
, ensuring that only recognized sink types (e.g.,S3
,KINESIS
) are allowed. This prevents configuration errors.Updated and Expanded Unit Tests:
outputBucket
andoutputPrefix
are used instead of modernoutputs
fields.None
values and verifying correct application of defaults.Checklist
Before you submit a pull request, please make sure you have the following:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.