-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathapi.py
More file actions
34 lines (28 loc) · 993 Bytes
/
api.py
File metadata and controls
34 lines (28 loc) · 993 Bytes
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
import pathlib
from lib import logging
from lib.config.formatter import ModelFormatter
from lib.config.io import load_raw_config
from lib.config.schema import BinarizerConfig, RootConfig
from preprocessing.binarizer_base import BaseBinarizer
__all__ = [
"load_config_for_binarization",
"binarize_datasets",
]
def load_config_for_binarization(
config_path: pathlib.Path,
scope: int = 0,
overrides: list[str] = None
) -> BinarizerConfig:
config = load_raw_config(config_path, inherit=True, overrides=overrides)
config = RootConfig.model_validate(config, scope=scope)
config.resolve(scope_mask=scope)
config.check(scope_mask=scope)
formatter = ModelFormatter()
print(formatter.format(config.binarizer))
return config.binarizer
def binarize_datasets(
binarizer: BaseBinarizer
):
logging.info(f"Starting binarizer: {binarizer.__class__.__name__}.")
binarizer.process()
logging.success("Binarization completed.")