Skip to content

Conversation

@Omswastik-11
Copy link

@Omswastik-11 Omswastik-11 commented Jan 4, 2026

Summary

This PR refactors run_flow_on_task, which had grown to ~160 lines with high cyclomatic complexity, by extracting small helper functions with clear, single responsibilities. The main function is now a readable orchestrator with clearly defined steps.


Changes

Extracted helper functions

  • _validate_flow_and_task_inputs
    Handles input validation and backward-compatible argument handling

  • _sync_flow_with_server
    Synchronizes the flow with the server and checks for duplicate runs

  • _prepare_run_environment
    Prepares environment information and run tags

  • _create_run_from_results
    Builds the OpenMLRun object from execution results

Internal structure improvements

  • Introduced a _RunResults NamedTuple to bundle execution outputs
    (data_content, trace, evaluations) and reduce long parameter lists

Type Safety Improvements

  • Replaced assert statements with explicit ValueError / TypeError exceptions
  • Added type guards before accessing attributes that may be None
  • Made boolean parameters keyword-only where appropriate

Fixes #1580

@Omswastik-11 Omswastik-11 marked this pull request as ready for review January 5, 2026 14:14
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 15.27778% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.06%. Comparing base (3454bbb) to head (5a4a089).

Files with missing lines Patch % Lines
openml/runs/functions.py 15.27% 61 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1596       +/-   ##
===========================================
+ Coverage   52.72%   66.06%   +13.34%     
===========================================
  Files          36       36               
  Lines        4326     4353       +27     
===========================================
+ Hits         2281     2876      +595     
+ Misses       2045     1477      -568     

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

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.

[MNT] Refactor run_flow_on_task-function

3 participants