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


Python yaml.FullLoader方法代码示例

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


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

示例1: import_files

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def import_files(self):
        print("self.manifest_path", self.manifest_path)
        self.manifest = yaml.load(open("{}/manifest.yml".format(self.manifest_path)), Loader=yaml.FullLoader)
        sys.path.append(self.manifest_path)
        """
        don't remove the import below, this will be the cti_transformations.py,
        which is one of the required file to run the job. This file will be provided by the 
        user during the run.
        """
        try:
            import ib_functions
        except Exception as e:
            ib_functions = None
        self.ib_functions = ib_functions
        print ("self.ib_functions is {}".format(ib_functions))
        # print("manifest is {}".format(self.manifest))
        # print("ib_functions is {}".format(self.ib_functions)) 
开发者ID:invanalabs,项目名称:invana-bot,代码行数:19,代码来源:cti.py

示例2: readYaml

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def readYaml(env=None):
    """Load the skelebot.yaml, with environment overrride if present, into the Config object"""

    yamlData = None
    cwd = os.getcwd()
    cfgFile = FILE_PATH.format(path=cwd)
    if os.path.isfile(cfgFile):
        with open(cfgFile, 'r') as stream:
            yamlData = yaml.load(stream, Loader=yaml.FullLoader)
            if (env is not None):
                envFile = ENV_FILE_PATH.format(path=cwd, env=env)
                if os.path.isfile(envFile):
                    with open(envFile, 'r') as stream:
                        overrideYaml = yaml.load(stream, Loader=yaml.FullLoader)
                        yamlData = override(yamlData, overrideYaml)
                else:
                    raise RuntimeError("Environment Not Found")

    return yamlData 
开发者ID:carsdotcom,项目名称:skelebot,代码行数:21,代码来源:yaml.py

示例3: load_config

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def load_config(config_path):
    """ Load a configuration file, also reading any component configs """
    with open(str(config_path)) as config_fd:
        config = yaml.load(config_fd, Loader=yaml.FullLoader)
    for component in config:
        if isinstance(config[component], dict) and "path" in config[component]:
            component_path = CONFIG_ROOT / config[component]["path"]
            with open(str(component_path)) as component_fd:
                component_config = yaml.load(component_fd, Loader=yaml.FullLoader)
            component_config.update(config[component])
            config[component] = component_config
            if "name" not in config[component]:
                config[component]["name"] = component_path.stem
    if "name" not in config:
        config["name"] = config_path.stem
    return config 
开发者ID:notkarol,项目名称:derplearning,代码行数:18,代码来源:util.py

示例4: generatetempyaml_multi

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def generatetempyaml_multi(yamlfile,videolist):

    #copy yaml and rename
    tempyaml = os.path.dirname(yamlfile) +'\\temp.yaml'
    shutil.copy(yamlfile,tempyaml)


    deeplabcut.add_new_videos(tempyaml,videolist,copy_videos=True)

    with open(tempyaml) as f:
        read_yaml = yaml.load(f, Loader=yaml.FullLoader)

    original_videosets = read_yaml['video_sets'].keys()

    keys=[]
    for i in original_videosets:
        keys.append(i)


    read_yaml['video_sets'].pop(keys[0],None)

    with open(tempyaml, 'w') as outfile:
        yaml.dump(read_yaml, outfile, default_flow_style=False) 
开发者ID:sgoldenlab,项目名称:simba,代码行数:25,代码来源:dlc_change_yamlfile.py

示例5: update_init_weight

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def update_init_weight(yamlfile,initweights):
    yamlPath=yamlfile
    initweights,initw_filetype = os.path.splitext(initweights)

    with open(yamlPath) as f:
        read_yaml = yaml.load(f, Loader=yaml.FullLoader)

    iteration = read_yaml['iteration']

    yamlfiledirectory = os.path.dirname(yamlfile)
    iterationfolder = yamlfiledirectory +'\\dlc-models\\iteration-' +str(iteration)
    projectfolder = os.listdir(iterationfolder)
    projectfolder = projectfolder[0]


    posecfg = iterationfolder + '\\' + projectfolder +'\\train\\' + 'pose_cfg.yaml'

    with open(posecfg) as g:
        read_cfg = yaml.load(g, Loader=yaml.FullLoader)

    read_cfg['init_weights'] = str(initweights)

    with open(posecfg, 'w') as outfile:
        yaml.dump(read_cfg, outfile, default_flow_style=False)
    print(os.path.basename(initweights),'selected') 
开发者ID:sgoldenlab,项目名称:simba,代码行数:27,代码来源:dlc_change_yamlfile.py

示例6: add_single_video_yaml

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def add_single_video_yaml(yamlfile,videofile):
    yamlPath = yamlfile
    cap = cv2.VideoCapture(videofile)
    width = int(cap.get(3))  # float
    height = int(cap.get(4))  # float
    cropLine = [0, width, 0, height]
    cropLine = str(cropLine)
    currCropLinePath = cropLine.strip("[]")
    currCropLinePath = currCropLinePath.replace("'", "")
    with open(yamlPath) as f:
        read_yaml = yaml.load(f, Loader=yaml.FullLoader)

    read_yaml["video_sets"].update({videofile: {'crop': currCropLinePath}})

    with open(yamlPath, 'w') as outfile:
        yaml.dump(read_yaml, outfile, default_flow_style=False) 
开发者ID:sgoldenlab,项目名称:simba,代码行数:18,代码来源:dlc_change_yamlfile.py

示例7: load_configs_from_yaml

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def load_configs_from_yaml(yaml_file: str) -> Dict:
    """
    从yaml配置文件中加载参数,这里会将嵌套的二级映射调整为一级映射

    Args:
        yaml_file: yaml】文件路径

    Returns:
        yaml文件中的配置字典
    """
    yaml_config = yaml.load(open(yaml_file, encoding='utf-8'), Loader=yaml.FullLoader)
    configs_dict = {}
    for sub_k, sub_v in yaml_config.items():
        # 读取嵌套的参数
        if isinstance(sub_v, dict):
            for k, v in sub_v.items():
                if k in configs_dict.keys():
                    raise ValueError(f'Duplicate parameter : {k}')
                configs_dict[k] = v
        else:
            configs_dict[sub_k] = sub_v
    return configs_dict 
开发者ID:NLPInBLCU,项目名称:BiaffineDependencyParsing,代码行数:24,代码来源:arguments.py

示例8: find_descriptor_schemas

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def find_descriptor_schemas(self, schema_file):
        """Find descriptor schemas in given path."""
        if not schema_file.lower().endswith((".yml", ".yaml")):
            return []

        with open(schema_file) as fn:
            schemas = yaml.load(fn, Loader=yaml.FullLoader)
        if not schemas:
            self.stderr.write("Could not read YAML file {}".format(schema_file))
            return []

        descriptor_schemas = []
        for schema in schemas:
            if "schema" not in schema:
                continue

            descriptor_schemas.append(schema)

        return descriptor_schemas 
开发者ID:genialis,项目名称:resolwe,代码行数:21,代码来源:register.py

示例9: test_improper_metrics_repo

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def test_improper_metrics_repo(improper_metrics_repo):
    runner.main(cache_dir, out_dir, None, None, False, True, repositories_file,
                True, None, None, None, None, 'dev')

    path = os.path.join(out_dir, "glean", improper_repo_name, "metrics")
    with open(path, 'r') as data:
        metrics = json.load(data)

    # should be empty output, since it was an improper file
    assert not metrics

    with open(EMAIL_FILE, 'r') as email_file:
        emails = yaml.load(email_file, Loader=yaml.FullLoader)

    # should send 1 email
    assert len(emails) == 1 
开发者ID:mozilla,项目名称:probe-scraper,代码行数:18,代码来源:test_git_scraper.py

示例10: test_regularize_parameters

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def test_regularize_parameters():

    params_yaml = """
params:
  stop_cycle: 100
  variant: [A, B, C]
  probability: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
"""

    params = yaml.load(params_yaml, Loader=yaml.FullLoader)

    reg_params = regularize_parameters(params["params"])
    assert len(reg_params) == 3

    assert len(reg_params["stop_cycle"]) == 1
    for v in reg_params["stop_cycle"]:
        assert isinstance(v, str)

    assert len(reg_params["variant"]) == 3
    for v in reg_params["variant"]:
        assert isinstance(v, str)

    assert len(reg_params["probability"]) == 6
    for v in reg_params["probability"]:
        assert isinstance(v, str) 
开发者ID:Orange-OpenSource,项目名称:pyDcop,代码行数:27,代码来源:test_batch.py

示例11: test_run_batches_direct_and_iteration

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def test_run_batches_direct_and_iteration(mock_run_batch):
    with tempfile.TemporaryDirectory() as tmpdirname:

        definition = f"""
sets:
  set1:
     path: {tmpdirname}
     iterations: 3
batches:
  batch1:
    command: test
    """
        conf = yaml.load(definition, Loader=yaml.FullLoader)
        run_batches(conf, simulate=False)

        assert mock_run_batch.call_count == 3 
开发者ID:Orange-OpenSource,项目名称:pyDcop,代码行数:18,代码来源:test_batch.py

示例12: load_dcop

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def load_dcop(dcop_str: str, main_dir=None) -> DCOP:
    loaded = yaml.load(dcop_str, Loader=yaml.FullLoader)

    if "name" not in loaded:
        raise ValueError("Missing name in dcop string")
    if "objective" not in loaded or loaded["objective"] not in ["min", "max"]:
        raise ValueError("Objective is mandatory and must be min or max")

    dcop = DCOP(
        loaded["name"],
        loaded["objective"],
        loaded["description"] if "description" in loaded else "",
    )

    dcop.domains = _build_domains(loaded)
    dcop.variables = _build_variables(loaded, dcop)
    dcop.external_variables = _build_external_variables(loaded, dcop)
    dcop._constraints = _build_constraints(loaded, dcop, main_dir)
    dcop._agents_def = _build_agents(loaded)
    dcop.dist_hints = _build_dist_hints(loaded, dcop)
    return dcop 
开发者ID:Orange-OpenSource,项目名称:pyDcop,代码行数:23,代码来源:yamldcop.py

示例13: load_scenario

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def load_scenario(scenario_str) -> Scenario:
    """
    Load a scenario from a yaml string.
    :param scenario_str:
    :return:
    """
    loaded = yaml.load(scenario_str, Loader=yaml.FullLoader)
    evts = []
    for evt in loaded["events"]:
        id_evt = evt["id"]
        if "actions" in evt:
            actions = []
            for a in evt["actions"]:
                args = dict(a)
                args.pop("type")
                actions.append(EventAction(a["type"], **args))
            evts.append(DcopEvent(id_evt, actions=actions))
        elif "delay" in evt:
            evts.append(DcopEvent(id_evt, delay=evt["delay"]))

    return Scenario(evts) 
开发者ID:Orange-OpenSource,项目名称:pyDcop,代码行数:23,代码来源:yamldcop.py

示例14: load_config

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def load_config(yaml_file):
    logger.debug("Loading configuration from %s" % yaml_file)
    fd = None
    try:
        fd = open(yaml_file)
    except Exception as e:
        logger.error(
            "Error reading configuration file %s, ignoring..." % yaml_file
        )
        return

    try:
        return yaml.load(fd, Loader=yaml.FullLoader)
    except Exception as e:
        logger.error(
            "Error parsing configuration file %s: %s" % (yaml_file, e)
        )
        return 
开发者ID:mendix,项目名称:cf-mendix-buildpack,代码行数:20,代码来源:config.py

示例15: main

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import FullLoader [as 别名]
def main(args):
    with open(args.config) as f:
        if version.parse(yaml.version >= "5.1"):
            config = yaml.load(f, Loader=yaml.FullLoader)
        else:
            config = yaml.load(f)

    for k, v in config.items():
        setattr(args, k, v)

    # exp path
    if not hasattr(args, 'exp_path'):
        args.exp_path = os.path.dirname(args.config)

    # dist init
    if mp.get_start_method(allow_none=True) != 'spawn':
        mp.set_start_method('spawn', force=True)
    dist_init(args.launcher, backend='nccl')

    # train
    trainer = Trainer(args)
    trainer.run() 
开发者ID:XiaohangZhan,项目名称:conditional-motion-propagation,代码行数:24,代码来源:main.py


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