-
-
Notifications
You must be signed in to change notification settings - Fork 270
Expand file tree
/
Copy pathconfig.py
More file actions
62 lines (47 loc) · 1.2 KB
/
config.py
File metadata and controls
62 lines (47 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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(),
)