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

Remove redundant arguments from components using kw_only=True #1495

Merged

Conversation

blythed
Copy link
Collaborator

@blythed blythed commented Dec 6, 2023

The current Component classes have very redundant and bloated signatures. This is due to the
fact that we were trying to respect the ordering which @dataclass forces. By adding
the @dataclass(kw_only=True) decorator, we are able to avoid this mess, allowing for a significant
cleaning up of signatures.

In the process of doing this, it was necessary to finally deal with the fact that Component.version should never
be set via __init__.

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (34830a7) 80.33% compared to head (edcec7e) 80.61%.
Report is 1284 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1495      +/-   ##
==========================================
+ Coverage   80.33%   80.61%   +0.27%     
==========================================
  Files          95      104       +9     
  Lines        6602     7306     +704     
==========================================
+ Hits         5304     5890     +586     
- Misses       1298     1416     +118     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@blythed blythed requested a review from fnikolai December 6, 2023 22:53
Copy link
Collaborator

@kartik4949 kartik4949 left a comment

Choose a reason for hiding this comment

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

great pr

superduperdb/cli/stack.py Outdated Show resolved Hide resolved
superduperdb/components/schema.py Show resolved Hide resolved
superduperdb/components/schema.py Outdated Show resolved Hide resolved
superduperdb/ext/torch/model.py Show resolved Hide resolved
superduperdb/ext/torch/model.py Show resolved Hide resolved
Copy link
Collaborator

@jieguangzhou jieguangzhou left a comment

Choose a reason for hiding this comment

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

Great PR

Comment on lines +28 to +31
def __post_init__(self) -> None:
# set version in `__post_init__` so that is
# cannot be set in `__init__` and is always set
self.version: t.Optional[int] = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add self.type_id = self.__class__.__name__ in the post_init

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we need to discuss this -- can be done later. (The code is old, just moved around a bit, creating this diff.)

Comment on lines 462 to 471
artifact_attributes: t.ClassVar[t.Sequence[str]] = [
'object',
'preprocess',
'postprocess',
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should avoid using mutable objects in such places

@blythed blythed force-pushed the feature/non-redundant-parameters branch from d28759e to 8c0687e Compare December 9, 2023 13:00
@blythed blythed force-pushed the feature/non-redundant-parameters branch from 8c0687e to edcec7e Compare December 9, 2023 13:02
@blythed
Copy link
Collaborator Author

blythed commented Dec 9, 2023

Comments addressed, will merge.

@blythed blythed merged commit db74643 into superduper-io:main Dec 9, 2023
2 checks passed
@blythed blythed deleted the feature/non-redundant-parameters branch June 1, 2024 10:06
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.

4 participants