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

Separate out framework def as dataclass #667

Merged
merged 1 commit into from
Dec 9, 2024
Merged

Conversation

PGijsbers
Copy link
Collaborator

@PGijsbers PGijsbers commented Dec 8, 2024

This PR defines a Framework dataclass in favor of using a Namespace. The main advantages are type checks, IDE support, and validation. No real functional differences.

Because namespaces were used with "attribute access" (the . notation), switching out a namespace for Framework instances doesn't require very invasive changes.
Unfortunately, CI is a bit broken currently (AutoGluon used to be a reliable indicator until v1.2 broke that). But the unit tests pass, Random Forest passes, and AutoGluon-cholesterol passes, so I feel fairly confident about the change.

Part of #658 on a way to a better dev experience (#566).

@mfeurer It's been a long time since you agreed to do occasional PR reviews for AMLB. I understand if things changed and you are no longer available. If so, no hard feelings - just leave a message.

@PGijsbers PGijsbers added the enhancement New feature or request label Dec 8, 2024
Comment on lines +271 to +273
def __post_init__(self):
if isinstance(self.image, dict):
self.image = Image(**self.image)
Copy link
Collaborator Author

@PGijsbers PGijsbers Dec 8, 2024

Choose a reason for hiding this comment

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

This helps where framework namespaces were initiated based on nested dicts (loaded from configuration files). E.g.

framework = Framework(**{"name": ..., "image": {"author": ...}})

correctly initializes an Image instance.

@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@d493e92). Learn more about missing BASE report.

Files with missing lines Patch % Lines
amlb/frameworks/definitions.py 94.28% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #667   +/-   ##
=========================================
  Coverage          ?   70.08%           
=========================================
  Files             ?       55           
  Lines             ?     6835           
  Branches          ?        0           
=========================================
  Hits              ?     4790           
  Misses            ?     2045           
  Partials          ?        0           

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

@PGijsbers PGijsbers requested a review from mfeurer December 8, 2024 09:27
@PGijsbers PGijsbers merged commit a730f6f into master Dec 9, 2024
9 of 38 checks passed
@PGijsbers PGijsbers deleted the add-framework-type branch December 9, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants