Skip to content

[ENH] V1 -> V2 Migration : Runs#1616

Open
Omswastik-11 wants to merge 98 commits intoopenml:mainfrom
Omswastik-11:runs-migration-stacked
Open

[ENH] V1 -> V2 Migration : Runs#1616
Omswastik-11 wants to merge 98 commits intoopenml:mainfrom
Omswastik-11:runs-migration-stacked

Conversation

@Omswastik-11
Copy link
Contributor

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

Metadata

  • Reference Issue:
  • New Tests Added:
  • Documentation Updated:
  • Change Log Entry:

Details

fixes #1624

@geetu040 geetu040 mentioned this pull request Jan 15, 2026
25 tasks
@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 65.05576% with 282 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.50%. Comparing base (d421b9e) to head (b349581).

Files with missing lines Patch % Lines
openml/_api/clients/http.py 69.47% 58 Missing ⚠️
openml/_api/resources/base/versions.py 43.33% 51 Missing ⚠️
openml/_api/resources/run.py 29.23% 46 Missing ⚠️
openml/_api/config.py 0.00% 30 Missing ⚠️
openml/_api/resources/base/fallback.py 26.31% 28 Missing ⚠️
openml/_api/setup/backend.py 71.91% 25 Missing ⚠️
openml/runs/run.py 20.00% 12 Missing ⚠️
openml/_api/setup/_utils.py 56.00% 11 Missing ⚠️
openml/runs/functions.py 20.00% 8 Missing ⚠️
openml/_api/setup/builder.py 81.08% 7 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1616      +/-   ##
==========================================
- Coverage   52.04%   47.50%   -4.54%     
==========================================
  Files          36       64      +28     
  Lines        4333     5115     +782     
==========================================
+ Hits         2255     2430     +175     
- Misses       2078     2685     +607     

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

if "description" not in file_elements:
file_elements["description"] = run._to_xml()

run_id = self.resource.publish(path="run", files=file_elements)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be delete afterward, use TestBase._mark_entity_for_removal
apply at other places as well

assert isinstance(run_id, int)
assert run_id > 0

@pytest.mark.uses_test_server()
Copy link
Collaborator

Choose a reason for hiding this comment

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

marker can be moved at class level if all tests require this

Comment on lines 89 to 97
self.v2_http_client = self._get_http_client(
server="http://127.0.0.1:8001/",
base_url="",
api_key=self.api_key,
timeout=self.timeout,
retries=self.retries,
retry_policy=self.retry_policy,
cache=self.cache,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this can be self.http_clients[APIVersion.V2]

@@ -1658,13 +1666,60 @@ def test_run_on_dataset_with_missing_labels_array(self):

@pytest.mark.uses_test_server()
def test_get_cached_run(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can remove this function entirely, we test cache at client level

Signed-off-by: Omswastik-11 <omswastikpanda11@gmail.com>
@Omswastik-11
Copy link
Contributor Author

@mock.patch.object(requests.Session, "delete")
def test_delete_run_not_owned(mock_delete, test_files_directory, test_api_key):
    openml.config.start_using_configuration_for_example()
    content_file = test_files_directory / "mock_responses" / "runs" / "run_delete_not_owned.xml"
    mock_delete.return_value = create_request_response(
        status_code=412,
        content_filepath=content_file,
    )

    with pytest.raises(
        OpenMLNotAuthorizedError,
        match="The run can not be deleted because it was not uploaded by you.",
    ):
        openml.runs.delete_run(40_000)

    run_url = "https://test.openml.org/api/v1/xml/run/40000"
    assert run_url == mock_delete.call_args.args[0]
    assert test_api_key == mock_delete.call_args.kwargs.get("params", {}).get("api_key")

@mock.patch.object(requests.Session, "delete")
def test_delete_run_success(mock_delete, test_files_directory, test_api_key):
    openml.config.start_using_configuration_for_example()
    content_file = test_files_directory / "mock_responses" / "runs" / "run_delete_successful.xml"
    mock_delete.return_value = create_request_response(
        status_code=200,
        content_filepath=content_file,
    )

    success = openml.runs.delete_run(10591880)
    assert success

    run_url = "https://test.openml.org/api/v1/xml/run/10591880"
    assert run_url == mock_delete.call_args.args[0]
    assert test_api_key == mock_delete.call_args.kwargs.get("params", {}).get("api_key")

@mock.patch.object(requests.Session, "delete")
def test_delete_unknown_run(mock_delete, test_files_directory, test_api_key):
    openml.config.start_using_configuration_for_example()
    content_file = test_files_directory / "mock_responses" / "runs" / "run_delete_not_exist.xml"
    mock_delete.return_value = create_request_response(
        status_code=412,
        content_filepath=content_file,
    )

    with pytest.raises(
        OpenMLServerException,
        match="Run does not exist",
    ):
        openml.runs.delete_run(9_999_999)

    run_url = "https://test.openml.org/api/v1/xml/run/9999999"
    assert run_url == mock_delete.call_args.args[0]
    assert test_api_key == mock_delete.call_args.kwargs.get("params", {}).get("api_key")

@geetu040 same issue as Flow PR . Should I remove these issues or modify delete ?

@geetu040
Copy link
Collaborator

geetu040 commented Feb 6, 2026

@geetu040 same issue as Flow PR . Should I remove these issues or modify delete ?

Thanks for pointing this out, please modify these, here's how you can do this: #1575 (comment)

geetu040 added a commit to geetu040/openml-python that referenced this pull request Feb 6, 2026
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.

[ENH] V1 → V2 API Migration - runs

6 participants