-
-
Notifications
You must be signed in to change notification settings - Fork 270
[ENH] V1 → V2 API Migration - studies #1610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rohansen856
wants to merge
277
commits into
openml:main
Choose a base branch
from
rohansen856:studies-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 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 1dbc780
merge main
satvshr 13acf35
Merge branch 'main' into studies-migration
rohansen856 e02e05b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4c75e16
undo changes in tasks/functions.py
geetu040 5762185
Merge branch 'main' into migration
geetu040 9170edc
chore: updated the list function acc to reviews
rohansen856 021a1e1
made requested changes
satvshr 4c4a12c
Merge branch 'main' into issue1564
satvshr 1d91220
made requested changes
satvshr 3e26ace
Merge branch 'issue1564' of https://github.com/satvshr/openml-python …
satvshr 0060b2e
fixed bugs
satvshr 65ba66b
fixed bugs
satvshr 317c6e9
fixed bugs
satvshr 503ab82
fixed bugs
satvshr 8c980c9
chore: removed _list_studies and implemented api_context for studies …
rohansen856 fd7ea2b
Merge branch 'main' into issue1564
satvshr fa3cd40
bug fixing
satvshr 7e9bc1f
Merge branch 'main' into migration
geetu040 c603383
add tests directory
geetu040 ff6a8b0
use enum for delay method
geetu040 f01898f
implement cache
geetu040 5c4511e
refactor clients
geetu040 9d0098f
Merge branch 'main' into issue1564
fkiraly 43276d2
fix import in resources/base.py
geetu040 1206f69
refactor and add exception handling
geetu040 bde5942
Merge branch 'main' into issue1564
satvshr 4948e99
refactor resources/base/
geetu040 a354167
implement delete
geetu040 1fe7e3e
implement publish and minor refactoring
geetu040 54a3151
implement tag/untag
geetu040 2b6fe65
implement fallback
geetu040 fa53f8d
add test_http.py
geetu040 2b2db96
add uses_test_server marker
geetu040 c9617f9
implement reset_cache
geetu040 9d2e4e4
Merge branch 'main' into studies-migration
rohansen856 e05dec5
tests: initialized tests for studies migration
rohansen856 ad64cfb
Merge branch 'studies-migration' of https://github.com/rohansen856/op…
rohansen856 5bc37b8
fixes with publish/delete
geetu040 08d9916
fix cache_key in tests
geetu040 8caba11
update _not_supported
geetu040 1913c10
add 'get_api_config' skeleton method
SimonBlanke 7681949
remove 'APISettings'
SimonBlanke 01840a5
impl. 'get_api_config'
SimonBlanke 26ed4c1
add singleton pattern for settings
SimonBlanke c588d0c
add 'reset_settings'
SimonBlanke b6ff720
remove unused code
SimonBlanke 80d5afc
reimplement usage of v1 settings config
SimonBlanke f47112c
first try v2, fallback to v1 if not available
SimonBlanke d44cf3e
reimplement singelton without the use of 'global'
SimonBlanke ea7dda1
add explanations
SimonBlanke f0e5947
change usage of settings to new impl.
SimonBlanke edcd006
add explanations
SimonBlanke cde0aae
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] aa1e560
move to config: APIVersion, ResourceType
geetu040 06b8497
remove api_context entirely
geetu040 384da91
major refactor
geetu040 735a335
refactor: updated studies migration acc to reviews
rohansen856 6b67c1f
tests: add tests for studies API migration
rohansen856 1878138
more refactoring with setup/
geetu040 dc26e01
implement APIBackend as controller
geetu040 e2d059b
move enums
geetu040 d156ad4
module level imports
geetu040 d7a3788
module level import for _backend
geetu040 b5b9ef6
module level import for tests
geetu040 68820fe
Merge branch 'main' into migration
geetu040 567eca4
add test: test_tag_and_untag
geetu040 b2287c3
implement get/set_config_values
geetu040 b7e285e
improve APIBackend.set_config_values
geetu040 fd43c48
use LegacyConfig
geetu040 f4aab6b
Revert "use LegacyConfig"
geetu040 d43cf86
implement _sync_api_config
geetu040 3e323ed
update tests with _sync_api_config
geetu040 9195fa6
rename config: timeout -> timeout_seconds
geetu040 5342eec
use timedelta for default ttl value
geetu040 adc0e74
update tests, adds v2/fallback
geetu040 bfb2d3e
add MinIOClient in TestBase
geetu040 ee10f59
refactor: replace api_context.backend.study with openml._backend.study
rohansen856 9c0ad45
chore: removed unneccesary test for studies
rohansen856 cabaecf
fix linting for builder
geetu040 85c1113
fix unbound variables: "code", "message"
geetu040 0458929
Merge branch 'migration' of https://github.com/geetu040/openml-python…
rohansen856 39bf86a
use requests.Session()
geetu040 7b66677
remove "timeout_seconds" entirely
geetu040 d2224c4
update/refactor tests
geetu040 5e3fea8
refactor: updated StudyV1API acc to reviews
rohansen856 fc32488
refactor: updated studies test acc to reviews
rohansen856 eda66ca
chore: removed delete method test from studies api test
rohansen856 18dc72a
refactor: updated study api test filename
rohansen856 9608c36
remove unused current_api_version from TestAPIBase
geetu040 f6bc7f7
make TestAPIBase inherit TestBase
geetu040 baa3a38
nits: test classes
geetu040 647a5cd
chore: updated list matches ro check proper error throw
rohansen856 52b93fe
minor fix in _sync_api_config
geetu040 ec9477f
chore: rerun CI
geetu040 ea8dae9
Merge branch 'migration' of https://github.com/geetu040/openml-python…
rohansen856 10d134a
remove duplicates in _api/resources/__init__.py
geetu040 935f0f4
implement HTTPClient.download and add tests
geetu040 9514df8
add docstrings
geetu040 85ad3df
chore: added enums file
rohansen856 f96a34c
chore: updated all test to use enums file
rohansen856 272b710
chore: fixed http test import error
rohansen856 53bee94
update minio
geetu040 33b4ca0
make delay functions static
geetu040 a6b9a45
rename: retry_raise_e -> exception
geetu040 f924b32
use context-manager for requests.Session
geetu040 541b0f2
remove "assert response is not None"
geetu040 acb173f
verify checksum before caching
geetu040 3e8d1f0
update tests
geetu040 f83bdb5
minor fix in ResourceV1API.untag
geetu040 9a7aebe
chore: updated study test acc to upstream
rohansen856 0a6e836
Merge branch 'main' into studies-migration
rohansen856 2a42712
remove cache.ttl
geetu040 001caad
replace config.cache.dir with config.cache_dir
geetu040 fb38a2d
make HTTPClient.cache compulsory
geetu040 03c4ca9
remove unused OpenMLCacheRequiredError
geetu040 8d708fd
implement and use TestAPIBase._create_resource
geetu040 4f75bba
make ResourceAPI.minio compulsory
geetu040 164f66f
Merge branch 'main' into migration
geetu040 c4dae43
rename: use_cache -> enable_cache; reset_cache -> refresh_cache
geetu040 36c20a2
use server config from TestBase
geetu040 ab3c1eb
tests: mock HTTP post calls to prevent race conditions
geetu040 2a488ca
Merge branch 'main' into migration
geetu040 599c7e1
remove hardcoded server in TestHTTPClient.test_cache
geetu040 2867862
fix docstring in _resolve_default_cache_dir
geetu040 f09f3cd
fix docstring in ResourceAPI
geetu040 5f731ce
remove duplicates in __all__
geetu040 bad7842
remove ttl related code/docs
geetu040 aefdb38
remove delay methods in HTTPClient
geetu040 0f40b02
minor fix in _resolve_default_cache_dir
geetu040 7ac1672
update FallbackProxy
geetu040 6ac1dfe
simplify _backend creation
geetu040 62924c9
Merge branch 'main' into migration
geetu040 27696bb
req changes
satvshr 190face
resolve conflicts
satvshr 95daaa6
remove old config file
satvshr 7841ea8
added OPENML_TEST_SERVER_ADMIN_KEY_ENV_VAR
satvshr cc515aa
bug fixing
satvshr e6a92df
armagh fix
satvshr 1b8c22a
update content_type check
geetu040 fc839a6
Revert "make delay functions static"
geetu040 1c922af
Revert "remove delay methods in HTTPClient"
geetu040 ffa9ce9
Merge branch 'main' into migration
geetu040 a7b2d21
allow api_key=None
geetu040 27fe790
add tests for api_key=None
geetu040 8965112
update cache not found message
geetu040 72ea1a4
update docs for path in HTTPCache
geetu040 a696c49
remove elapsed from cached meta
geetu040 755636d
move self.headers to _HEADERS
geetu040 d07af34
fix indentation in docstrings of _resolve_default_cache_dir
geetu040 2d9c8ec
Update openml/_api/clients/http.py
geetu040 002b989
Merge branch 'main' into migration
geetu040 045d896
move _handle_delete_exception and_get_endpoint_name, legal_resources
geetu040 c437966
set HTTPClient.headers
geetu040 e27470a
remove main_tag
geetu040 d04d956
remove and merge TestAPIBase into TestBase
geetu040 9263f7f
minor change in TestHTTPClient.test_cache
geetu040 79dea29
make HTTPClient.request private
geetu040 f6497c2
Revert "update FallbackProxy"
geetu040 dce7f54
use st_ctime instead of st_ctime for cache refresh test
geetu040 40dd460
Merge branch 'main' into issue1564
geetu040 0fc917c
majore config refactor
geetu040 3d86b18
Merge branch 'pr-1577' into migration
geetu040 aba3d3e
update _config.py
geetu040 d99d54d
update test_openml_cache_dir_env_var
geetu040 dc22e3a
fix mutable SERVERS_REGISTRY
geetu040 7318573
update set_api_version for fallback
geetu040 29ef187
minor fix
geetu040 cf94c89
fixes for test_config
geetu040 298fbda
fixes in conftest urls
geetu040 9870502
update test_http.py
geetu040 33065c2
undo changes with test_openml_cache_dir_env_var
geetu040 76b92bb
fix server mode in test_config.py
geetu040 419edcb
move _HEADERS to confing
geetu040 cb6d937
add fixtures for migration tests
geetu040 8544c8a
update test_http.py with fixtures
geetu040 d4c413b
update test_versions.py
geetu040 fab1a15
update test_versions.py
geetu040 276324a
fix error message in HTTPClient.server
geetu040 73f7594
fixes in test_versions.py: use DummyTaskAPI instead of TaskAPI
geetu040 2ee7fa3
add clients in openml._backend
geetu040 4be5bbd
fixes with openml.config.[server|apikey] leakage
geetu040 9027c01
remove unused fixtures: use_api_[v1|v2]
geetu040 e5461a9
add more config tests
geetu040 7d899a9
make SERVERS_REGISTRY private
geetu040 8587414
fix marker: uses_test_server->test_server
geetu040 23a3450
fix UserWarning
geetu040 ac28f82
update fixture: with_server
geetu040 3ce1095
sync with base
rohansen856 a110fa0
Merge branch 'migration' of https://github.com/geetu040/openml-python…
rohansen856 18f31f7
Merge branch 'studies-migration' of https://github.com/rohansen856/op…
rohansen856 b1ddc93
chore: updated tests for studies
rohansen856 960e601
chore: fixed circular import errors
rohansen856 677051b
chore: up[dated conftest for ci errors
rohansen856 68f3ff6
chore: fixed module import errors
rohansen856 2e1cdcf
chore: fixed minio import errors
rohansen856 96cee47
ci errors fix
rohansen856 4a66245
req changes
satvshr c762fb4
Merge branch 'issue1564' of https://github.com/satvshr/openml-python …
satvshr 77c21f2
Update openml/_api/clients/http.py
geetu040 eac24fc
Update tests/test_api/test_http.py
geetu040 2ed65fe
update test_get_uses_cached_response
geetu040 f3b07de
test_get_with_api_key
geetu040 29db3f1
use .arff instead of .bin in tests
geetu040 3b4e538
update test_download_creates_file to use md5_checksum
geetu040 8ac886b
update test_download_is_cached_on_disk
geetu040 305f4f0
update APIBackendBuilder
geetu040 b2bf164
Merge branch 'main' into migration
geetu040 e97e6c2
Update openml/_api/clients/http.py
geetu040 c66d73c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] aa54e8e
pre-commit fixes
geetu040 2d452d3
Merge branch 'main' into issue1564
geetu040 c235812
Merge branch 'main' into issue1564
fkiraly 39eb823
Trigger CI
satvshr 50eed37
Merge branch 'main' into migration
geetu040 7a000eb
Merge branch 'main' into issue1564
geetu040 f120c19
Merge branch 'main' into studies-migration
rohansen856 79f6187
Merge branch 'main' into issue1564
geetu040 adea726
Merge branch 'main' into studies-migration
rohansen856 242e420
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b1a9e7f
Merge branch 'pr-1577' into migration (merge conflicts)
geetu040 d716ecf
update server methods in config
geetu040 3c29e71
fix api-version leakage in tests
geetu040 b4ff0b2
remove unused migration code
geetu040 93155ee
debug ci: separate cache for each test-case
geetu040 d3cc9a7
update port for localhost
geetu040 a6b82f4
Revert "debug ci: separate cache for each test-case"
geetu040 3419973
rerun CI
geetu040 8de99b7
Merge branch 'main' into migration
geetu040 7d61107
create enum ServerMode
geetu040 1ecbbba
update config for ServerMode
geetu040 65472ed
update tests for ServerMode
geetu040 a0a3b61
Merge branch 'main' into studies-migration
rohansen856 33858a7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a704bb0
chore: fixed pre commit errors
rohansen856 3470cb5
chore: fixed mypy errors
rohansen856 44b48b5
udpate apikey in _TEST_SERVERS_LOCAL
geetu040 62c3d3d
CI trigger
rohansen856 c93b97f
chore: fixed missing header in OpenMLConfigManager
rohansen856 972987b
chore: fixed server key issue in test
rohansen856 04bc83b
fix: remove duplicate server name in cache path
geetu040 f926092
test: remove check for ":" since windows CI expects it
geetu040 083194b
Merge branch 'migration' of https://github.com/geetu040/openml-python…
rohansen856 c224532
Merge branch 'main' into studies-migration (resolve conflicts)
geetu040 3953fdf
chore: added missing argument in studies api test
rohansen856 c2d8487
chore: updated resource base to enable tagging for studies
rohansen856 edf8524
chore: updated acc to reviews
rohansen856 ca2cdc5
Merge branch 'main' into studies-migration
rohansen856 6f30a45
chore: updated tests acc to review
rohansen856 03ea718
Merge branch 'studies-migration' of https://github.com/rohansen856/op…
rohansen856 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from openml._api.runtime.core import APIContext | ||
|
|
||
|
|
||
| def set_api_version(version: str, *, strict: bool = False) -> None: | ||
| api_context.set_version(version=version, strict=strict) | ||
|
|
||
|
|
||
| api_context = APIContext() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import Literal | ||
|
|
||
| DelayMethod = Literal["human", "robot"] | ||
|
|
||
|
|
||
| @dataclass | ||
| class APIConfig: | ||
| server: str | ||
| base_url: str | ||
| key: str | ||
| timeout: int = 10 # seconds | ||
|
|
||
|
|
||
| @dataclass | ||
| class APISettings: | ||
| v1: APIConfig | ||
| v2: APIConfig | ||
|
|
||
|
|
||
| @dataclass | ||
| class ConnectionConfig: | ||
| retries: int = 3 | ||
| delay_method: DelayMethod = "human" | ||
| delay_time: int = 1 # seconds | ||
|
|
||
| def __post_init__(self) -> None: | ||
| if self.delay_method not in ("human", "robot"): | ||
| raise ValueError(f"delay_method must be 'human' or 'robot', got {self.delay_method}") | ||
|
|
||
|
|
||
| @dataclass | ||
| class CacheConfig: | ||
| dir: str = "~/.openml/cache" | ||
| ttl: int = 60 * 60 * 24 * 7 # one week | ||
|
|
||
|
|
||
| @dataclass | ||
| class Settings: | ||
| api: APISettings | ||
| connection: ConnectionConfig | ||
| cache: CacheConfig | ||
|
|
||
|
|
||
| settings = Settings( | ||
| api=APISettings( | ||
| v1=APIConfig( | ||
| server="https://www.openml.org/", | ||
| base_url="api/v1/xml/", | ||
| key="...", | ||
| ), | ||
| v2=APIConfig( | ||
| server="http://127.0.0.1:8001/", | ||
| base_url="", | ||
| key="...", | ||
| ), | ||
| ), | ||
| connection=ConnectionConfig(), | ||
| cache=CacheConfig(), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from openml._api.http.client import HTTPClient | ||
|
|
||
| __all__ = ["HTTPClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| from typing import TYPE_CHECKING, Any | ||
| from urllib.parse import urlencode, urljoin, urlparse | ||
|
|
||
| import requests | ||
| from requests import Response | ||
|
|
||
| from openml.__version__ import __version__ | ||
| from openml._api.config import settings | ||
|
|
||
| if TYPE_CHECKING: | ||
| from openml._api.config import APIConfig | ||
|
|
||
|
|
||
| class CacheMixin: | ||
| @property | ||
| def dir(self) -> str: | ||
| return settings.cache.dir | ||
|
|
||
| @property | ||
| def ttl(self) -> int: | ||
| return settings.cache.ttl | ||
|
|
||
| def _get_cache_dir(self, url: str, params: dict[str, Any]) -> Path: | ||
| parsed_url = urlparse(url) | ||
| netloc_parts = parsed_url.netloc.split(".")[::-1] # reverse domain | ||
| path_parts = parsed_url.path.strip("/").split("/") | ||
|
|
||
| # remove api_key and serialize params if any | ||
| filtered_params = {k: v for k, v in params.items() if k != "api_key"} | ||
| params_part = [urlencode(filtered_params)] if filtered_params else [] | ||
|
|
||
| return Path(self.dir).joinpath(*netloc_parts, *path_parts, *params_part) | ||
|
|
||
| def _get_cache_response(self, cache_dir: Path) -> Response: # noqa: ARG002 | ||
| return Response() | ||
|
|
||
| def _set_cache_response(self, cache_dir: Path, response: Response) -> None: # noqa: ARG002 | ||
| return None | ||
|
|
||
|
|
||
| class HTTPClient(CacheMixin): | ||
| def __init__(self, config: APIConfig) -> None: | ||
| self.config = config | ||
| self.headers: dict[str, str] = {"user-agent": f"openml-python/{__version__}"} | ||
|
|
||
| @property | ||
| def server(self) -> str: | ||
| return self.config.server | ||
|
|
||
| @property | ||
| def base_url(self) -> str: | ||
| return self.config.base_url | ||
|
|
||
| @property | ||
| def key(self) -> str: | ||
| return self.config.key | ||
|
|
||
| @property | ||
| def timeout(self) -> int: | ||
| return self.config.timeout | ||
|
|
||
| def request( | ||
| self, | ||
| method: str, | ||
| path: str, | ||
| *, | ||
| use_cache: bool = False, | ||
| use_api_key: bool = False, | ||
| **request_kwargs: Any, | ||
| ) -> Response: | ||
| url = urljoin(self.server, urljoin(self.base_url, path)) | ||
|
|
||
| params = request_kwargs.pop("params", {}) | ||
| params = params.copy() | ||
| if use_api_key: | ||
| params["api_key"] = self.key | ||
|
|
||
| headers = request_kwargs.pop("headers", {}) | ||
| headers = headers.copy() | ||
| headers.update(self.headers) | ||
|
|
||
| timeout = request_kwargs.pop("timeout", self.timeout) | ||
| cache_dir = self._get_cache_dir(url, params) | ||
|
|
||
| if use_cache: | ||
| try: | ||
| return self._get_cache_response(cache_dir) | ||
| # TODO: handle ttl expired error | ||
| except Exception: | ||
| raise | ||
|
|
||
| response = requests.request( | ||
| method=method, | ||
| url=url, | ||
| params=params, | ||
| headers=headers, | ||
| timeout=timeout, | ||
| **request_kwargs, | ||
| ) | ||
|
|
||
| if use_cache: | ||
| self._set_cache_response(cache_dir, response) | ||
|
|
||
| return response | ||
|
|
||
| def get( | ||
| self, | ||
| path: str, | ||
| *, | ||
| use_cache: bool = False, | ||
| use_api_key: bool = False, | ||
| **request_kwargs: Any, | ||
| ) -> Response: | ||
| # TODO: remove override when cache is implemented | ||
| use_cache = False | ||
| return self.request( | ||
| method="GET", | ||
| path=path, | ||
| use_cache=use_cache, | ||
| use_api_key=use_api_key, | ||
| **request_kwargs, | ||
| ) | ||
|
|
||
| def post( | ||
| self, | ||
| path: str, | ||
| **request_kwargs: Any, | ||
| ) -> Response: | ||
| return self.request( | ||
| method="POST", | ||
| path=path, | ||
| use_cache=False, | ||
| use_api_key=True, | ||
| **request_kwargs, | ||
| ) | ||
|
|
||
| def delete( | ||
| self, | ||
| path: str, | ||
| **request_kwargs: Any, | ||
| ) -> Response: | ||
| return self.request( | ||
| method="DELETE", | ||
| path=path, | ||
| use_cache=False, | ||
| use_api_key=True, | ||
| **request_kwargs, | ||
| ) |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from openml._api.resources.datasets import DatasetsV1, DatasetsV2 | ||
| from openml._api.resources.studies import StudiesV1, StudiesV2 | ||
| from openml._api.resources.tasks import TasksV1, TasksV2 | ||
|
|
||
| __all__ = ["DatasetsV1", "DatasetsV2", "StudiesV1", "StudiesV2", "TasksV1", "TasksV2"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| if TYPE_CHECKING: | ||
| from requests import Response | ||
|
|
||
| from openml._api.http import HTTPClient | ||
| from openml.datasets.dataset import OpenMLDataset | ||
| from openml.tasks.task import OpenMLTask | ||
|
|
||
|
|
||
| class ResourceAPI: | ||
| def __init__(self, http: HTTPClient): | ||
| self._http = http | ||
|
|
||
|
|
||
| class DatasetsAPI(ResourceAPI, ABC): | ||
| @abstractmethod | ||
| def get(self, dataset_id: int) -> OpenMLDataset | tuple[OpenMLDataset, Response]: ... | ||
|
|
||
|
|
||
| class TasksAPI(ResourceAPI, ABC): | ||
| @abstractmethod | ||
| def get( | ||
| self, | ||
| task_id: int, | ||
| *, | ||
| return_response: bool = False, | ||
| ) -> OpenMLTask | tuple[OpenMLTask, Response]: ... | ||
|
|
||
|
|
||
| class StudiesAPI(ResourceAPI, ABC): | ||
| @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, | ||
| ) -> Any: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from openml._api.resources.base import DatasetsAPI | ||
|
|
||
| if TYPE_CHECKING: | ||
| from responses import Response | ||
|
|
||
| from openml.datasets.dataset import OpenMLDataset | ||
|
|
||
|
|
||
| class DatasetsV1(DatasetsAPI): | ||
| def get(self, dataset_id: int) -> OpenMLDataset | tuple[OpenMLDataset, Response]: | ||
| raise NotImplementedError | ||
|
|
||
|
|
||
| class DatasetsV2(DatasetsAPI): | ||
| def get(self, dataset_id: int) -> OpenMLDataset | tuple[OpenMLDataset, Response]: | ||
| raise NotImplementedError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from openml._api.resources.base import StudiesAPI | ||
|
|
||
|
|
||
| class StudiesV1(StudiesAPI): | ||
| 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, | ||
| ) -> Any: | ||
| 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}" | ||
|
|
||
| # Make the GET request and return the XML text | ||
| response = self._http.get(api_call) | ||
| return response.text | ||
|
|
||
|
|
||
| class StudiesV2(StudiesAPI): | ||
| 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, | ||
| ) -> Any: | ||
| raise NotImplementedError("V2 API implementation is not yet available") | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see point 8 in #1575 (comment)