Skip to content

[MNT] diagnose and address long test runtimes #1633

Open

Description

@fkiraly

Current test runtimes are in the order of 1 hour.

We should diagnose the biggest time sinks and think about strategies to mitigate them, while optimally not reducing coverage.

Activity

  1. added
    Good First IssueIssues suitable for people new to contributing to openml-python!
    maintenance & CIContinuous integration & package distribution
    on Feb 15, 2026
  2. geetu040 commented on Feb 16, 2026

    @geetu040
    Collaborator

    Some info from this run: https://github.com/openml/openml-python/actions/runs/22063995363/:

    "production" and "sklearn" included tests are responsible for the major time sink

    some tests are taking too long, though they involve a single simple API call
    it could be something with the server, which is not able to hold the load of multiple jobs from multiple PRs
    though I believe it should be sporadic, but some specific tests are taking too long, even when run locally, these single tests can take up to 30-60 mins to exexute, here are some noted from a few recent jobs

    tests/test_study/test_study_functions.py::TestStudyFunctions::test_get_study_old
    tests/test_evaluations/test_evaluation_functions.py::TestEvaluationFunctions::test_list_evaluations_setups_filter_flow
    tests/test_runs/test_run_functions.py::TestRun::test_get_runs_list_by_tag
    tests/test_tasks/test_task_functions.py::TestTask::test_list_clustering_task
    tests/test_evaluations/test_evaluation_functions.py::TestEvaluationFunctions::test_list_evaluations_setups_filter_task
    tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows_paginate
    tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows_output_format
    tests/test_evaluations/test_evaluations_example.py::TestEvaluationsExample::test_example_python_paper
    tests/test_tasks/test_task_functions.py::TestTask::test_get_task_different_types
    tests/test_runs/test_run_functions.py::TestRun::test_get_runs_list_by_task
    tests/test_runs/test_run_functions.py::TestRun::test_get_runs_pagination
    tests/test_study/test_study_functions.py::TestStudyFunctions::test_get_suite
    
  3. fkiraly commented on Feb 16, 2026

    @fkiraly
    ContributorAuthor

    yes, looks like it is coming from "production" - here is a list with runtimes from the durations flag:

    3740.37s call     tests/test_study/test_study_functions.py::TestStudyFunctions::test_get_study_old
    2094.26s call     tests/test_tasks/test_task_functions.py::TestTask::test_list_clustering_task
    1980.66s call     tests/test_runs/test_run_functions.py::TestRun::test_get_runs_list_by_tag
    175.46s call     tests/test_runs/test_run_functions.py::TestRun::test_get_runs_list_by_task
    64.49s call     tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows
    42.39s call     tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows_output_format
    25.99s call     tests/test_evaluations/test_evaluation_functions.py::TestEvaluationFunctions::test_evaluation_list_sort
    24.68s call     tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows_paginate
    22.22s call     tests/test_runs/test_run_functions.py::TestRun::test_online_run_metric_score
    21.01s call     tests/test_runs/test_run_functions.py::TestRun::test_get_runs_pagination
    17.99s call     tests/test_setups/test_setup_functions.py::TestSetupFunctions::test_get_setup
    13.51s call     tests/test_evaluations/test_evaluation_functions.py::TestEvaluationFunctions::test_list_evaluations_setups_filter_flow
    13.30s call     tests/test_tasks/test_task_functions.py::TestTask::test_get_task_different_types
    12.72s call     tests/test_evaluations/test_evaluation_functions.py::TestEvaluationFunctions::test_list_evaluations_setups_filter_task
    11.71s call     tests/test_runs/test_run_functions.py::TestRun::test_format_prediction_non_supervised
    11.11s call     tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows_empty
    9.60s call     tests/test_study/test_study_functions.py::TestStudyFunctions::test_get_study_error
    9.54s call     tests/test_datasets/test_dataset.py::OpenMLDatasetTestSparse::test_get_sparse_categorical_data_id_395
    7.70s call     tests/test_tasks/test_clustering_task.py::OpenMLClusteringTaskTest::test_get_dataset
    7.18s call     tests/test_setups/test_setup_functions.py::TestSetupFunctions::test_list_setups_output_format
    
  4. PGijsbers commented on Feb 18, 2026

    @PGijsbers
    Collaborator

    The slowest tests should take no longer than 1-2 minutes. These are tests that:

    • run some local experiment that's time consuming (we should probably find lightweight equivalents)
    • require a cronjob to run on the server (e.g., uploading a dataset and checking it's processed correctly by the server)

    There should be no more than a few of those in the entire test suite. Any test that takes longer, especially such as reported above, is caused by connectivity issues or server-sided issues.

    I think it would be useful to look at longer running tests (such as the ones that require the server cronjob) and make sure they can run without a server (e.g., through mocking). This is beneficial twice: our tests are more consistent and faster, but also those tests typically poll the server and for that reason may be more likely to cause server-sided issues in the first place.

  5. geetu040 commented on Feb 18, 2026

    @geetu040
    Collaborator

    also since the connection_n_retries is set to 5 with a longer delay with each retry, a failing test will take even longer to fail

    would it be fine to set retries to possibly 3?

  6. areebahmeddd commented on Feb 19, 2026

    @areebahmeddd

    Hi, could i pick this issue up? thanks!

  7. geetu040 commented on Feb 19, 2026

    @geetu040
    Collaborator

    Hi, could i pick this issue up? thanks!

    please mention down first how you are going to fix it, which test cases you are going to cover and what will you do to reduce their time

  8. kronzter commented on Feb 19, 2026

    @kronzter

    Hi, could i pick this issue up? thanks!

    please mention down first how you are going to fix it, which test cases you are going to cover and what will you do to reduce their time

    Hi, Id like to try tackling this issue.
    I have gone through the code base and have some questions and approaches.

    Issues as ive tried to understand

    1. Some tests call list_flows(), list_runs()etc. with no size limit so it is triggering _list_all to fetch the entire production database in batches of 10,000 records. For example, test_list_flows fetches all 15,000+ flows just to assert len >= 1500.
    2. The as_robot fixture in conftest.py applies n_retries=20 with a sigmoid delay (approaching 60s/retry) to the entire test session. A single network error on a production test can stall and cause large delays
    3. Several @pytest.mark.production_server tests hit the live server only because the test server lacks that data (study 34/99, setups, clustering tasks)not because they need production behavior. Can't these be replaced with mock fixtures using the create_request_response pattern already in the codebase?

    Approach i'm planning:

    • Cap uncapped listing calls with size=N where the assertion doesn't actually need the full dataset
    • Reduce n_retries in the as_robot fixture
    • Replace single-GET production tests with XML fixture mocks following the existing pattern in test_dataset_functions.py

    Questions:

    1. For tests like test_list_flows where the assertion is len >= 1500 is it okay to reduce this to something like len >= 100 with size=200, or would you prefer keeping the original assertion and instead just mocking the full response?
    2. For the as_robot retry count is n_retries=3 an acceptable floor, or is this intentional?
      Because as mentioned above in thread I also think such a long delay is not required. From what I understand, such a long delay should only be for prod environment, isnt it fine if for just test suite, it fails faster?
    3. Should the mocked tests keep the @pytest.mark.production_server marker (just using a mock instead of the real server), or should that marker be removed entirely if run without production server?
      Happy to discuss further before diving in!
  9. geetu040 commented on Feb 19, 2026

    @geetu040
    Collaborator

    @kronzter yes you are looking in the right direction

    • For tests like test_list_flows where the assertion is len >= 1500 is it okay to reduce this to something like len >= 100 with size=200, or would you prefer keeping the original assertion and instead just mocking the full response?

    Ultimately for any given test-case it's better to mock than rely on live server call (unless it's an explicit integration test)
    For mocking this is the relevant issue: #1649
    CC: @PGijsbers

    • For the as_robot retry count is n_retries=3 an acceptable floor, or is this intentional?
      Because as mentioned above in thread I also think such a long delay is not required. From what I understand, such a long delay should only be for prod environment, isnt it fine if for just test suite, it fails faster?

    I would prefer a lower number and would be fine with n_retries=3, but would leave this question for @PGijsbers since they set it up to this value in the first place.

    • Should the mocked tests keep the @pytest.mark.production_server marker (just using a mock instead of the real server), or should that marker be removed entirely if run without production server?
      Happy to discuss further before diving in!

    yes you can remove the marker if it's not sending an api call to the production server

  10. kronzter commented on Feb 19, 2026

    @kronzter

    @kronzter yes you are looking in the right direction

    • For tests like test_list_flows where the assertion is len >= 1500 is it okay to reduce this to something like len >= 100 with size=200, or would you prefer keeping the original assertion and instead just mocking the full response?

    Ultimately for any given test-case it's better to mock than rely on live server call (unless it's an explicit integration test) For mocking this is the relevant issue: #1649 CC: @PGijsbers

    • For the as_robot retry count is n_retries=3 an acceptable floor, or is this intentional?
      Because as mentioned above in thread I also think such a long delay is not required. From what I understand, such a long delay should only be for prod environment, isnt it fine if for just test suite, it fails faster?

    I would prefer a lower number and would be fine with n_retries=3, but would leave this question for @PGijsbers since they set it up to this value in the first place.

    • Should the mocked tests keep the @pytest.mark.production_server marker (just using a mock instead of the real server), or should that marker be removed entirely if run without production server?
      Happy to discuss further before diving in!

    yes you can remove the marker if it's not sending an api call to the production server

    Will await confirmation regarding retry count and then push a fix.

  11. geetu040 commented on Feb 20, 2026

    @geetu040
    Collaborator

    @kronzter please see this comment #1633 (comment). Can you collect the relevant tests mentioned there? You can run these tests locally using the markers "production_server" and "test_server" to run specific tests.

  12. kronzter commented on Feb 20, 2026

    @kronzter

    Hi @geetu040 ,
    I've grouped them basis of test_server and production_server

    With 40 longest durations :
    Check snippet
    test_server

    Production_server

    Except the one that failed looks like only one has run durations even reaching 90 secs

    Rest are under a minute.

    Please let me know if ive missed something.

  13. geetu040 commented on Feb 20, 2026

    @geetu040
    Collaborator

    The link is not working. It's better to drop the longest durations, we already had some in the initial comments, are they the same?

  14. kronzter commented on Feb 20, 2026

    @kronzter

    for test_server marked tests:

    87.80s call tests/test_runs/test_run_functions.py::TestRun::test_run_and_upload_gridsearch
    69.04s call tests/test_datasets/test_dataset_functions.py::TestOpenMLDataset::test_data_edit_critical_field
    63.33s call tests/test_runs/test_run_functions.py::TestRun::test_run_and_upload_maskedarrays
    47.97s call tests/test_runs/test_run_functions.py::TestRun::test_run_and_upload_column_transformer_pipeline
    44.03s call tests/test_runs/test_run.py::TestRun::test_offline_and_online_run_identical
    41.60s call tests/test_runs/test_run_functions.py::TestRun::test_run_and_upload_randomsearch
    38.38s call tests/test_runs/test_run.py::TestRun::test_publish_with_local_loaded_flow
    33.33s call tests/test_datasets/test_dataset_functions.py::TestOpenMLDataset::test_data_edit_cannot_edit_critical_field_if_dataset_has_task
    30.58s call tests/test_runs/test_run_functions.py::TestRun::test_learning_curve_task_2
    29.56s call tests/test_runs/test_run_functions.py::TestRun::test__run_exists
    28.93s call tests/test_runs/test_run_functions.py::TestRun::test_run_and_upload_linear_regression

    full log

    for production_server marked tests:
    47.16s call tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows
    41.10s call tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows_output_format
    38.24s call tests/test_runs/test_run_functions.py::TestRun::test_online_run_metric_score
    27.05s call tests/test_evaluations/test_evaluation_functions.py::TestEvaluationFunctions::test_evaluation_list_sort
    23.92s call tests/test_evaluations/test_evaluation_functions.py::TestEvaluationFunctions::test_list_evaluations_setups_filter_flow
    22.28s call tests/test_runs/test_run_functions.py::TestRun::test_get_runs_list_by_tag
    17.83s call tests/test_study/test_study_functions.py::TestStudyFunctions::test_get_study_old
    14.34s call tests/test_runs/test_run_functions.py::TestRun::test_get_runs_pagination
    14.19s call tests/test_flows/test_flow_functions.py::TestFlowFunctions::test_list_flows_paginate
    13.72s call tests/test_runs/test_run_functions.py::TestRun::test_get_runs_list_by_task
    13.22s call tests/test_runs/test_run_functions.py::TestRun::test_get_runs_list_by_filters

    full log

    As for the lagging tests in the previous threads, only some are the same.
    But even then, they are comparatively faster
    Some examples are :
    test_get_study_old 3740s to 17.8s
    test_list_clustering_task 2094s to 6.3s
    test_get_runs_list_by_tag 1980s to 22s

    ps: not sure why pastebin doesnt work. i have accordingly added gists.

  15. Abhishek9639 commented on Feb 21, 2026

    @Abhishek9639
    Contributor

    Hi @fkiraly,
    I’d like to work on this issue.
    My plan is to profile the test suite using pytest --durations to identify the slowest tests and then investigate whether repeated API calls or fixture setup are causing the delay.
    Please let me know if this approach aligns with your expectations.

  16. PGijsbers commented on May 22, 2026

    @PGijsbers
    Collaborator

    This issue was automatically closed by #1692 but that only added some guidelines on how to identify long running tests and does not actually reduce test time, so I am keeping this issue open for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueIssues suitable for people new to contributing to openml-python!maintenance & CIContinuous integration & package distribution

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions