openml-python icon indicating copy to clipboard operation
openml-python copied to clipboard

[MNT] Replace Live Server Calls with Mocks in Unit Tests

Open geetu040 opened this issue 9 months ago • 25 comments

Several tests currently rely on direct connections to the live server (production/test), which can cause race conditions, server overload, and sporadic failures (see https://github.com/openml/openml-python/issues/1586). To ensure these remain true unit tests, they should use mocks/patches instead of the remote server.

Steps:

  1. Identify tests using the remote server, e.g., marked with "production_server" or "test_server".
  2. Mock or patch requests.Session in tests relying on openml._api_calls._send_request. Alternatively, higher-level mocking can be used to simplify implementation.

Affected test files (can be separate sub-tasks/PRs):

geetu040 avatar Feb 18 '26 08:02 geetu040

Hi, I would like to work on this issue. Could you please assign it to me?

VHemanth45 avatar Feb 18 '26 18:02 VHemanth45

hi @VHemanth45 I think you can claim/work on individual files at a time. It's a big issue, so many people can take it up

omkar-334 avatar Feb 18 '26 19:02 omkar-334

@geetu040 can i work on this ??

bala-bhargav avatar Feb 19 '26 01:02 bala-bhargav

sure anyone can work on this, just comment down which individual file you are working on and create a corresponding PR on it

geetu040 avatar Feb 19 '26 06:02 geetu040

Hi @geetu040 ,

Can I be assigned this issue to work on. I am currently working on the test_openml/test_api_calls.py

Joiejoie1 avatar Feb 19 '26 15:02 Joiejoie1

Hi @geetu040,

I’m currently working on the test_study/test_study_functions module for this issue.

Quick doubt — should we mock all calls that hit the test_server so the tests run fully offline, or are there any exceptions where live calls are still expected?

Thanks!

Sachin0496 avatar Feb 19 '26 17:02 Sachin0496

I'll take on test_tasks/test_task_functions.py

kronzter avatar Feb 19 '26 18:02 kronzter

Hi, I would like to work on this issue. Could you please assign it to me?

I have started working on test_flows/test_flow.py

VHemanth45 avatar Feb 19 '26 18:02 VHemanth45

Hi @geetu040 . I have started working on test_utils/test_utils.py .

Rahuldrabit avatar Feb 19 '26 19:02 Rahuldrabit

I'm working on tests/test_tasks/test_classification_task.py

omkar-334 avatar Feb 19 '26 19:02 omkar-334

i am working on tests/test_tasks/test_task_methods.py
pr link -PR

Sandipmandal25 avatar Feb 19 '26 20:02 Sandipmandal25

Hi @geetu040 everyone I am Shafwan, I am working on the /test_tasks/test_clustering_task.py

Shafwansafi06 avatar Feb 20 '26 05:02 Shafwansafi06

hi @geetu040 Im working on tests/test_datasets/test_dataset_functions.py — it has 58 @pytest.mark.test_server() markers so I am planning to split it across 2–3 PRs by logical test group rather than one large PR. Does that approach work or would you prefer a single PR?

Sandipmandal25 avatar Feb 20 '26 07:02 Sandipmandal25

hi @geetu040 Im working on tests/test_datasets/test_dataset_functions.py — it has 58 @pytest.mark.test_server() markers so I am planning to split it across 2–3 PRs by logical test group rather than one large PR. Does that approach work or would you prefer a single PR?

can you explain why would you need to split it?

geetu040 avatar Feb 20 '26 09:02 geetu040

Hi @geetu040, I would like to work on test_openml/test_api_calls.py

aryarathoree avatar Feb 20 '26 09:02 aryarathoree

Hi @geetu040 i am working on tests/test_tasks/test_supervised_task.py

bala-bhargav avatar Feb 20 '26 14:02 bala-bhargav

I'm working on test_datasets/test_dataset.py

omkar-334 avatar Feb 20 '26 16:02 omkar-334

hi @geetu040 Im working on tests/test_datasets/test_dataset_functions.py — it has 58 @pytest.mark.test_server() markers so I am planning to split it across 2–3 PRs by logical test group rather than one large PR. Does that approach work or would you prefer a single PR?

can you explain why would you need to split it?

The 58 markers cover very different functionality (listing, downloading, caching, uploading, tagging, etc.) so splitting by logical group keeps each PR focused and easier to review. But if you'd prefer a single PR, I can do that too — happy to go either way.

Sandipmandal25 avatar Feb 20 '26 17:02 Sandipmandal25

Hi @geetu040 ! I am working on test_runs/test_run_functions.py , test_tasks/test_regression_task.py

Jay2006sawant avatar Feb 21 '26 11:02 Jay2006sawant