Exemple #1
0
    def _update_params_def_target_config(self, param_def):
        """
        calculates parameter.target_config based on extra config
        at `parameter_name__target value
        user might want to change the target_config for specific param using configuration/cli
        """

        # used for target_format update
        # change param_def definition based on config state
        target_def_key = "%s__target" % param_def.name
        target_config = self.config.get_multisection_config_value(
            self.config_sections, key=target_def_key)
        if not target_config:
            return param_def

        # the last is from a higher level
        target_config = last(target_config)
        try:
            target_config = parse_target_config(target_config.value)
        except Exception as ex:
            raise param_def.parameter_exception(
                "Calculate target config for %s : target_config='%s'" %
                (target_def_key, target_config.value),
                ex,
            )

        param_def = param_def.modify(target_config=target_config)
        return param_def
Exemple #2
0
    def get_value_target_config(self, value_type):
        # type: (Type) -> TargetConfig

        type_handler = get_value_type_of_type(value_type)
        for possible_option in [str(type_handler), type_handler.config_name]:
            config_value = config.get_config_value(
                section=self._conf__task_family, key=possible_option)
            if config_value:
                return parse_target_config(config_value.value)
        return file.pickle
Exemple #3
0
    def _update_param_def_target_config(self, param_def):
        """calculates parameter.target_config based on extra config at parameter__target value"""
        target_option = "%s__target" % param_def.name
        target_config = self._get_task_config_value(key=target_option)
        if not target_config:
            return param_def

        try:
            target_config = parse_target_config(target_config.value)
        except Exception as ex:
            raise param_def.parameter_exception(
                "Calculate target config for %s : target_config='%s'" %
                (target_option, target_config.value),
                ex,
            )

        param_def = param_def.modify(target_config=target_config)
        return param_def
Exemple #4
0
 def parse_from_str(self, x):
     return parse_target_config(x)