-
-
Notifications
You must be signed in to change notification settings - Fork 271
[ENH] V1 → V2 API Migration - setups #1619
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
EmanAbdelhaleem
wants to merge
264
commits into
openml:main
Choose a base branch
from
EmanAbdelhaleem:setups-mig
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 all commits
Commits
Show all changes
264 commits
Select commit
Hold shift + click to select a range
52ef379
fix pre-commit
geetu040 146dd21
Update all files
satvshr 7a67bf0
Update introduction_tutorial.py
satvshr 5dfcbce
refactor
geetu040 2acbe99
implement cache_dir
geetu040 af99880
refactor
geetu040 b111905
Merge branch 'main' into pr/1577
fkiraly 83f36c2
Merge branch 'issue1564' of https://github.com/satvshr/openml-python …
fkiraly 74ab366
Merge branch 'main' into pr/1576
fkiraly 4241624
bug fixing
satvshr f01c1e9
Update test_utils.py
satvshr 07cc1c8
Update test_config.py
satvshr 1dbc780
merge main
satvshr 4c75e16
undo changes in tasks/functions.py
geetu040 5762185
Merge branch 'main' into migration
geetu040 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 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 4a3a638
[ENH] V1 → V2 API Migration - setups
EmanAbdelhaleem d07e4a6
get, exists setup migration
EmanAbdelhaleem 42d067a
sync with pr-1576
EmanAbdelhaleem c9617f9
implement reset_cache
geetu040 178cd8b
added partial tests
EmanAbdelhaleem 8c23ab8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 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 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 51aa433
use_cashe, push_tag, remove_tag
EmanAbdelhaleem 23f6ca3
added tests
EmanAbdelhaleem 72c1d8e
removed caching tests
EmanAbdelhaleem 0364bff
Merge branch 'setups-mig' of github.com:EmanAbdelhaleem/openml-python…
EmanAbdelhaleem 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 cabaecf
fix linting for builder
geetu040 f9f31bd
Merge branch 'pr-1576' into setups-mig
EmanAbdelhaleem 81058b7
final commit
EmanAbdelhaleem 7512e0f
Merge branch 'pr-1576' into setups-mig
EmanAbdelhaleem db79a7f
[ENH] V1 -> V2 Migration - Setups
EmanAbdelhaleem a2e2361
update client confit in test_setup
EmanAbdelhaleem 85c1113
fix unbound variables: "code", "message"
geetu040 39bf86a
use requests.Session()
geetu040 7b66677
remove "timeout_seconds" entirely
geetu040 d2224c4
update/refactor tests
geetu040 9608c36
remove unused current_api_version from TestAPIBase
geetu040 f6bc7f7
make TestAPIBase inherit TestBase
geetu040 baa3a38
nits: test classes
geetu040 9c3d3a5
Merge branch 'pr-1576' into setups-mig
EmanAbdelhaleem 52b93fe
minor fix in _sync_api_config
geetu040 ec9477f
chore: rerun CI
geetu040 1f40bf5
update exists method, added _to_dict() to the setups resource
EmanAbdelhaleem 1b63cb1
updated api tests to use http_client, corrected exists tests
EmanAbdelhaleem 2cee514
moved `@pytest.mark.uses_test_server()
EmanAbdelhaleem 10d134a
remove duplicates in _api/resources/__init__.py
geetu040 935f0f4
implement HTTPClient.download and add tests
geetu040 9514df8
add docstrings
geetu040 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 d11597b
update tests
EmanAbdelhaleem 9f6df70
Merge branch 'pr-1576' into setups-mig
EmanAbdelhaleem 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 bdd4258
Merge branch 'pr-1576' into setups-mig
EmanAbdelhaleem d6c315c
update tests
EmanAbdelhaleem 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 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 79f6187
Merge branch 'main' into issue1564
geetu040 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 44b48b5
udpate apikey in _TEST_SERVERS_LOCAL
geetu040 5943720
Merge branch 'migration' into setups-mig
geetu040 1cfacac
fix marker
geetu040 04bc83b
fix: remove duplicate server name in cache path
geetu040 f926092
test: remove check for ":" since windows CI expects it
geetu040 a72d73a
Merge branch 'migration' into setups-mig
geetu040 8105a1d
Merge branch 'main' into setups-mig
geetu040 354e86f
remove _create_setup
geetu040 18e1046
add cache test
geetu040 23963ff
update cache test
geetu040 98a50fd
update cache files for setup::1
geetu040 fcf7c0f
update _expected_static_cache_state
geetu040 bc10ac6
Merge branch 'main' into setups-mig
geetu040 14f4853
Update openml/_api/resources/setup.py
geetu040 ddf79ff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9575480
make private methods static
geetu040 80e8fd4
update v2 tests
geetu040 be4e652
use uuid in tests
geetu040 fd1a5f4
Merge remote-tracking branch 'refs/remotes/eman/setups-mig' into setu…
geetu040 801c16f
rerun ci
geetu040 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
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 |
|---|---|---|
| @@ -1,11 +1,280 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import builtins | ||
| from collections import OrderedDict | ||
| from collections.abc import Iterable | ||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| import xmltodict | ||
|
|
||
| from openml.setups.setup import OpenMLParameter, OpenMLSetup | ||
|
|
||
| from .base import ResourceV1API, ResourceV2API, SetupAPI | ||
|
|
||
| if TYPE_CHECKING: | ||
| from openml.flows.flow import OpenMLFlow | ||
|
|
||
|
|
||
| class SetupV1API(ResourceV1API, SetupAPI): | ||
| """Version 1 API implementation for setup resources.""" | ||
| """V1 XML API implementation for setups.""" | ||
|
|
||
| @staticmethod | ||
| def _build_url( | ||
| limit: int, | ||
| offset: int, | ||
| *, | ||
| setup: Iterable[int] | None = None, | ||
| flow: int | None = None, | ||
| tag: str | None = None, | ||
| ) -> str: | ||
| """Construct an OpenML Setup API URL with filtering parameters. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| The setup argument that is a list is separated from the single value | ||
| filters which are put into the kwargs. | ||
|
|
||
| limit : int | ||
| offset : int | ||
| setup : list(int), optional | ||
| flow : int, optional | ||
| tag : str, optional | ||
|
|
||
| Returns | ||
| ------- | ||
| str | ||
| A relative API path suitable for an OpenML HTTP request. | ||
| """ | ||
| api_call = "setup/list" | ||
| if limit is not None: | ||
| api_call += f"/limit/{limit}" | ||
| if offset is not None: | ||
| api_call += f"/offset/{offset}" | ||
| if setup is not None: | ||
| api_call += f"/setup/{','.join([str(int(i)) for i in setup])}" | ||
| if flow is not None: | ||
| api_call += f"/flow/{flow}" | ||
| if tag is not None: | ||
| api_call += f"/tag/{tag}" | ||
|
|
||
| return api_call | ||
|
|
||
| @staticmethod | ||
| def _parse_list_xml(xml_content: str) -> builtins.list[OpenMLSetup]: | ||
| """Helper function to parse API calls which are lists of setups""" | ||
| setups_dict = xmltodict.parse(xml_content, force_list=("oml:setup",)) | ||
| openml_uri = "http://openml.org/openml" | ||
| # Minimalistic check if the XML is useful | ||
| if "oml:setups" not in setups_dict: | ||
| raise ValueError( | ||
| f'Error in return XML, does not contain "oml:setups": {setups_dict!s}', | ||
| ) | ||
|
|
||
| if "@xmlns:oml" not in setups_dict["oml:setups"]: | ||
| raise ValueError( | ||
| f'Error in return XML, does not contain "oml:setups"/@xmlns:oml: {setups_dict!s}', | ||
| ) | ||
|
|
||
| if setups_dict["oml:setups"]["@xmlns:oml"] != openml_uri: | ||
| raise ValueError( | ||
| "Error in return XML, value of " | ||
| '"oml:seyups"/@xmlns:oml is not ' | ||
| f'"{openml_uri}": {setups_dict!s}', | ||
| ) | ||
|
|
||
| assert isinstance(setups_dict["oml:setups"]["oml:setup"], list), type( | ||
| setups_dict["oml:setups"] | ||
| ) | ||
|
|
||
| return [ | ||
| SetupV1API._create_setup({"oml:setup_parameters": setup_}) | ||
| for setup_ in setups_dict["oml:setups"]["oml:setup"] | ||
| ] | ||
|
|
||
| @staticmethod | ||
| def _create_setup(result_dict: dict) -> OpenMLSetup: | ||
| """Turns an API xml result into a OpenMLSetup object (or dict)""" | ||
| setup_id = int(result_dict["oml:setup_parameters"]["oml:setup_id"]) | ||
| flow_id = int(result_dict["oml:setup_parameters"]["oml:flow_id"]) | ||
|
|
||
| if "oml:parameter" not in result_dict["oml:setup_parameters"]: | ||
| return OpenMLSetup(setup_id, flow_id, parameters=None) | ||
|
|
||
| xml_parameters = result_dict["oml:setup_parameters"]["oml:parameter"] | ||
| if isinstance(xml_parameters, dict): | ||
| xml_parameters = [xml_parameters] | ||
| if not isinstance(xml_parameters, list): | ||
| raise ValueError( | ||
| f"Expected None, list or dict, received something else: {type(xml_parameters)!s}", | ||
| ) | ||
|
|
||
| parameters = { | ||
| int(xml_parameter["oml:id"]): SetupV1API._create_setup_parameter_from_xml(xml_parameter) | ||
| for xml_parameter in xml_parameters | ||
| } | ||
| return OpenMLSetup(setup_id, flow_id, parameters) | ||
|
|
||
| @staticmethod | ||
| def _create_setup_parameter_from_xml(result_dict: dict[str, str]) -> OpenMLParameter: | ||
| """Create an OpenMLParameter object or a dictionary from an API xml result.""" | ||
| return OpenMLParameter( | ||
| input_id=int(result_dict["oml:id"]), | ||
| flow_id=int(result_dict["oml:flow_id"]), | ||
| flow_name=result_dict["oml:flow_name"], | ||
| full_name=result_dict["oml:full_name"], | ||
| parameter_name=result_dict["oml:parameter_name"], | ||
| data_type=result_dict["oml:data_type"], | ||
| default_value=result_dict["oml:default_value"], | ||
| value=result_dict["oml:value"], | ||
| ) | ||
|
|
||
| @staticmethod | ||
| def _to_dict( | ||
| flow_id: int, openml_parameter_settings: builtins.list[dict[str, Any]] | ||
| ) -> OrderedDict: | ||
| """Convert a flow ID and a list of OpenML parameter settings to | ||
| a dictionary representation that can be serialized to XML. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| flow_id : int | ||
| ID of the flow. | ||
| openml_parameter_settings : list[dict[str, Any]] | ||
| A list of OpenML parameter settings. | ||
|
|
||
| Returns | ||
| ------- | ||
| OrderedDict | ||
| A dictionary representation of the flow ID and parameter settings. | ||
| """ | ||
| # for convenience, this function (ab)uses the run object. | ||
| xml: OrderedDict = OrderedDict() | ||
| xml["oml:run"] = OrderedDict() | ||
| xml["oml:run"]["@xmlns:oml"] = "http://openml.org/openml" | ||
| xml["oml:run"]["oml:flow_id"] = flow_id | ||
| xml["oml:run"]["oml:parameter_setting"] = openml_parameter_settings | ||
|
|
||
| return xml | ||
|
|
||
| def list( | ||
| self, | ||
| limit: int, | ||
| offset: int, | ||
| *, | ||
| setup: Iterable[int] | None = None, | ||
| flow: int | None = None, | ||
| tag: str | None = None, | ||
| ) -> builtins.list[OpenMLSetup]: | ||
| """Perform API call `/setup/list/{filters}` | ||
|
|
||
| Parameters | ||
| ---------- | ||
| The setup argument that is a list is separated from the single value | ||
| filters which are put into the kwargs. | ||
|
|
||
| limit : int | ||
| offset : int | ||
| setup : list(int), optional | ||
| flow : int, optional | ||
| tag : str, optional | ||
|
|
||
| Returns | ||
| ------- | ||
| list | ||
| setups that match the filters, going from id to the OpenMLSetup object. | ||
| """ | ||
| api_call = SetupV1API._build_url(limit, offset, setup=setup, flow=flow, tag=tag) | ||
| setup_response = self._http.get(api_call) | ||
| xml_content = setup_response.text | ||
|
|
||
| return SetupV1API._parse_list_xml(xml_content) | ||
|
|
||
| def get(self, setup_id: int) -> OpenMLSetup: | ||
| """ | ||
| Downloads the setup (configuration) description from OpenML | ||
| and returns a structured object | ||
|
|
||
| Parameters | ||
| ---------- | ||
| setup_id : int | ||
| The Openml setup_id | ||
|
|
||
| Returns | ||
| ------- | ||
| OpenMLSetup | ||
| An initialized OpenMLSetup object parsed from the XML | ||
| """ | ||
| url_suffix = f"setup/{setup_id}" | ||
| setup_response = self._http.get(url_suffix, enable_cache=True) | ||
| xml_content = setup_response.text | ||
| result_dict = xmltodict.parse(xml_content) | ||
|
|
||
| return SetupV1API._create_setup(result_dict) | ||
|
|
||
| def exists( | ||
| self, | ||
| flow: OpenMLFlow, | ||
| param_settings: builtins.list[dict[str, Any]], | ||
| ) -> int | bool: | ||
| """ | ||
| Checks whether a hyperparameter configuration already exists on the server. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| flow : OpenMLFlow | ||
| The openml flow object. Should have flow id present for the main flow | ||
| and all subflows (i.e., it should be downloaded from the server by | ||
| means of flow.get, and not instantiated locally) | ||
|
|
||
| list : | ||
| A list of dicts, where each dict has the following entries: | ||
| oml:name : str: The OpenML parameter name | ||
| oml:value : mixed: A representation of the parameter value | ||
| oml:component : int: flow id to which the parameter belongs | ||
|
|
||
| Returns | ||
| ------- | ||
| setup_id : int | ||
| setup id iff exists, False otherwise | ||
| """ | ||
| if flow.flow_id is None: | ||
| raise ValueError("Flow must have a flow_id") | ||
| description = xmltodict.unparse( | ||
| SetupV1API._to_dict(flow.flow_id, param_settings), pretty=True | ||
| ) | ||
| file_elements = { | ||
| "description": ("description.arff", description), | ||
| } | ||
|
|
||
| api_call = "setup/exists/" | ||
| setup_response = self._http.post(api_call, files=file_elements) | ||
| xml_content = setup_response.text | ||
| result_dict = xmltodict.parse(xml_content) | ||
|
|
||
| setup_id = int(result_dict["oml:setup_exists"]["oml:id"]) | ||
| return setup_id if setup_id > 0 else False | ||
|
|
||
|
|
||
| class SetupV2API(ResourceV2API, SetupAPI): | ||
| """Version 2 API implementation for setup resources.""" | ||
| """V2 JSoN API implementation for setups.""" | ||
|
|
||
| def list( | ||
| self, | ||
| limit: int, # noqa: ARG002 | ||
| offset: int, # noqa: ARG002 | ||
| *, | ||
| setup: Iterable[int] | None = None, # noqa: ARG002 | ||
| flow: int | None = None, # noqa: ARG002 | ||
| tag: str | None = None, # noqa: ARG002 | ||
| ) -> builtins.list[OpenMLSetup]: | ||
| self._not_supported(method="list") | ||
|
|
||
| def get(self, setup_id: int) -> OpenMLSetup: # noqa: ARG002 | ||
| self._not_supported(method="get") | ||
|
|
||
| def exists( | ||
| self, | ||
| flow: OpenMLFlow, # noqa: ARG002 | ||
| param_settings: builtins.list[dict[str, Any]], # noqa: ARG002 | ||
| ) -> int | bool: | ||
| self._not_supported(method="exists") | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.