Skip to content

Separate out framework def as dataclass#667

Merged
PGijsbers merged 1 commit into
masterfrom
add-framework-type
Dec 9, 2024
Merged

Separate out framework def as dataclass#667
PGijsbers merged 1 commit into
masterfrom
add-framework-type

Conversation

@PGijsbers

@PGijsbers PGijsbers commented Dec 8, 2024

Copy link
Copy Markdown
Collaborator

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)

@PGijsbers PGijsbers Dec 8, 2024

Copy link
Copy Markdown
Collaborator Author

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

codecov-commenter commented Dec 8, 2024

Copy link
Copy Markdown

Codecov Report

❌ 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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PGijsbers PGijsbers requested a review from mfeurer December 8, 2024 09:27
@PGijsbers PGijsbers merged commit a730f6f into master Dec 9, 2024
@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