Skip to content

[ENH] V1 → V2 API Migration - core structure#1576

Open
geetu040 wants to merge 183 commits intoopenml:mainfrom
geetu040:migration
Open

[ENH] V1 → V2 API Migration - core structure#1576
geetu040 wants to merge 183 commits intoopenml:mainfrom
geetu040:migration

Conversation

@geetu040
Copy link
Collaborator

Towards #1575

This PR sets up the core folder and file structure along with base scaffolding for the API v1 → v2 migration.

It includes:

  • Skeleton for the HTTP client, backend, and API context
  • Abstract resource interfaces and versioned stubs (*V1, *V2)
  • Minimal wiring to allow future version switching and fallback support

No functional endpoints are migrated yet. This PR establishes a stable foundation for subsequent migration and refactor work.

@geetu040 geetu040 mentioned this pull request Dec 30, 2025
25 tasks
@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 2025

Codecov Report

❌ Patch coverage is 54.88722% with 420 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.65%. Comparing base (7feb2a3) to head (2ee7fa3).

Files with missing lines Patch % Lines
openml/_api/clients/http.py 23.74% 167 Missing ⚠️
openml/_config.py 68.64% 90 Missing ⚠️
openml/_api/resources/base/versions.py 31.16% 53 Missing ⚠️
openml/_api/resources/base/fallback.py 26.31% 28 Missing ⚠️
openml/_api/setup/builder.py 27.02% 27 Missing ⚠️
openml/_api/setup/backend.py 66.66% 19 Missing ⚠️
openml/_api/resources/base/base.py 57.14% 15 Missing ⚠️
openml/cli.py 0.00% 8 Missing ⚠️
openml/runs/functions.py 0.00% 5 Missing ⚠️
openml/testing.py 76.92% 3 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1576      +/-   ##
==========================================
- Coverage   52.82%   52.65%   -0.18%     
==========================================
  Files          37       61      +24     
  Lines        4371     5029     +658     
==========================================
+ Hits         2309     2648     +339     
- Misses       2062     2381     +319     

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

@geetu040 geetu040 requested a review from mfeurer February 25, 2026 10:10
@geetu040
Copy link
Collaborator Author

geetu040 commented Feb 25, 2026

Notes for stacked PRs on updating tests

Please follow tests/test_api/test_versions.py to write tests. I have created fixtures in conftest.py, you can use them.

  1. You don't need to create dummy resource, you will import relevant resource from openml._api
  2. create 2 fixtures [resource]_v1 and [resource]_v2 using the clients
  3. write v1-specific tests, v2-specific tests and tests to match outputs of v1 and v2 where applicable
  4. you can choose between mocking or live-server call. I would prefer that delete and post methods are mocked since they are more prune to race conditions.
  5. If you want to access a config, access it directly from openml.config.[var] instead of http_client.[var] or [resource].[var]
  6. don't test for fallback
  7. since v2 is not available through remote servers, you should set up local servers and manually update SERVERS_REGISTRY in _config.py, you can replace the dict for "test" with "local" for testing out these endpoints locally, but don't push these changes

FYI: @EmanAbdelhaleem @JATAYU000 @rohansen856 @satvshr @Omswastik-11

@geetu040
Copy link
Collaborator Author

updated for #1611 (comment), #1609 (comment)

Copy link
Collaborator Author

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

I have addressed all previous review comments from Pieter, Matthias, and co-pilot. Any remaining unresolved threads include a reply from my side and may need further discussion, please take a look and resolve if appropriate.

This PR is now stacked on #1577, which refactors config.py into _config.py.

I have made the following changes in the _config.py

  • Removed server and apikey as standalone config fields.
  • Introduced:
    • servers: holds server and apikey per API version.
    • api_version: active API version (also the switch point).
    • fallback_api_version: optional fallback version (defaults to None).
    • server and apikey remain available via getters/setters, backed by servers + api_version.
  • Removed the separate config used by the _api module. It now relies directly on _config.py.
  • Added SERVERS_REGISTRY to _config.py to centralize environment configuration instead of scattering it across the SDK.

Updated all new API tests:

  • Dropped TestBase inheritance.
  • Removed TestAPIBase.
  • Converted everything to pure pytest style, creating and using fixtures from conftest.py.

This PR is up for review but I'll continue addressing feedback from the stacked PRs and update this PR accordingly if needed.

FYI: @fkiraly @mfeurer @PGijsbers

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants