当前位置: 首页>>代码示例>>Python>>正文


Python Configuration.iterations方法代码示例

本文整理汇总了Python中config.Configuration.iterations方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.iterations方法的具体用法?Python Configuration.iterations怎么用?Python Configuration.iterations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在config.Configuration的用法示例。


在下文中一共展示了Configuration.iterations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import iterations [as 别名]
    def load(self):
        """
        Loads a config.json file and run a validation process.
        If the configurations seem valid, returns Configuration object.

        """
        util.set_working_directory()
        # paths relatively to this script's location
        schema_json = util.json_decode(self.schema_path)
        if schema_json is None:
            msg = "Problem has occurred during the decoding procedure" + \
                  " with the following file: " + self.schema_path + "."
            logging.error(msg)
            raise IOError(msg)
        tools_json = util.json_decode(self.tools_path)
        if tools_json is None:
            msg = "Problem has occurred during the decoding procedure" + \
                  " with the following file: " + self.tools_path + "."
            logging.error(msg)
            raise IOError(msg)

        try:
            with open(self.config_path, mode="r") as file:
                config_string = file.read()
            decoder = json.JSONDecoder(object_pairs_hook=checking_hook)
            config_json = decoder.decode(config_string)
        except IOError:
            msg = "The file does not exist or cannot be read:" + \
                  (os.path.split(self.config_path))[1]
            logging.error(msg)
            raise IOError(msg)
        except ValueError as value_error:
            msg = (os.path.split(self.config_path))[1] + " file is not valid"
            logging.error(msg)
            print(value_error)
            raise ValidationError(msg)
        except KeyError as k_error:
            msg = "Duplicate key specified."
            logging.error(msg)
            print(k_error)
            print("Modify: " + (os.path.split(self.config_path))[1])
            raise ValidationError(msg)

        valid = validation.is_valid_json(config_json, schema_json)
        if not valid:
            msg = "Validation failed for " + \
                  (os.path.split(self.config_path))[1] + "."
            logging.error(msg)
            raise ValidationError(msg)

        config = Configuration()
        config.iterations = config_json["IterationCount"]
        config.runs = config_json["Runs"]
        config.queries = config_json["Queries"]
        config.scenarios = config_json["Scenarios"]
        config.sizes = util.get_power_of_two(config_json["MinSize"], config_json["MaxSize"])
        config.tools = config_json["Tools"]
        config.optional_arguments = config_json["OptionalArguments"]

        return config
开发者ID:pappist,项目名称:trainbenchmark,代码行数:62,代码来源:loader.py


注:本文中的config.Configuration.iterations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。