Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
277 commits
Select commit Hold shift + click to select a range
88077a7
chore: fixed the args limit in function using noqa
rohansen856 Jan 13, 2026
1dbc780
merge main
satvshr Jan 14, 2026
13acf35
Merge branch 'main' into studies-migration
rohansen856 Jan 15, 2026
e02e05b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 15, 2026
4c75e16
undo changes in tasks/functions.py
geetu040 Jan 15, 2026
5762185
Merge branch 'main' into migration
geetu040 Jan 15, 2026
9170edc
chore: updated the list function acc to reviews
rohansen856 Jan 15, 2026
021a1e1
made requested changes
satvshr Jan 15, 2026
4c4a12c
Merge branch 'main' into issue1564
satvshr Jan 15, 2026
1d91220
made requested changes
satvshr Jan 15, 2026
3e26ace
Merge branch 'issue1564' of https://github.com/satvshr/openml-python …
satvshr Jan 15, 2026
0060b2e
fixed bugs
satvshr Jan 15, 2026
65ba66b
fixed bugs
satvshr Jan 15, 2026
317c6e9
fixed bugs
satvshr Jan 15, 2026
503ab82
fixed bugs
satvshr Jan 15, 2026
8c980c9
chore: removed _list_studies and implemented api_context for studies …
rohansen856 Jan 16, 2026
fd7ea2b
Merge branch 'main' into issue1564
satvshr Jan 16, 2026
fa3cd40
bug fixing
satvshr Jan 16, 2026
7e9bc1f
Merge branch 'main' into migration
geetu040 Jan 21, 2026
c603383
add tests directory
geetu040 Jan 21, 2026
ff6a8b0
use enum for delay method
geetu040 Jan 21, 2026
f01898f
implement cache
geetu040 Jan 21, 2026
5c4511e
refactor clients
geetu040 Jan 21, 2026
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
fa53f8d
add test_http.py
geetu040 Jan 28, 2026
2b2db96
add uses_test_server marker
geetu040 Jan 28, 2026
c9617f9
implement reset_cache
geetu040 Jan 29, 2026
9d2e4e4
Merge branch 'main' into studies-migration
rohansen856 Jan 29, 2026
e05dec5
tests: initialized tests for studies migration
rohansen856 Jan 29, 2026
ad64cfb
Merge branch 'studies-migration' of https://github.com/rohansen856/op…
rohansen856 Jan 29, 2026
5bc37b8
fixes with publish/delete
geetu040 Jan 29, 2026
08d9916
fix cache_key in tests
geetu040 Jan 29, 2026
8caba11
update _not_supported
geetu040 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
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
735a335
refactor: updated studies migration acc to reviews
rohansen856 Feb 1, 2026
6b67c1f
tests: add tests for studies API migration
rohansen856 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
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
ee10f59
refactor: replace api_context.backend.study with openml._backend.study
rohansen856 Feb 3, 2026
9c0ad45
chore: removed unneccesary test for studies
rohansen856 Feb 3, 2026
cabaecf
fix linting for builder
geetu040 Feb 3, 2026
85c1113
fix unbound variables: "code", "message"
geetu040 Feb 4, 2026
0458929
Merge branch 'migration' of https://github.com/geetu040/openml-python…
rohansen856 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
5e3fea8
refactor: updated StudyV1API acc to reviews
rohansen856 Feb 5, 2026
fc32488
refactor: updated studies test acc to reviews
rohansen856 Feb 5, 2026
eda66ca
chore: removed delete method test from studies api test
rohansen856 Feb 5, 2026
18dc72a
refactor: updated study api test filename
rohansen856 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
647a5cd
chore: updated list matches ro check proper error throw
rohansen856 Feb 6, 2026
52b93fe
minor fix in _sync_api_config
geetu040 Feb 6, 2026
ec9477f
chore: rerun CI
geetu040 Feb 6, 2026
ea8dae9
Merge branch 'migration' of https://github.com/geetu040/openml-python…
rohansen856 Feb 10, 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
85ad3df
chore: added enums file
rohansen856 Feb 11, 2026
f96a34c
chore: updated all test to use enums file
rohansen856 Feb 11, 2026
272b710
chore: fixed http test import error
rohansen856 Feb 11, 2026
53bee94
update minio
geetu040 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
9a7aebe
chore: updated study test acc to upstream
rohansen856 Feb 16, 2026
0a6e836
Merge branch 'main' into studies-migration
rohansen856 Feb 16, 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
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
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
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
3ce1095
sync with base
rohansen856 Feb 27, 2026
a110fa0
Merge branch 'migration' of https://github.com/geetu040/openml-python…
rohansen856 Feb 27, 2026
18f31f7
Merge branch 'studies-migration' of https://github.com/rohansen856/op…
rohansen856 Feb 27, 2026
b1ddc93
chore: updated tests for studies
rohansen856 Feb 27, 2026
960e601
chore: fixed circular import errors
rohansen856 Mar 2, 2026
677051b
chore: up[dated conftest for ci errors
rohansen856 Mar 2, 2026
68f3ff6
chore: fixed module import errors
rohansen856 Mar 2, 2026
2e1cdcf
chore: fixed minio import errors
rohansen856 Mar 2, 2026
96cee47
ci errors fix
rohansen856 Mar 2, 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
f120c19
Merge branch 'main' into studies-migration
rohansen856 Mar 10, 2026
79f6187
Merge branch 'main' into issue1564
geetu040 Mar 10, 2026
adea726
Merge branch 'main' into studies-migration
rohansen856 Mar 11, 2026
242e420
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 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
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
a0a3b61
Merge branch 'main' into studies-migration
rohansen856 Mar 17, 2026
33858a7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 17, 2026
a704bb0
chore: fixed pre commit errors
rohansen856 Mar 17, 2026
3470cb5
chore: fixed mypy errors
rohansen856 Mar 17, 2026
44b48b5
udpate apikey in _TEST_SERVERS_LOCAL
geetu040 Mar 17, 2026
62c3d3d
CI trigger
rohansen856 Mar 17, 2026
c93b97f
chore: fixed missing header in OpenMLConfigManager
rohansen856 Mar 17, 2026
972987b
chore: fixed server key issue in test
rohansen856 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
083194b
Merge branch 'migration' of https://github.com/geetu040/openml-python…
rohansen856 Mar 24, 2026
c224532
Merge branch 'main' into studies-migration (resolve conflicts)
geetu040 Mar 25, 2026
3953fdf
chore: added missing argument in studies api test
rohansen856 Mar 26, 2026
c2d8487
chore: updated resource base to enable tagging for studies
rohansen856 Mar 26, 2026
edf8524
chore: updated acc to reviews
rohansen856 Mar 26, 2026
ca2cdc5
Merge branch 'main' into studies-migration
rohansen856 Mar 26, 2026
6f30a45
chore: updated tests acc to review
rohansen856 Mar 30, 2026
03ea718
Merge branch 'studies-migration' of https://github.com/rohansen856/op…
rohansen856 Mar 30, 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
13 changes: 13 additions & 0 deletions openml/_api/resources/base/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
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
Expand Down Expand Up @@ -80,6 +82,17 @@ class StudyAPI(ResourceAPI):

resource_type: ResourceType = ResourceType.STUDY

@abstractmethod
def list( # noqa: PLR0913
self,
limit: int | None = None,
offset: int | None = None,
status: str | None = None,
main_entity_type: str | None = None,
uploader: list[int] | None = None,
benchmark_suite: int | None = None,
) -> pd.DataFrame: ...


class RunAPI(ResourceAPI):
"""Abstract API interface for run resources."""
Expand Down
1 change: 1 addition & 0 deletions openml/_api/resources/base/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ResourceType.DATASET,
ResourceType.TASK,
ResourceType.FLOW,
ResourceType.STUDY,
ResourceType.SETUP,
ResourceType.RUN,
]
Expand Down
157 changes: 154 additions & 3 deletions openml/_api/resources/study.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,162 @@
from __future__ import annotations

from .base import ResourceV1API, ResourceV2API, StudyAPI
import builtins

import pandas as pd
import xmltodict

from openml._api.resources.base import ResourceV1API, ResourceV2API, StudyAPI


class StudyV1API(ResourceV1API, StudyAPI):
"""Version 1 API implementation for study resources."""
def list( # noqa: PLR0913
self,
limit: int | None = None,
offset: int | None = None,
status: str | None = None,
main_entity_type: str | None = None,
uploader: builtins.list[int] | None = None,
benchmark_suite: int | None = None,
) -> pd.DataFrame:
"""List studies using V1 API.

Parameters
----------
limit : int, optional
Maximum number of studies to return.
offset : int, optional
Number of studies to skip.
status : str, optional
Filter by status (active, in_preparation, deactivated, all).
main_entity_type : str, optional
Filter by main entity type (run, task).
uploader : list[int], optional
Filter by uploader IDs.
benchmark_suite : int, optional
Filter by benchmark suite ID.

Returns
-------
pd.DataFrame
DataFrame containing study information.
"""
api_call = self._build_url(
limit=limit,
offset=offset,
status=status,
main_entity_type=main_entity_type,
uploader=uploader,
benchmark_suite=benchmark_suite,
)
response = self._http.get(api_call)
xml_string = response.content.decode("utf-8")
return self._parse_list_xml(xml_string)

@staticmethod
def _build_url( # noqa: PLR0913
limit: int | None = None,
offset: int | None = None,
status: str | None = None,
main_entity_type: str | None = None,
uploader: builtins.list[int] | None = None,
benchmark_suite: int | None = None,
) -> str:
"""Build the V1 API URL for listing studies.

Parameters
----------
limit : int, optional
Maximum number of studies to return.
offset : int, optional
Number of studies to skip.
status : str, optional
Filter by status (active, in_preparation, deactivated, all).
main_entity_type : str, optional
Filter by main entity type (run, task).
uploader : list[int], optional
Filter by uploader IDs.
benchmark_suite : int, optional
Filter by benchmark suite ID.

Returns
-------
str
The API call string with all filters applied.
"""
api_call = "study/list"

if limit is not None:
api_call += f"/limit/{limit}"
if offset is not None:
api_call += f"/offset/{offset}"
if status is not None:
api_call += f"/status/{status}"
if main_entity_type is not None:
api_call += f"/main_entity_type/{main_entity_type}"
if uploader is not None:
api_call += f"/uploader/{','.join(str(u) for u in uploader)}"
if benchmark_suite is not None:
api_call += f"/benchmark_suite/{benchmark_suite}"

return api_call

@staticmethod
def _parse_list_xml(xml_string: str) -> pd.DataFrame:
"""Parse the XML response from study list API.

Parameters
----------
xml_string : str
The XML response from the API.

Returns
-------
pd.DataFrame
DataFrame containing study information.
"""
study_dict = xmltodict.parse(xml_string, force_list=("oml:study",))

# Minimalistic check if the XML is useful
assert isinstance(study_dict["oml:study_list"]["oml:study"], list), type(
study_dict["oml:study_list"],
)
assert study_dict["oml:study_list"]["@xmlns:oml"] == "http://openml.org/openml", study_dict[
"oml:study_list"
]["@xmlns:oml"]

studies = {}
for study_ in study_dict["oml:study_list"]["oml:study"]:
Comment on lines +120 to +128
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

In StudyV1API._parse_list_xml, the use of bare assert statements (lines 119–124) for validating server XML responses is inappropriate for production code. Python's assert statements are removed when the interpreter runs with the -O (optimize) flag, so these checks would silently disappear in optimized environments. Server response validation should use explicit if checks that raise descriptive exceptions (e.g., ValueError or a custom exception).

Suggested change
assert isinstance(study_dict["oml:study_list"]["oml:study"], list), type(
study_dict["oml:study_list"],
)
assert study_dict["oml:study_list"]["@xmlns:oml"] == "http://openml.org/openml", study_dict[
"oml:study_list"
]["@xmlns:oml"]
studies = {}
for study_ in study_dict["oml:study_list"]["oml:study"]:
study_list = study_dict.get("oml:study_list")
if not isinstance(study_list, dict):
raise ValueError(
"Unexpected XML format: 'oml:study_list' element is missing or not a mapping.",
)
studies_xml = study_list.get("oml:study")
if not isinstance(studies_xml, list):
raise ValueError(
"Unexpected XML format: expected 'oml:study_list[\"oml:study\"]' to be a list, "
f"got {type(studies_xml).__name__!r}.",
)
expected_namespace = "http://openml.org/openml"
namespace = study_list.get("@xmlns:oml")
if namespace != expected_namespace:
raise ValueError(
"Unexpected XML namespace for 'oml:study_list': "
f"{namespace!r} (expected {expected_namespace!r}).",
)
studies = {}
for study_ in studies_xml:

Copilot uses AI. Check for mistakes.
# maps from xml name to a tuple of (dict name, casting fn)
expected_fields = {
"oml:id": ("id", int),
"oml:alias": ("alias", str),
"oml:main_entity_type": ("main_entity_type", str),
"oml:benchmark_suite": ("benchmark_suite", int),
"oml:name": ("name", str),
"oml:status": ("status", str),
"oml:creation_date": ("creation_date", str),
"oml:creator": ("creator", int),
}
study_id = int(study_["oml:id"])
current_study = {}
for oml_field_name, (real_field_name, cast_fn) in expected_fields.items():
if oml_field_name in study_:
current_study[real_field_name] = cast_fn(study_[oml_field_name])
current_study["id"] = int(current_study["id"])
studies[study_id] = current_study

return pd.DataFrame.from_dict(studies, orient="index")


class StudyV2API(ResourceV2API, StudyAPI):
"""Version 2 API implementation for study resources."""
def list( # noqa: PLR0913
self,
limit: int | None = None, # noqa: ARG002
offset: int | None = None, # noqa: ARG002
status: str | None = None, # noqa: ARG002
main_entity_type: str | None = None, # noqa: ARG002
uploader: builtins.list[int] | None = None, # noqa: ARG002
benchmark_suite: int | None = None, # noqa: ARG002
) -> pd.DataFrame:
"""V2 API for listing studies is not yet available."""
self._not_supported(method="list")
89 changes: 6 additions & 83 deletions openml/study/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import warnings
from functools import partial
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING

import pandas as pd
import xmltodict
Expand Down Expand Up @@ -336,7 +336,8 @@ def delete_study(study_id: int) -> bool:
bool
True iff the deletion was successful. False otherwise
"""
return openml.utils._delete_entity("study", study_id)
result: bool = openml._backend.study.delete(study_id)
return result


def attach_to_suite(suite_id: int, task_ids: list[int]) -> int:
Expand Down Expand Up @@ -465,7 +466,7 @@ def list_suites(
- creation_date
"""
listing_call = partial(
_list_studies,
openml._backend.study.list,
main_entity_type="task",
status=status,
uploader=uploader,
Expand All @@ -481,7 +482,7 @@ def list_studies(
offset: int | None = None,
size: int | None = None,
status: str | None = None,
uploader: list[str] | None = None,
uploader: list[int] | None = None,
benchmark_suite: int | None = None,
) -> pd.DataFrame:
"""
Expand Down Expand Up @@ -516,7 +517,7 @@ def list_studies(
these are also returned.
"""
listing_call = partial(
_list_studies,
openml._backend.study.list,
main_entity_type="run",
status=status,
uploader=uploader,
Expand All @@ -527,81 +528,3 @@ def list_studies(
return pd.DataFrame()

return pd.concat(batches)


def _list_studies(limit: int, offset: int, **kwargs: Any) -> pd.DataFrame:
"""Perform api call to return a list of studies.

Parameters
----------
limit: int
The maximum number of studies to return.
offset: int
The number of studies to skip, starting from the first.
kwargs : dict, optional
Legal filter operators (keys in the dict):
status, main_entity_type, uploader, benchmark_suite

Returns
-------
studies : dataframe
"""
api_call = "study/list"
if limit is not None:
api_call += f"/limit/{limit}"
if offset is not None:
api_call += f"/offset/{offset}"
if kwargs is not None:
for operator, value in kwargs.items():
if value is not None:
api_call += f"/{operator}/{value}"
return __list_studies(api_call=api_call)


def __list_studies(api_call: str) -> pd.DataFrame:
"""Retrieves the list of OpenML studies and
returns it in a dictionary or a Pandas DataFrame.

Parameters
----------
api_call : str
The API call for retrieving the list of OpenML studies.

Returns
-------
pd.DataFrame
A Pandas DataFrame of OpenML studies
"""
xml_string = openml._api_calls._perform_api_call(api_call, "get")
study_dict = xmltodict.parse(xml_string, force_list=("oml:study",))

# Minimalistic check if the XML is useful
assert isinstance(study_dict["oml:study_list"]["oml:study"], list), type(
study_dict["oml:study_list"],
)
assert study_dict["oml:study_list"]["@xmlns:oml"] == "http://openml.org/openml", study_dict[
"oml:study_list"
]["@xmlns:oml"]

studies = {}
for study_ in study_dict["oml:study_list"]["oml:study"]:
# maps from xml name to a tuple of (dict name, casting fn)
expected_fields = {
"oml:id": ("id", int),
"oml:alias": ("alias", str),
"oml:main_entity_type": ("main_entity_type", str),
"oml:benchmark_suite": ("benchmark_suite", int),
"oml:name": ("name", str),
"oml:status": ("status", str),
"oml:creation_date": ("creation_date", str),
"oml:creator": ("creator", int),
}
study_id = int(study_["oml:id"])
current_study = {}
for oml_field_name, (real_field_name, cast_fn) in expected_fields.items():
if oml_field_name in study_:
current_study[real_field_name] = cast_fn(study_[oml_field_name])
current_study["id"] = int(current_study["id"])
studies[study_id] = current_study

return pd.DataFrame.from_dict(studies, orient="index")
Loading
Loading