Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion examples/Advanced/datasets_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
# only for the dataset owner. Further, critical fields cannot be edited if the dataset has any
# tasks associated with it. To edit critical fields of a dataset (without tasks) owned by you,
# configure the API key:
# openml.config.apikey = 'FILL_IN_OPENML_API_KEY'
# openml.config._config.apikey = 'FILL_IN_OPENML_API_KEY'
# This example here only shows a failure when trying to work on a dataset not owned by you:

# %%
Expand Down
2 changes: 1 addition & 1 deletion examples/Basics/introduction_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# %%
import openml

openml.config.apikey = "YOURKEY"
openml.config._config.apikey = "YOURKEY"

# %% [markdown]
# ## Caching
Expand Down
4 changes: 2 additions & 2 deletions examples/_external_or_deprecated/benchmark_with_optunahub.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# account (you don't need one for anything else, just to upload your results),
# go to your profile and select the API-KEY.
# Or log in, and navigate to https://www.openml.org/auth/api-key
openml.config.apikey = ""
openml.config._config.apikey = ""
############################################################################
# Prepare for preprocessors and an OpenML task
# ============================================
Expand Down Expand Up @@ -95,7 +95,7 @@ def objective(trial: optuna.Trial) -> Pipeline:
run = openml.runs.run_model_on_task(pipe, task=task_id, avoid_duplicate_runs=False)

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

Expand Down
2 changes: 1 addition & 1 deletion examples/_external_or_deprecated/flow_id_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# %%
openml.config.start_using_configuration_for_example()
openml.config.server = "https://api.openml.org/api/v1/xml"
openml.config._config.server = "https://api.openml.org/api/v1/xml"

# %%
# Defining a classifier
Expand Down
16 changes: 8 additions & 8 deletions openml/_api_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def resolve_env_proxies(url: str) -> str | None:


def _create_url_from_endpoint(endpoint: str) -> str:
url = config.server
url = config._config.server
if not url.endswith("/"):
url += "/"
url += endpoint
Expand Down Expand Up @@ -172,7 +172,7 @@ def _download_minio_file(
bucket_name=bucket,
object_name=object_name,
file_path=str(destination),
progress=ProgressBar() if config.show_progress else None,
progress=ProgressBar() if config._config.show_progress else None,
request_headers=_HEADERS,
)
if destination.is_file() and destination.suffix == ".zip":
Expand Down Expand Up @@ -301,7 +301,7 @@ def _file_id_to_url(file_id: int, filename: str | None = None) -> str:
Presents the URL how to download a given file id
filename is optional
"""
openml_url = config.server.split("/api/")
openml_url = config._config.server.split("/api/")
url = openml_url[0] + f"/data/download/{file_id!s}"
if filename is not None:
url += "/" + filename
Expand All @@ -317,7 +317,7 @@ def _read_url_files(
and sending file_elements as files
"""
data = {} if data is None else data
data["api_key"] = config.apikey
data["api_key"] = config._config.apikey
if file_elements is None:
file_elements = {}
# Using requests.post sets header 'Accept-encoding' automatically to
Expand All @@ -337,8 +337,8 @@ def __read_url(
md5_checksum: str | None = None,
) -> requests.Response:
data = {} if data is None else data
if config.apikey:
data["api_key"] = config.apikey
if config._config.apikey:
data["api_key"] = config._config.apikey
return _send_request(
request_method=request_method,
url=url,
Expand All @@ -363,10 +363,10 @@ def _send_request( # noqa: C901, PLR0912
files: FILE_ELEMENTS_TYPE | None = None,
md5_checksum: str | None = None,
) -> requests.Response:
n_retries = max(1, config.connection_n_retries)
n_retries = max(1, config._config.connection_n_retries)

response: requests.Response | None = None
delay_method = _human_delay if config.retry_policy == "human" else _robot_delay
delay_method = _human_delay if config._config.retry_policy == "human" else _robot_delay

# Error to raise in case of retrying too often. Will be set to the last observed exception.
retry_raise_e: Exception | None = None
Expand Down
6 changes: 5 additions & 1 deletion openml/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from typing import Callable
from urllib.parse import urlparse

from attr import fields

from openml import config


Expand Down Expand Up @@ -339,7 +341,9 @@ def main() -> None:
"'https://openml.github.io/openml-python/main/usage.html#configuration'.",
)

configurable_fields = [f for f in config._defaults if f not in ["max_retries"]]
configurable_fields = [
f.name for f in fields(config.OpenMLConfig) if f.name not in ["max_retries"]
]

parser_configure.add_argument(
"field",
Expand Down
Loading
Loading