Exemplo n.º 1
0
def _load_link_config(_cls, config):
    if not isinstance(config, dict) or "type" not in config:
        logger.error(
            "Failed to unserialize config, class={}, config={}".format(
                str(_cls()), str(config)))
        return None
    class_type = _cls._class_type
    class_name = config["type"]
    if not class_name:
        return None
    if "_class_data" in config:
        # restore config
        class_data = config["_class_data"]
    else:
        # first set config
        class_data = config
    config_cls = _get_specific_class_config(class_type, class_name)
    if config_cls:
        setattr(_cls, "type", class_name)
        if class_data:
            setattr(_cls, "_class_data", config_cls.from_json(class_data))
            valid_rule(_cls._class_data, config, _cls._class_data.rules())
            for key, sub in _cls._class_data.get_config().items():
                if key in config.keys():
                    valid_rule(sub, config[key], sub.rules())
        else:
            setattr(_cls, "_class_data", None)
    else:
        logger.error(
            "Failed to unserialize config, class={}, config={}".format(
                str(_cls()), str(config)))
Exemplo n.º 2
0
 def check_config(cls, config):
     """Check config."""
     check_rules_user = {
         "general": {
             "type": dict
         },
         "pipeline": {
             "required": True,
             "type": list
         }
     }
     valid_rule(cls, config, check_rules_user)
     for pipe_step in config["pipeline"]:
         if pipe_step not in config:
             raise Exception("{} is required in {}".format(
                 pipe_step, cls.__name__))
Exemplo n.º 3
0
Arquivo: conf.py Projeto: ylfzr/vega
    def check_config(cls, config):
        """Check config."""
        check_rules_nas = {"pipe_step": {"type": dict},
                           "dataset": {"type": dict},
                           "search_algorithm": {"type": dict},
                           "search_space": {"type": dict},
                           "trainer": {"type": dict},
                           "evaluator": {"type": dict},
                           "model": {"type": dict},
                           "evaluator_enable": {"type": bool},
                           "models_folder": {"type": str}
                           }

        if 'pipe_step' in config:
            if config["pipe_step"]['type'] == 'NasPipeStep':
                valid_rule(cls, config, check_rules_nas)
            elif config["pipe_step"]['type'] == 'FullyTrainPipeStep':
                pass
        else:
            raise Exception(
                "pipe_step attr is required in {}".format(cls.__name__))
Exemplo n.º 4
0
 def check_config(cls, config):
     """Check config."""
     valid_rule(cls, config, cls.rules())
Exemplo n.º 5
0
Arquivo: conf.py Projeto: ylfzr/vega
 def check_config(cls, config):
     """Check config."""
     check_rules_searchspace = {"type": {"type": str},
                                "modules": {"type": list}
                                }
     valid_rule(cls, config, check_rules_searchspace)