Beispiel #1
0
def read_configuration_file(filename):
    """
    Load a configuration file stored in YAML format into a dictionary
    :param filename: (str) Path to configuration file
    :return: (PKDict) Dictionary holding the configuration
    """
    return load_file(filename)
Beispiel #2
0
def test_load_file():
    """Test values are unicode"""
    from pykern import pkunit
    from pykern import pkyaml

    y = pkyaml.load_file(pkunit.data_dir().join('conf1.yml'))
    _assert_unicode(y)
Beispiel #3
0
def data_yaml(base_name):
    """Load base_name.yml from data_dir

    Args:
        base_name (str): name of YAML file with ``.yml`` extension

    Returns:
        object: YAML data structure, usually dict or array
    """
    return pkyaml.load_file(data_dir().join(base_name) + '.yml')
Beispiel #4
0
def data_yaml(base_name):
    """Load base_name.yml from data_dir

    Args:
        base_name (str): name of YAML file with ``.yml`` extension

    Returns:
        object: YAML data structure, usually dict or array
    """
    return pkyaml.load_file(data_dir().join(base_name) + '.yml')
Beispiel #5
0
def _get_example_file_list(example_name):
    registry = pkyaml.load_file(_EXAMPLE_REGISTRY)
    return registry['examples'][example_name]['files']
Beispiel #6
0
import unittest
import numpy as np
import os
from rsopt.pkcli.optimize import configuration
from rsopt.pkcli import cleanup
from rsopt.pkcli.quickstart import _EXAMPLE_SYMLINK, _EXAMPLE_REGISTRY
from pykern import pkyaml
import shutil
import glob

_EXAMPLES = pkyaml.load_file(_EXAMPLE_REGISTRY)['examples']


def copy_example_files(example):
    example_file_list = example['files']
    for filename in example_file_list:
        filepath = os.path.join(_EXAMPLE_SYMLINK, filename)
        shutil.copyfile(filepath, filename, follow_symlinks=True)

    return example_file_list


def run_test(config_filename):
    configuration(config_filename)


def run_cleanup(file_list):
    shutil.rmtree('ensemble', ignore_errors=True)
    cleanup.libensemble('.')
    if file_list:
        for file in file_list:
Beispiel #7
0
def test_load_file():
    """Test values are unicode"""
    y = pkyaml.load_file(pkunit.data_dir().join('conf1.yml'))
    _assert_unicode(y)
def ReadYaml(filename):
    d = pkunit.data_dir()
    y = pkyaml.load_file(d.join(filename))
    return y