-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.py
59 lines (45 loc) · 1.12 KB
/
config.py
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
"""
Schema definition and validation of the hierarchical config files.
"""
from typing import List
from hydra.core.config_store import ConfigStore
from omegaconf import MISSING
from pydantic import validator
# we use pydantic as a replacement of default dataclasses for more validation features
from pydantic.dataclasses import dataclass
@dataclass
class Experiment:
model: str
l2: float
n_steps: int
@dataclass
class DataBase:
driver: str
host: str
@validator("port")
def check_non_privileged_port(cls, port: int) -> int:
if port < 1024:
raise ValueError("Choose a non-privileged port!")
return port
port: int
username: str
password: str
@dataclass
class Neptune:
project: str
api_token: str
tags: List[str]
description: str
mode: str
@dataclass
class Main:
sleep: int
@dataclass
class Config:
main: Main
db: DataBase
neptune: Neptune
experiment: Experiment = MISSING
cs = ConfigStore.instance()
# name `base_config` is used for matching it with the main.yaml's default section
cs.store(name="base_config", node=Config)