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

Add pydantic #1605

Closed
wants to merge 33 commits into from
Closed

Add pydantic #1605

wants to merge 33 commits into from

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Mar 22, 2024

No description provided.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ternaus - I've reviewed your changes and they look great!

General suggestions:

  • Consider simplifying the implementation by integrating configuration directly into the transformation classes to reduce complexity.
  • Ensure comprehensive test coverage for the new configuration models, including their custom validators and edge cases.
  • Review the relationship between quality_lower and quality_upper in ImageCompressionConfig to ensure it's validated within the config class.
  • Add unit tests for the new ImageCompressionType enum to verify serialization and deserialization.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 3 issues found
  • 🟡 Complexity: 1 issue found
  • 🟢 Docstrings: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

albumentations/augmentations/transforms.py Show resolved Hide resolved
tests/test_serialization.py Show resolved Hide resolved
albumentations/augmentations/configs.py Outdated Show resolved Hide resolved
albumentations/augmentations/configs.py Show resolved Hide resolved
albumentations/augmentations/transforms.py Show resolved Hide resolved
@ternaus ternaus marked this pull request as draft March 22, 2024 02:28
Copy link
Collaborator

Choose a reason for hiding this comment

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

empty file

always_apply: bool = False,
p: float = 0.5,
):
config = BaseTransformConfig(always_apply=always_apply, p=p)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This must be inside BasicTransform.__init__

raise ValueError(f"Grid dimensions must be positive integers. Current grid dimensions: [{n}, {m}]")

self.grid = grid
config = RandomGridShuffleConfig(grid=grid, always_apply=always_apply, p=p)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can do this using metcaclasses...
Look SerializableMeta as an example https://github.com/albumentations-team/albumentations/blob/main/albumentations/core/serialization.py#L44

@ternaus ternaus closed this Apr 4, 2024
@ternaus ternaus deleted the add_pydantic branch April 4, 2024 23:34
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