def test_invalid_job( calc_key, app_key, obs_keys, obs_with_data, errors, alpha, ): user_config_dict = { "CALCULATE_KEYS": {"keys": [{"key": calc_key}], "std_cutoff": 0.001}, "UPDATE_KEYS": {"keys": [{"key": app_key}]}, } if alpha: user_config_dict["CALCULATE_KEYS"]["alpha"] = 3 else: errors.insert( 0, "MissingKeyError(msg=Missing key: alpha, " "key_path=('CALCULATE_KEYS',), layer=None)", ) reporter = FileReporter(os.path.realpath(os.getcwd())) with pytest.raises(ValidationError) as exc_info: ScalingJob(obs_keys, [], obs_with_data, user_config_dict, reporter) assert [str(elem) for elem in exc_info.value.errors] == errors
def test_invalid_job( calc_key, app_key, obs_keys, obs_with_data, errors, ): user_config_dict = { "CALCULATE_KEYS": { "keys": [{ "key": calc_key }] }, "UPDATE_KEYS": { "keys": [{ "key": app_key }] }, } reporter = FileReporter(os.path.realpath(os.getcwd())) with pytest.raises(ValidationError) as exc_info: ScalingJob(obs_keys, [], obs_with_data, user_config_dict, reporter) assert exc_info.value.errors == errors
def test_config_value_overwrites_default(input_key): user_config_dict = { "CALCULATE_KEYS": {"keys": [{"key": "a_key"}], "alpha": 2, "std_cutoff": 0.01}, } default_vals = { "CALCULATE_KEYS": {"std_cutoff": 1.0e-6, "alpha": 3}, "UPDATE_KEYS": {}, } reporter = FileReporter(os.path.realpath(os.getcwd())) job = ScalingJob(["a_key"], [], ["a_key"], user_config_dict, reporter, default_vals) # Check that the value equals the config value assert ( getattr(job._config.snapshot.CALCULATE_KEYS, input_key) == user_config_dict["CALCULATE_KEYS"][input_key] ) # Check that different from default value assert ( getattr(job._config.snapshot.CALCULATE_KEYS, input_key) != default_vals["CALCULATE_KEYS"][input_key] )
def test_valid_job( calc_key, app_key, obs_keys, obs_with_data, scaling_job_content, ): user_config_dict = { "CALCULATE_KEYS": {"keys": [{"key": calc_key}]}, "UPDATE_KEYS": {"keys": [{"key": app_key}]}, } default_vals = { "CALCULATE_KEYS": {"std_cutoff": 1.0e-6, "alpha": 3}, "UPDATE_KEYS": {}, } reporter = FileReporter(os.path.realpath(os.getcwd())) job = ScalingJob( obs_keys, [], obs_with_data, user_config_dict, reporter, default_vals ) assert job.get_index_lists() == scaling_job_content["get_index_lists"] assert job.get_calc_keys() == scaling_job_content["get_calc_keys"]
def __init__(self, ert): super().__init__(ert) self._output_dir = self._get_output_dir() self._reporter = FileReporter(self._output_dir) self._wrap_run()
def __init__(self, output_dir, thread_id): super().__init__(1) self._reporter = FileReporter(output_dir) self._namespace = SEMEIOSCRIPT_LOG_FILE self.addFilter(lambda rec: rec.thread == thread_id)
def __init__(self, output_dir): super(_ReportHandler, self).__init__(1) self._reporter = FileReporter(output_dir) self._namespace = SEMEIOSCRIPT_LOG_FILE
def __init__(self, output_dir): super(_ReportHandler, self).__init__(1) self._reporter = FileReporter(output_dir) self._namespace = "log.txt"