Exemple #1
0
    def setUp(self):
        self.tmp_dir = tempfile.mkdtemp()
        self.definitions = self.CSV_SAMPLER.format(path=self.tmp_dir)
        self.csv_data = self.CSV1
        self.sampler_file = os.path.join(self.tmp_dir, "config.yaml")
        self.csv_file = os.path.join(self.tmp_dir, "test.csv")
        with open(self.sampler_file, 'w') as _file:
            _file.write(self.definitions)
        with open(self.csv_file, 'w') as _file:
            _file.write(self.csv_data)

        self.sample_data = read_yaml(self.sampler_file)

        self.sampler = new_sampler(self.sample_data['sampler'])
Exemple #2
0
def get_custom_generator(env, **kwargs):
    """
    Create a custom populated ParameterGenerator.
    This function supports several sampling methods.
    :params kwargs: A dictionary of keyword arguments this function uses.
    :returns: A ParameterGenerator populated with parameters.
    """

    try:
        SAMPLE_DICTIONARY = kwargs.get("sample_dictionary",
                                       env.find("SAMPLE_DICTIONARY").value)
    except ValueError:
        raise Exception("this pgen code requires SAMPLE_DICTIONARY " +
                        "to be defined in the yaml specification")

    return new_sampler(SAMPLE_DICTIONARY).maestro_pgen
Exemple #3
0
    def setUp(self):
        print("CUSTOM_FUNCTION:\n" + self.CUSTOM_FUNCTION)
        self.tmp_dir = tempfile.mkdtemp()
        self.definitions = self.CUSTOM_SAMPLER.format(path=self.tmp_dir)
        self.function_data = self.CUSTOM_FUNCTION
        self.sampler_file = os.path.join(self.tmp_dir, "config.yaml")
        self.function_file = os.path.join(self.tmp_dir,
                                          "codepy_sampler_test.py")
        with open(self.sampler_file, 'w') as _file:
            _file.write(self.definitions)
        with open(self.function_file, 'w') as _file:
            _file.write(self.function_data)

        self.sample_data = read_yaml(self.sampler_file)

        self.sampler = new_sampler(self.sample_data['sampler'])
Exemple #4
0
def new_sampler_from_yaml(yaml_text):
    """Returns sampler from yaml text"""
    return new_sampler(yaml.safe_load(yaml_text))