Skip to content

Conversation

@rohansen856
Copy link
Contributor

Metadata

Details

Edited the OpenMLParameter in openml/setups/setup.py to use @dataclass decorator. This significantly reduces the boilerplate code in the following places:

  • OpenMLSetup

Before:

class OpenMLSetup:
    """Setup object (a.k.a. Configuration)...."""

    def __init__(self, setup_id: int, flow_id: int, parameters: dict[int, Any] | None):
        if not isinstance(setup_id, int):
            raise ValueError("setup id should be int")

        if not isinstance(flow_id, int):
            raise ValueError("flow id should be int")

        if parameters is not None and not isinstance(parameters, dict):
            raise ValueError("parameters should be dict")

        self.setup_id = setup_id
        self.flow_id = flow_id
        self.parameters = parameters

After:

@dataclass
class OpenMLSetup:
    """Setup object (a.k.a. Configuration)...."""

    setup_id: int
    flow_id: int
    parameters: dict[int, Any] | None

    def __post_init__(self) -> None:
        if not isinstance(self.setup_id, int):
            raise ValueError("setup id should be int")

        if not isinstance(self.flow_id, int):
            raise ValueError("flow id should be int")

        if self.parameters is not None and not isinstance(self.parameters, dict):
            raise ValueError("parameters should be dict")
  • OpenMLParameter

Before:

class OpenMLParameter:
    """Parameter object (used in setup)...."""

    def __init__(  # noqa: PLR0913
        self,
        input_id: int,
        flow_id: int,
        flow_name: str,
        full_name: str,
        parameter_name: str,
        data_type: str,
        default_value: str,
        value: str,
    ):
        self.id = input_id
        self.flow_id = flow_id
        self.flow_name = flow_name
        self.full_name = full_name
        self.parameter_name = parameter_name
        self.data_type = data_type
        self.default_value = default_value
        self.value = value

After:

@dataclass
class OpenMLParameter:
    """Parameter object (used in setup)...."""

    input_id: int
    flow_id: int
    flow_name: str
    full_name: str
    parameter_name: str
    data_type: str
    default_value: str
    value: str

    def __post_init__(self) -> None:
        # Map input_id to id for backward compatibility
        self.id = self.input_id

Tests

For tests, I have used xfail temporarily to bypass the preexisting test failures in tests\test_setups\test_setup_functions.py.

@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.14%. Comparing base (c5f68bf) to head (e7c3c91).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1582      +/-   ##
==========================================
- Coverage   53.02%   52.14%   -0.89%     
==========================================
  Files          36       36              
  Lines        4326     4332       +6     
==========================================
- Hits         2294     2259      -35     
- Misses       2032     2073      +41     

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

Copy link
Contributor

@geetu040 geetu040 left a comment

Choose a reason for hiding this comment

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

Changes in openml/setups/setup.py look good. Please revert the changes in tests/test_setups/test_setup_functions.py; they won't be needed once this branch is synced with main. Merging main into this branch should skip those tests and make the CI pass.

@rohansen856 rohansen856 force-pushed the dataclass_impl_openmlparameter branch from e15e442 to 82fafe3 Compare January 12, 2026 18:19
@rohansen856 rohansen856 force-pushed the dataclass_impl_openmlparameter branch from 82fafe3 to e7c3c91 Compare January 12, 2026 18:20
@rohansen856
Copy link
Contributor Author

@geetu040 removed the test file changes. Ready for review.

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