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
9 changes: 8 additions & 1 deletion openml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
# License: BSD 3-Clause
from __future__ import annotations

from typing import TYPE_CHECKING

from . import (
_api_calls,
config,
config as _config_module,
datasets,
evaluations,
exceptions,
Expand Down Expand Up @@ -49,6 +51,11 @@
OpenMLTask,
)

if TYPE_CHECKING:
from .config import OpenMLConfigManager

config: OpenMLConfigManager = _config_module._config


def populate_cache(
task_ids: list[int] | None = None,
Expand Down
7 changes: 4 additions & 3 deletions openml/_api_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import xml
import zipfile
from pathlib import Path
from typing import Dict, Tuple, Union
from typing import Dict, Tuple, Union, cast

import minio
import requests
Expand Down 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 = cast(str, config.server)
if not url.endswith("/"):
url += "/"
url += endpoint
Expand Down Expand Up @@ -301,7 +301,8 @@ 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_server = cast(str, config.server)
openml_url = openml_server.split("/api/")
url = openml_url[0] + f"/data/download/{file_id!s}"
if filename is not None:
url += "/" + filename
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