Skip to content

Commit 146dd21

Browse files
committed
Update all files
1 parent b3513f0 commit 146dd21

16 files changed

Lines changed: 443 additions & 492 deletions

File tree

examples/Advanced/datasets_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
# only for the dataset owner. Further, critical fields cannot be edited if the dataset has any
140140
# tasks associated with it. To edit critical fields of a dataset (without tasks) owned by you,
141141
# configure the API key:
142-
# openml.config._config.apikey = 'FILL_IN_OPENML_API_KEY'
142+
# openml.config.apikey = 'FILL_IN_OPENML_API_KEY'
143143
# This example here only shows a failure when trying to work on a dataset not owned by you:
144144

145145
# %%

examples/Basics/introduction_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# %%
3636
import openml
3737

38-
openml.config._config.apikey = "YOURKEY"
38+
openml.config.apikey = "YOURKEY"
3939

4040
# %% [markdown]
4141
# ## Caching
@@ -52,4 +52,4 @@
5252
# %%
5353
import openml
5454

55-
openml.config.set_root_cache_directory("YOURDIR")
55+
openml.config.set_root_cache_directory("YOURDIR")

examples/_external_or_deprecated/benchmark_with_optunahub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# account (you don't need one for anything else, just to upload your results),
4545
# go to your profile and select the API-KEY.
4646
# Or log in, and navigate to https://www.openml.org/auth/api-key
47-
openml.config._config.apikey = ""
47+
openml.config.apikey = ""
4848
############################################################################
4949
# Prepare for preprocessors and an OpenML task
5050
# ============================================
@@ -95,7 +95,7 @@ def objective(trial: optuna.Trial) -> Pipeline:
9595
run = openml.runs.run_model_on_task(pipe, task=task_id, avoid_duplicate_runs=False)
9696

9797
logger.log(1, f"Model has been trained - {run}")
98-
if openml.config._config.apikey != "":
98+
if openml.config.apikey != "":
9999
try:
100100
run.publish()
101101

examples/_external_or_deprecated/flow_id_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# %%
1818
openml.config.start_using_configuration_for_example()
19-
openml.config._config.server = "https://api.openml.org/api/v1/xml"
19+
openml.config.server = "https://api.openml.org/api/v1/xml"
2020

2121
# %%
2222
# Defining a classifier

openml/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
# License: BSD 3-Clause
1919
from __future__ import annotations
2020

21+
from typing import TYPE_CHECKING
22+
2123
from . import (
2224
_api_calls,
23-
config,
25+
config as _config_module,
2426
datasets,
2527
evaluations,
2628
exceptions,
@@ -49,6 +51,11 @@
4951
OpenMLTask,
5052
)
5153

54+
if TYPE_CHECKING:
55+
from .config import OpenMLConfigManager
56+
57+
config: OpenMLConfigManager = _config_module._config
58+
5259

5360
def populate_cache(
5461
task_ids: list[int] | None = None,

openml/_api_calls.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import xml
1313
import zipfile
1414
from pathlib import Path
15-
from typing import Dict, Tuple, Union
15+
from typing import Dict, Tuple, Union, cast
1616

1717
import minio
1818
import requests
@@ -71,7 +71,7 @@ def resolve_env_proxies(url: str) -> str | None:
7171

7272

7373
def _create_url_from_endpoint(endpoint: str) -> str:
74-
url = config._config.server
74+
url = cast(str, config.server)
7575
if not url.endswith("/"):
7676
url += "/"
7777
url += endpoint
@@ -172,7 +172,7 @@ def _download_minio_file(
172172
bucket_name=bucket,
173173
object_name=object_name,
174174
file_path=str(destination),
175-
progress=ProgressBar() if config._config.show_progress else None,
175+
progress=ProgressBar() if config.show_progress else None,
176176
request_headers=_HEADERS,
177177
)
178178
if destination.is_file() and destination.suffix == ".zip":
@@ -301,7 +301,8 @@ def _file_id_to_url(file_id: int, filename: str | None = None) -> str:
301301
Presents the URL how to download a given file id
302302
filename is optional
303303
"""
304-
openml_url = config._config.server.split("/api/")
304+
openml_server = cast(str, config.server)
305+
openml_url = openml_server.split("/api/")
305306
url = openml_url[0] + f"/data/download/{file_id!s}"
306307
if filename is not None:
307308
url += "/" + filename
@@ -317,7 +318,7 @@ def _read_url_files(
317318
and sending file_elements as files
318319
"""
319320
data = {} if data is None else data
320-
data["api_key"] = config._config.apikey
321+
data["api_key"] = config.apikey
321322
if file_elements is None:
322323
file_elements = {}
323324
# Using requests.post sets header 'Accept-encoding' automatically to
@@ -337,8 +338,8 @@ def __read_url(
337338
md5_checksum: str | None = None,
338339
) -> requests.Response:
339340
data = {} if data is None else data
340-
if config._config.apikey:
341-
data["api_key"] = config._config.apikey
341+
if config.apikey:
342+
data["api_key"] = config.apikey
342343
return _send_request(
343344
request_method=request_method,
344345
url=url,
@@ -363,10 +364,10 @@ def _send_request( # noqa: C901, PLR0912
363364
files: FILE_ELEMENTS_TYPE | None = None,
364365
md5_checksum: str | None = None,
365366
) -> requests.Response:
366-
n_retries = max(1, config._config.connection_n_retries)
367+
n_retries = max(1, config.connection_n_retries)
367368

368369
response: requests.Response | None = None
369-
delay_method = _human_delay if config._config.retry_policy == "human" else _robot_delay
370+
delay_method = _human_delay if config.retry_policy == "human" else _robot_delay
370371

371372
# Error to raise in case of retrying too often. Will be set to the last observed exception.
372373
retry_raise_e: Exception | None = None

0 commit comments

Comments
 (0)