Skip to content
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

refactor: refatoring updating image_request.py and updating tests #108

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

drduhe
Copy link
Collaborator

@drduhe drduhe commented Oct 25, 2024

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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:

  • Code changes are compact and well-structured to facilitate easy review
  • Changes are documented in the README.md and other relevant documentation pages
  • PR title and description accurately reflect the changes and are detailed enough for historical tracking
  • PR contains tests that cover all new code and the code has been manual tested
  • All new dependencies are declared (if any), and no unnecessary libraries are added
  • Performance impacts (if any) of the changes are evaluated and documented
  • Security implications of the changes (if any) are reviewed and addressed
  • I have read the Contributing Guidelines and agree to follow the Code of Conduct

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@jtblack-aws jtblack-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit should be refactor: instead of chore: to be consistent with conventional commits.

@drduhe drduhe changed the title chore: refatoring updating image_request.py and updating tests refactor: refatoring updating image_request.py and updating tests Oct 28, 2024
@drduhe drduhe force-pushed the refactor/update-image-request branch 2 times, most recently from 1bde467 to 6ff3a9d Compare October 28, 2024 20:52
@drduhe drduhe force-pushed the refactor/update-image-request branch from 6ff3a9d to 315181d Compare October 28, 2024 21:00
@drduhe drduhe merged commit d9b6cb0 into main Oct 30, 2024
2 checks passed
@drduhe drduhe deleted the refactor/update-image-request branch October 30, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants