Пример #1
0
 def dfs_check_child(cfg: Cfg2Tune):
     for v in cfg.values():
         if isinstance(v, Cfg2Tune):
             assert len(object.__getattribute__(v, "_params2tune")) == 0
             dfs_check_child(v)
Пример #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Author  : Xiaobo Yang
@Contact : [email protected]
@Time    : 2021/5/6 22:09
@File    : cfg.py.py
@Software: PyCharm
@Desc    : 
"""
from alchemy_cat.py_tools import Cfg2Tune, Param2Tune

cfg = config = Cfg2Tune()

cfg.rslt_dir = 'run_time_mutual_depend_config'

# * Param on same Cfg2Tune
cfg.foo0.foo1.a = Param2Tune([0, 1, 2])


def b_subject_to(_):
    if cfg.foo0.foo1.a.cur_val == 0:
        return True

    return cfg.c.cur_val


cfg.foo0.foo1.b = Param2Tune([.1, .2], b_subject_to)
# * Param on root Cfg2Tune
cfg.c = Param2Tune([False, True],
                   subject_to=lambda x: x ==
Пример #3
0
def subject_to_static_config():
    return Cfg2Tune.load_cfg2tune(
        osp.join('configs', 'subject_to_static_config', 'cfg.py'))
Пример #4
0
def wrong_sequence_config():
    return Cfg2Tune.load_cfg2tune(
        osp.join('configs', 'wrong_sequence_config', 'cfg.py'))
Пример #5
0
def run_time_mutual_depend_config():
    return Cfg2Tune.load_cfg2tune(
        osp.join('configs', 'run_time_mutual_depend_config', 'cfg.py'))
Пример #6
0
def no_param_config():
    return Cfg2Tune.load_cfg2tune(
        osp.join('configs', 'no_param_config', 'cfg.py'))
Пример #7
0
def no_legal_val_config():
    return Cfg2Tune.load_cfg2tune(
        osp.join('configs', 'no_legal_val_config', 'cfg.py'))
Пример #8
0
def easy_config():
    return Cfg2Tune.load_cfg2tune(osp.join('configs', 'easy_config', 'cfg.py'))
Пример #9
0
def test_same_name_config():
    with pytest.raises(RuntimeError, match="for param2tune repeated."):
        Cfg2Tune.load_cfg2tune(
            osp.join('configs', 'same_name_config', 'cfg.py'))