Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
9d0098f
Merge branch 'main' into issue1564
fkiraly Jan 21, 2026
43276d2
fix import in resources/base.py
geetu040 Jan 23, 2026
1206f69
refactor and add exception handling
geetu040 Jan 26, 2026
bde5942
Merge branch 'main' into issue1564
satvshr Jan 26, 2026
4948e99
refactor resources/base/
geetu040 Jan 26, 2026
a354167
implement delete
geetu040 Jan 26, 2026
1fe7e3e
implement publish and minor refactoring
geetu040 Jan 27, 2026
54a3151
implement tag/untag
geetu040 Jan 27, 2026
2b6fe65
implement fallback
geetu040 Jan 27, 2026
29fd985
Merge branches 'migration' and 'migration' of https://github.com/geet…
Omswastik-11 Jan 28, 2026
fa53f8d
add test_http.py
geetu040 Jan 28, 2026
2b2db96
add uses_test_server marker
geetu040 Jan 28, 2026
0135ba2
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Jan 29, 2026
c9617f9
implement reset_cache
geetu040 Jan 29, 2026
5bc37b8
fixes with publish/delete
geetu040 Jan 29, 2026
08d9916
fix cache_key in tests
geetu040 Jan 29, 2026
37a468f
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Jan 30, 2026
8caba11
update _not_supported
geetu040 Jan 30, 2026
a70a33f
tests:added tests for migration
Omswastik-11 Jan 30, 2026
d08b1fe
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Jan 30, 2026
aaf9d4b
tests:added tests for migration
Omswastik-11 Jan 30, 2026
84d43a9
Merge branch 'main' into runs-migration-stacked
Omswastik-11 Jan 30, 2026
761ef9e
tests:modified old chache tests to use new caching
Omswastik-11 Jan 30, 2026
cf37a75
Merge branch 'runs-migration-stacked' of https://github.com/Omswastik…
Omswastik-11 Jan 30, 2026
2eb7c7a
tests:modified old chache tests to use new caching
Omswastik-11 Jan 30, 2026
d9476c8
tests:modified old chache tests to use new caching
Omswastik-11 Jan 30, 2026
f4718c1
tests:skip the production related tests
Omswastik-11 Jan 30, 2026
4560b6b
tests:modify skip messgaes
Omswastik-11 Jan 30, 2026
1913c10
add 'get_api_config' skeleton method
SimonBlanke Jan 30, 2026
7681949
remove 'APISettings'
SimonBlanke Jan 30, 2026
01840a5
impl. 'get_api_config'
SimonBlanke Jan 30, 2026
26ed4c1
add singleton pattern for settings
SimonBlanke Jan 30, 2026
c588d0c
add 'reset_settings'
SimonBlanke Jan 30, 2026
b6ff720
remove unused code
SimonBlanke Jan 30, 2026
80d5afc
reimplement usage of v1 settings config
SimonBlanke Jan 30, 2026
f47112c
first try v2, fallback to v1 if not available
SimonBlanke Jan 30, 2026
d44cf3e
reimplement singelton without the use of 'global'
SimonBlanke Jan 30, 2026
ea7dda1
add explanations
SimonBlanke Jan 30, 2026
f0e5947
change usage of settings to new impl.
SimonBlanke Jan 30, 2026
edcd006
add explanations
SimonBlanke Jan 30, 2026
cde0aae
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 30, 2026
48fa391
modify get method to use use_chache by default
Omswastik-11 Jan 31, 2026
aa1e560
move to config: APIVersion, ResourceType
geetu040 Feb 1, 2026
06b8497
remove api_context entirely
geetu040 Feb 1, 2026
384da91
major refactor
geetu040 Feb 1, 2026
1878138
more refactoring with setup/
geetu040 Feb 2, 2026
dc26e01
implement APIBackend as controller
geetu040 Feb 2, 2026
e2d059b
move enums
geetu040 Feb 2, 2026
d156ad4
module level imports
geetu040 Feb 2, 2026
d7a3788
module level import for _backend
geetu040 Feb 2, 2026
b5b9ef6
module level import for tests
geetu040 Feb 2, 2026
68820fe
Merge branch 'main' into migration
geetu040 Feb 2, 2026
567eca4
add test: test_tag_and_untag
geetu040 Feb 2, 2026
ff33d8e
move runs to run with better class name
Omswastik-11 Feb 2, 2026
20ee072
changed test to use latest backed style
Omswastik-11 Feb 2, 2026
0a7dd16
move runs test to test_api dir
Omswastik-11 Feb 2, 2026
b2287c3
implement get/set_config_values
geetu040 Feb 3, 2026
b7e285e
improve APIBackend.set_config_values
geetu040 Feb 3, 2026
fd43c48
use LegacyConfig
geetu040 Feb 3, 2026
f4aab6b
Revert "use LegacyConfig"
geetu040 Feb 3, 2026
d43cf86
implement _sync_api_config
geetu040 Feb 3, 2026
3e323ed
update tests with _sync_api_config
geetu040 Feb 3, 2026
9195fa6
rename config: timeout -> timeout_seconds
geetu040 Feb 3, 2026
5342eec
use timedelta for default ttl value
geetu040 Feb 3, 2026
adc0e74
update tests, adds v2/fallback
geetu040 Feb 3, 2026
bfb2d3e
add MinIOClient in TestBase
geetu040 Feb 3, 2026
cabaecf
fix linting for builder
geetu040 Feb 3, 2026
e14532f
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Feb 3, 2026
a64203d
add run migrtation test file
Omswastik-11 Feb 3, 2026
85c1113
fix unbound variables: "code", "message"
geetu040 Feb 4, 2026
39bf86a
use requests.Session()
geetu040 Feb 4, 2026
7b66677
remove "timeout_seconds" entirely
geetu040 Feb 4, 2026
d2224c4
update/refactor tests
geetu040 Feb 4, 2026
c6351e0
correct the not implemented error
Omswastik-11 Feb 5, 2026
9608c36
remove unused current_api_version from TestAPIBase
geetu040 Feb 5, 2026
f6bc7f7
make TestAPIBase inherit TestBase
geetu040 Feb 5, 2026
baa3a38
nits: test classes
geetu040 Feb 5, 2026
d6146aa
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Feb 5, 2026
b349581
remove old caching tests
Omswastik-11 Feb 6, 2026
52b93fe
minor fix in _sync_api_config
geetu040 Feb 6, 2026
ec9477f
chore: rerun CI
geetu040 Feb 6, 2026
ad05cd3
remove old delete methods
Omswastik-11 Feb 9, 2026
5cdc0ad
correct the url
Omswastik-11 Feb 9, 2026
7457f16
correct the tests
Omswastik-11 Feb 9, 2026
f199479
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Feb 9, 2026
282c7d9
correct the tests
Omswastik-11 Feb 9, 2026
10d134a
remove duplicates in _api/resources/__init__.py
geetu040 Feb 10, 2026
935f0f4
implement HTTPClient.download and add tests
geetu040 Feb 10, 2026
9514df8
add docstrings
geetu040 Feb 11, 2026
53bee94
update minio
geetu040 Feb 12, 2026
4f8c9b3
correct the tests
Omswastik-11 Feb 12, 2026
7f98c61
merge
Omswastik-11 Feb 12, 2026
33b4ca0
make delay functions static
geetu040 Feb 13, 2026
a6b9a45
rename: retry_raise_e -> exception
geetu040 Feb 13, 2026
f924b32
use context-manager for requests.Session
geetu040 Feb 13, 2026
541b0f2
remove "assert response is not None"
geetu040 Feb 13, 2026
acb173f
verify checksum before caching
geetu040 Feb 13, 2026
3e8d1f0
update tests
geetu040 Feb 13, 2026
f83bdb5
minor fix in ResourceV1API.untag
geetu040 Feb 13, 2026
2a42712
remove cache.ttl
geetu040 Feb 16, 2026
001caad
replace config.cache.dir with config.cache_dir
geetu040 Feb 16, 2026
fb38a2d
make HTTPClient.cache compulsory
geetu040 Feb 17, 2026
03c4ca9
remove unused OpenMLCacheRequiredError
geetu040 Feb 17, 2026
8d708fd
implement and use TestAPIBase._create_resource
geetu040 Feb 17, 2026
4f75bba
make ResourceAPI.minio compulsory
geetu040 Feb 17, 2026
164f66f
Merge branch 'main' into migration
geetu040 Feb 17, 2026
c4dae43
rename: use_cache -> enable_cache; reset_cache -> refresh_cache
geetu040 Feb 17, 2026
36c20a2
use server config from TestBase
geetu040 Feb 17, 2026
ab3c1eb
tests: mock HTTP post calls to prevent race conditions
geetu040 Feb 17, 2026
0577e45
Merge branch 'main' into runs-migration-stacked
Omswastik-11 Feb 17, 2026
d4965eb
merge
Omswastik-11 Feb 17, 2026
ea3a8ae
merge
Omswastik-11 Feb 17, 2026
5d229c7
use minio in run migration
Omswastik-11 Feb 17, 2026
2a488ca
Merge branch 'main' into migration
geetu040 Feb 18, 2026
599c7e1
remove hardcoded server in TestHTTPClient.test_cache
geetu040 Feb 18, 2026
2867862
fix docstring in _resolve_default_cache_dir
geetu040 Feb 18, 2026
f09f3cd
fix docstring in ResourceAPI
geetu040 Feb 18, 2026
5f731ce
remove duplicates in __all__
geetu040 Feb 18, 2026
bad7842
remove ttl related code/docs
geetu040 Feb 18, 2026
aefdb38
remove delay methods in HTTPClient
geetu040 Feb 18, 2026
0f40b02
minor fix in _resolve_default_cache_dir
geetu040 Feb 18, 2026
7ac1672
update FallbackProxy
geetu040 Feb 18, 2026
6ac1dfe
simplify _backend creation
geetu040 Feb 18, 2026
62924c9
Merge branch 'main' into migration
geetu040 Feb 18, 2026
27696bb
req changes
satvshr Feb 20, 2026
190face
resolve conflicts
satvshr Feb 20, 2026
95daaa6
remove old config file
satvshr Feb 20, 2026
7841ea8
added OPENML_TEST_SERVER_ADMIN_KEY_ENV_VAR
satvshr Feb 20, 2026
cc515aa
bug fixing
satvshr Feb 20, 2026
e6a92df
armagh fix
satvshr Feb 20, 2026
1b8c22a
update content_type check
geetu040 Feb 20, 2026
fc839a6
Revert "make delay functions static"
geetu040 Feb 20, 2026
1c922af
Revert "remove delay methods in HTTPClient"
geetu040 Feb 20, 2026
ffa9ce9
Merge branch 'main' into migration
geetu040 Feb 20, 2026
a7b2d21
allow api_key=None
geetu040 Feb 20, 2026
27fe790
add tests for api_key=None
geetu040 Feb 20, 2026
8965112
update cache not found message
geetu040 Feb 23, 2026
72ea1a4
update docs for path in HTTPCache
geetu040 Feb 23, 2026
a696c49
remove elapsed from cached meta
geetu040 Feb 23, 2026
755636d
move self.headers to _HEADERS
geetu040 Feb 23, 2026
d07af34
fix indentation in docstrings of _resolve_default_cache_dir
geetu040 Feb 23, 2026
2d9c8ec
Update openml/_api/clients/http.py
geetu040 Feb 23, 2026
002b989
Merge branch 'main' into migration
geetu040 Feb 23, 2026
045d896
move _handle_delete_exception and_get_endpoint_name, legal_resources
geetu040 Feb 23, 2026
c437966
set HTTPClient.headers
geetu040 Feb 23, 2026
e27470a
remove main_tag
geetu040 Feb 23, 2026
d04d956
remove and merge TestAPIBase into TestBase
geetu040 Feb 23, 2026
9263f7f
minor change in TestHTTPClient.test_cache
geetu040 Feb 23, 2026
79dea29
make HTTPClient.request private
geetu040 Feb 23, 2026
f6497c2
Revert "update FallbackProxy"
geetu040 Feb 23, 2026
dce7f54
use st_ctime instead of st_ctime for cache refresh test
geetu040 Feb 23, 2026
40dd460
Merge branch 'main' into issue1564
geetu040 Feb 24, 2026
0fc917c
majore config refactor
geetu040 Feb 24, 2026
3d86b18
Merge branch 'pr-1577' into migration
geetu040 Feb 24, 2026
aba3d3e
update _config.py
geetu040 Feb 24, 2026
d99d54d
update test_openml_cache_dir_env_var
geetu040 Feb 24, 2026
dc22e3a
fix mutable SERVERS_REGISTRY
geetu040 Feb 25, 2026
7318573
update set_api_version for fallback
geetu040 Feb 25, 2026
29ef187
minor fix
geetu040 Feb 25, 2026
cf94c89
fixes for test_config
geetu040 Feb 25, 2026
298fbda
fixes in conftest urls
geetu040 Feb 25, 2026
9870502
update test_http.py
geetu040 Feb 25, 2026
33065c2
undo changes with test_openml_cache_dir_env_var
geetu040 Feb 25, 2026
76b92bb
fix server mode in test_config.py
geetu040 Feb 25, 2026
419edcb
move _HEADERS to confing
geetu040 Feb 25, 2026
cb6d937
add fixtures for migration tests
geetu040 Feb 25, 2026
8544c8a
update test_http.py with fixtures
geetu040 Feb 25, 2026
d4c413b
update test_versions.py
geetu040 Feb 25, 2026
fab1a15
update test_versions.py
geetu040 Feb 25, 2026
49789a7
merged latest changes related to testing
Omswastik-11 Feb 25, 2026
8b07a20
modified tests
Omswastik-11 Feb 25, 2026
276324a
fix error message in HTTPClient.server
geetu040 Feb 26, 2026
73f7594
fixes in test_versions.py: use DummyTaskAPI instead of TaskAPI
geetu040 Feb 26, 2026
2ee7fa3
add clients in openml._backend
geetu040 Feb 26, 2026
070731d
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Feb 26, 2026
4be5bbd
fixes with openml.config.[server|apikey] leakage
geetu040 Feb 26, 2026
9027c01
remove unused fixtures: use_api_[v1|v2]
geetu040 Feb 26, 2026
e5461a9
add more config tests
geetu040 Feb 27, 2026
7d899a9
make SERVERS_REGISTRY private
geetu040 Feb 27, 2026
8587414
fix marker: uses_test_server->test_server
geetu040 Feb 27, 2026
23a3450
fix UserWarning
geetu040 Feb 27, 2026
ac28f82
update fixture: with_server
geetu040 Feb 27, 2026
4f6e7ec
merge
Omswastik-11 Feb 27, 2026
176002c
modified tests
Omswastik-11 Feb 27, 2026
0178ee0
remove the api key requirement tag key
Omswastik-11 Feb 27, 2026
4a66245
req changes
satvshr Mar 2, 2026
c762fb4
Merge branch 'issue1564' of https://github.com/satvshr/openml-python …
satvshr Mar 2, 2026
77c21f2
Update openml/_api/clients/http.py
geetu040 Mar 4, 2026
eac24fc
Update tests/test_api/test_http.py
geetu040 Mar 4, 2026
2ed65fe
update test_get_uses_cached_response
geetu040 Mar 4, 2026
f3b07de
test_get_with_api_key
geetu040 Mar 4, 2026
29db3f1
use .arff instead of .bin in tests
geetu040 Mar 4, 2026
3b4e538
update test_download_creates_file to use md5_checksum
geetu040 Mar 4, 2026
8ac886b
update test_download_is_cached_on_disk
geetu040 Mar 4, 2026
305f4f0
update APIBackendBuilder
geetu040 Mar 4, 2026
b2bf164
Merge branch 'main' into migration
geetu040 Mar 4, 2026
e97e6c2
Update openml/_api/clients/http.py
geetu040 Mar 4, 2026
c66d73c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 4, 2026
aa54e8e
pre-commit fixes
geetu040 Mar 4, 2026
2d452d3
Merge branch 'main' into issue1564
geetu040 Mar 6, 2026
c235812
Merge branch 'main' into issue1564
fkiraly Mar 6, 2026
39eb823
Trigger CI
satvshr Mar 6, 2026
50eed37
Merge branch 'main' into migration
geetu040 Mar 6, 2026
7a000eb
Merge branch 'main' into issue1564
geetu040 Mar 10, 2026
79f6187
Merge branch 'main' into issue1564
geetu040 Mar 10, 2026
ec2b09a
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Mar 11, 2026
b1a9e7f
Merge branch 'pr-1577' into migration (merge conflicts)
geetu040 Mar 12, 2026
d716ecf
update server methods in config
geetu040 Mar 12, 2026
3c29e71
fix api-version leakage in tests
geetu040 Mar 12, 2026
b4ff0b2
remove unused migration code
geetu040 Mar 12, 2026
93155ee
debug ci: separate cache for each test-case
geetu040 Mar 12, 2026
d3cc9a7
update port for localhost
geetu040 Mar 12, 2026
a6b82f4
Revert "debug ci: separate cache for each test-case"
geetu040 Mar 12, 2026
3419973
rerun CI
geetu040 Mar 12, 2026
8de99b7
Merge branch 'main' into migration
geetu040 Mar 12, 2026
4a24b83
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Mar 16, 2026
7d61107
create enum ServerMode
geetu040 Mar 16, 2026
1ecbbba
update config for ServerMode
geetu040 Mar 16, 2026
65472ed
update tests for ServerMode
geetu040 Mar 16, 2026
44b48b5
udpate apikey in _TEST_SERVERS_LOCAL
geetu040 Mar 17, 2026
04bc83b
fix: remove duplicate server name in cache path
geetu040 Mar 23, 2026
f926092
test: remove check for ":" since windows CI expects it
geetu040 Mar 23, 2026
aa91d92
Merge branch 'migration' of https://github.com/geetu040/openml-python…
Omswastik-11 Mar 23, 2026
22d7179
updated the tests
Omswastik-11 Mar 23, 2026
dc081ca
Merge branch 'main' into runs-migration-stacked
Omswastik-11 Mar 23, 2026
808bc5b
updated the test
Omswastik-11 Mar 23, 2026
61816f4
updated the tests
Omswastik-11 Mar 23, 2026
c02e09b
updated the tests
Omswastik-11 Mar 23, 2026
19c7dab
Merge branch 'main' into runs-migration-stacked
Omswastik-11 Mar 24, 2026
fe8f66b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 24, 2026
f5982fd
Merge branch 'main' into runs-migration-stacked
Omswastik-11 Apr 1, 2026
855973e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 1, 2026
79db213
merge the final changes
Omswastik-11 Apr 1, 2026
0af278a
Merge branch 'runs-migration-stacked' of https://github.com/Omswastik…
Omswastik-11 Apr 1, 2026
bc4bf1e
Revert "updated the tests"
Omswastik-11 Apr 1, 2026
4912d57
implement the suggestions
Omswastik-11 Apr 1, 2026
e913fb3
implement the suggestions
Omswastik-11 Apr 1, 2026
6b86327
update HTTPClient
geetu040 Apr 3, 2026
ebb6c2d
rename cache file
geetu040 Apr 3, 2026
3adcd0e
update cache file
geetu040 Apr 3, 2026
9d7618c
add back cache tests
geetu040 Apr 3, 2026
475706b
update cache tests
geetu040 Apr 3, 2026
05fd050
remove lock file
geetu040 Apr 3, 2026
6ffac4e
remove newly added skips
geetu040 Apr 3, 2026
276b851
remove contract test
geetu040 Apr 3, 2026
a0e9653
update run_id
geetu040 Apr 3, 2026
f5f0df1
update run_id
geetu040 Apr 3, 2026
9accf24
use cached run in test_api/test_run.py
geetu040 Apr 3, 2026
229592f
remove unused func
Omswastik-11 Apr 3, 2026
f6e6516
remove old api calls from OpenMLRun classes
Omswastik-11 Apr 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions openml/_api/clients/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import Any, cast
from urllib.parse import urlencode, urljoin, urlparse

import arff
import requests
import xmltodict
from requests import Response
Expand Down Expand Up @@ -98,16 +99,32 @@ def _get_body_filename_from_response(self, response: Response) -> str:
if "text/xml" in content_type:
return "body.xml"

if response.content.startswith(b"PK\x03\x04"):
return "body.zip"

try:
arff.loads(response.text)
return "body.arff"
except arff.ArffException:
pass

return "body.txt"

def _get_body_filename_from_path(self, path: Path) -> str:
if (path / "body.json").exists():
return "body.json"
candidates = []
for p in path.iterdir():
if p.name.startswith("body.") and len(p.suffixes) == 1:
candidates.append(p)

if (path / "body.xml").exists():
return "body.xml"
if not candidates:
raise FileNotFoundError(f"No body file found in path: {path}")

return "body.txt"
if len(candidates) > 1:
raise FileNotFoundError(
f"Multiple body files found in path: {path} ({[p.name for p in candidates]})"
)

return candidates[0].name

def load(self, key: str) -> Response:
"""
Expand All @@ -132,6 +149,9 @@ def load(self, key: str) -> Response:
"""
path = self._key_to_path(key)

if not path.exists():
raise FileNotFoundError(f"Cache path not found: {path}")

meta_path = path / "meta.json"
meta_raw = meta_path.read_bytes() if meta_path.exists() else "{}"
meta = json.loads(meta_raw)
Expand All @@ -141,8 +161,6 @@ def load(self, key: str) -> Response:
headers = json.loads(headers_raw)

body_path = path / self._get_body_filename_from_path(path)
if not body_path.exists():
raise FileNotFoundError(f"Incomplete cache at {body_path}")
body = body_path.read_bytes()

response = Response()
Expand Down Expand Up @@ -825,3 +843,9 @@ def write_to_file(response: Response, path: Path, encoding: str) -> None:
handler = handler or write_to_file
handler(response, file_path, encoding)
return file_path

def cache_path_from_url(self, url: str) -> Path:
full_url = urljoin(self.server, url)
key = self.cache.get_key(full_url, params={})
path = self.cache._key_to_path(key)
return path / self.cache._get_body_filename_from_path(path)
43 changes: 43 additions & 0 deletions openml/_api/resources/base/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
from .base import ResourceAPI

if TYPE_CHECKING:
import pandas as pd

from openml.estimation_procedures import OpenMLEstimationProcedure
from openml.evaluations import OpenMLEvaluation
from openml.flows.flow import OpenMLFlow
from openml.runs.run import OpenMLRun
from openml.setups.setup import OpenMLSetup
Comment on lines 15 to 19
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

There is a duplicate OpenMLEvaluation import in this TYPE_CHECKING block. Please remove the duplicate to keep imports tidy and avoid confusion during refactors.

Copilot uses AI. Check for mistakes.
from openml.tasks.task import TaskType


class DatasetAPI(ResourceAPI):
Expand Down Expand Up @@ -86,6 +90,45 @@ class RunAPI(ResourceAPI):

resource_type: ResourceType = ResourceType.RUN

@abstractmethod
def get(
self,
run_id: int,
*,
reset_cache: bool = False,
) -> OpenMLRun: ...

def list( # type: ignore[valid-type] # noqa: PLR0913
self,
limit: int,
offset: int,
*,
ids: builtins.list[int] | None = None,
Comment on lines +102 to +106
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

RunAPI.list() is declared with an ellipsis body but is not marked @abstractmethod, unlike the other resource interfaces in this file. Mark it abstract (or provide a real implementation) so incomplete RunAPI implementations are caught early.

Copilot uses AI. Check for mistakes.
task: builtins.list[int] | None = None,
setup: builtins.list[int] | None = None,
flow: builtins.list[int] | None = None,
uploader: builtins.list[int] | None = None,
study: int | None = None,
tag: str | None = None,
display_errors: bool = False,
task_type: TaskType | int | None = None,
) -> pd.DataFrame: ...

@abstractmethod
def download_text_file(
self,
source: str,
*,
md5_checksum: str | None = None,
) -> str: ...

@abstractmethod
def file_id_to_url(
self,
file_id: int,
filename: str | None = None,
) -> str: ...


class SetupAPI(ResourceAPI):
"""Abstract API interface for setup resources."""
Expand Down
33 changes: 22 additions & 11 deletions openml/_api/resources/base/versions.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

merge was not clean here, right?

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Mapping
from typing import Any, cast
from typing import Any

import xmltodict

Expand Down Expand Up @@ -189,7 +189,10 @@ def untag(self, resource_id: int, tag: str) -> list[str]:
def _get_endpoint_name(self) -> str:
if self.resource_type == ResourceType.DATASET:
return "data"
return cast("str", self.resource_type.value)
endpoint_name = self.resource_type.value
if not isinstance(endpoint_name, str):
raise TypeError(f"Unexpected endpoint type: {type(endpoint_name)}")
return endpoint_name

def _extract_id_from_upload(self, parsed: Mapping[str, Any]) -> int:
"""
Expand Down Expand Up @@ -220,18 +223,23 @@ def _extract_id_from_upload(self, parsed: Mapping[str, Any]) -> int:
if not isinstance(root_value, Mapping):
raise ValueError("Unexpected XML structure")

# Look for oml:id directly in the root value
if "oml:id" in root_value:
id_value = root_value["oml:id"]
if isinstance(id_value, (str, int)):
return int(id_value)
# 1. Specifically look for keys ending in _id or id (e.g., oml:id, oml:run_id)
for k, v in root_value.items():
if (
(k.endswith(("id", "_id")) or "id" in k.lower())
and isinstance(v, (str, int))
and str(v).isdigit()
):
return int(v)

# Fallback: check all values for numeric/string IDs
# 2. Fallback: check all values for numeric/string IDs, excluding xmlns or URLs
for v in root_value.values():
if isinstance(v, (str, int)):
return int(v)
val_str = str(v)
if val_str.isdigit():
return int(val_str)

raise ValueError("No ID found in upload response")
raise ValueError(f"No ID found in upload response: {root_value}")


class ResourceV2API(ResourceAPI):
Expand All @@ -258,4 +266,7 @@ def untag(self, resource_id: int, tag: str) -> list[str]: # noqa: ARG002
self._not_supported(method="untag")

def _get_endpoint_name(self) -> str:
return cast("str", self.resource_type.value)
endpoint_name = self.resource_type.value
if not isinstance(endpoint_name, str):
raise TypeError(f"Unexpected endpoint type: {type(endpoint_name)}")
return endpoint_name
Loading
Loading