Exemplo n.º 1
0
    def test_keywords_for_monitoring_simulation_runtime(self):
        with TestAreaContext("analysis_config_init_test") as work_area:
            work_area.copy_directory(self.case_directory)
            ac = AnalysisConfig(self.case_file)

            # Unless the MIN_REALIZATIONS is set in config, one is required to
            # have "all" realizations.
            self.assertFalse(ac.haveEnoughRealisations(5, 10))
            self.assertTrue(ac.haveEnoughRealisations(10, 10))

            ac.set_max_runtime(50)
            self.assertEqual(50, ac.get_max_runtime())

            ac.set_stop_long_running(True)
            self.assertTrue(ac.get_stop_long_running())
Exemplo n.º 2
0
    def _alloc_from_dict(self, config_dict, throw_on_error=True):
        # treat the default config dir
        config_dir = os.getcwd()
        if ConfigKeys.CONFIG_DIRECTORY in config_dict:
            config_dir = config_dict[ConfigKeys.CONFIG_DIRECTORY]
        config_dict[ConfigKeys.CONFIG_DIRECTORY] = config_dir

        subst_config = SubstConfig(config_dict=config_dict)
        site_config = SiteConfig(config_dict=config_dict)
        rng_config = RNGConfig(config_dict=config_dict)
        analysis_config = AnalysisConfig(config_dict=config_dict)
        ecl_config = EclConfig(config_dict=config_dict)
        log_config = LogConfig(config_dict=config_dict)
        queue_config = QueueConfig(config_dict=config_dict)

        ert_workflow_list = ErtWorkflowList(
            subst_list=subst_config.subst_list, config_dict=config_dict
        )

        hook_manager = HookManager(
            workflow_list=ert_workflow_list, config_dict=config_dict
        )

        ert_templates = ErtTemplates(
            parent_subst=subst_config.subst_list, config_dict=config_dict
        )

        ensemble_config = EnsembleConfig(
            grid=ecl_config.getGrid(),
            refcase=ecl_config.getRefcase(),
            config_dict=config_dict,
        )

        model_config = ModelConfig(
            data_root=config_dir,
            joblist=site_config.get_installed_jobs(),
            last_history_restart=ecl_config.getLastHistoryRestart(),
            refcase=ecl_config.getRefcase(),
            config_dict=config_dict,
        )

        return [
            subst_config,
            site_config,
            rng_config,
            analysis_config,
            ert_workflow_list,
            hook_manager,
            ert_templates,
            ecl_config,
            ensemble_config,
            model_config,
            log_config,
            queue_config,
        ], config_dir
Exemplo n.º 3
0
 def test_analysis_config_global_std_scaling(self):
     with TestAreaContext("analysis_config_init_test") as work_area:
         work_area.copy_directory(self.case_directory)
         ac = AnalysisConfig(self.case_file)
         self.assertFloatEqual(ac.getGlobalStdScaling(), 1.0)
         ac.setGlobalStdScaling(0.77)
         self.assertFloatEqual(ac.getGlobalStdScaling(), 0.77)
Exemplo n.º 4
0
    def _alloc_from_content(self,
                            user_config_file=None,
                            config=None,
                            throw_on_error=True):
        if user_config_file is not None:
            # initialize configcontent if user_file provided
            parser = ConfigParser()
            config_content = self._alloc_config_content(
                user_config_file, parser)
            config_dir = config_content.getValue(ConfigKeys.CONFIG_DIRECTORY)
        else:
            config_dir = os.getcwd()
            config_content = self._build_config_content(config)

        if self.errors and throw_on_error:
            raise ValueError("Error loading configuration: " +
                             str(self._errors))

        subst_config = SubstConfig(config_content=config_content)
        site_config = SiteConfig(config_content=config_content)
        rng_config = RNGConfig(config_content=config_content)
        analysis_config = AnalysisConfig(config_content=config_content)
        ecl_config = EclConfig(config_content=config_content)
        log_config = LogConfig(config_content=config_content)
        queue_config = QueueConfig(config_content=config_content)

        ert_workflow_list = ErtWorkflowList(subst_list=subst_config.subst_list,
                                            config_content=config_content)

        hook_manager = HookManager(workflow_list=ert_workflow_list,
                                   config_content=config_content)

        ert_templates = ErtTemplates(parent_subst=subst_config.subst_list,
                                     config_content=config_content)

        ensemble_config = EnsembleConfig(config_content=config_content,
                                         grid=ecl_config.getGrid(),
                                         refcase=ecl_config.getRefcase())

        model_config = ModelConfig(
            data_root=config_dir,
            joblist=site_config.get_installed_jobs(),
            last_history_restart=ecl_config.getLastHistoryRestart(),
            refcase=ecl_config.getRefcase(),
            config_content=config_content)

        return [
            subst_config, site_config, rng_config, analysis_config,
            ert_workflow_list, hook_manager, ert_templates, ecl_config,
            ensemble_config, model_config, log_config, queue_config
        ], config_dir
Exemplo n.º 5
0
 def test_analysis_config_global_std_scaling(self):
     ac = AnalysisConfig()
     self.assertFloatEqual(ac.getGlobalStdScaling(), 1.0)
     ac.setGlobalStdScaling(0.77)
     self.assertFloatEqual(ac.getGlobalStdScaling(), 0.77)
Exemplo n.º 6
0
 def test_analysis_modules(self):
     ac = AnalysisConfig()
     self.assertIsNone(ac.activeModuleName())
     self.assertIsNotNone(ac.getModuleList())
Exemplo n.º 7
0
 def test_init(self):
     with TestAreaContext("analysis_config_init_test") as work_area:
         work_area.copy_directory(self.case_directory)
         analysis_config = AnalysisConfig(self.case_file)
         self.assertIsNotNone(analysis_config)
Exemplo n.º 8
0
 def test_analysis_modules(self):
     with TestAreaContext("analysis_config_init_test") as work_area:
         work_area.copy_directory(self.case_directory)
         ac = AnalysisConfig(self.case_file)
         self.assertIsNotNone(ac.activeModuleName())
         self.assertIsNotNone(ac.getModuleList())
Exemplo n.º 9
0
 def test_invalid_user_config(self):
     with TestAreaContext("void land"):
         with self.assertRaises(IOError):
             AnalysisConfig("this/is/not/a/file")
Exemplo n.º 10
0
    def __init__(self,
                 user_config_file=None,
                 config=None,
                 throw_on_error=True):

        self._errors, self._failed_keys = None, None
        self._assert_input(user_config_file, config, throw_on_error)

        if config is not None:
            config_content = self._build_config_content(config)
        elif user_config_file is not None:

            parser = ConfigParser()

            config_content = self._alloc_config_content(
                user_config_file, parser)
        else:
            raise ValueError("No config provided")

        if self.errors and throw_on_error:
            raise ValueError("Error loading configuration: " +
                             str(self._errors))

        config_dir = config_content.getValue(ConfigKeys.CONFIG_DIRECTORY)

        subst_config = SubstConfig(config_content=config_content)
        site_config = SiteConfig(config_content=config_content)
        rng_config = RNGConfig(config_content=config_content)
        analysis_config = AnalysisConfig(config_content=config_content)
        ecl_config = EclConfig(config_content=config_content)
        log_config = LogConfig(config_content=config_content)
        queue_config = QueueConfig(config_content=config_content)

        ert_workflow_list = ErtWorkflowList(
            ert_workflow_list=subst_config.subst_list,
            config_content=config_content)

        hook_manager = HookManager(workflow_list=ert_workflow_list,
                                   config_content=config_content)

        ert_templates = ErtTemplates(parent_subst=subst_config.subst_list,
                                     config_content=config_content)

        ensemble_config = EnsembleConfig(config_content=config_content,
                                         grid=ecl_config.getGrid(),
                                         refcase=ecl_config.getRefcase())

        model_config = ModelConfig(
            config_content=config_content,
            data_root=config_dir,
            joblist=site_config.get_installed_jobs(),
            last_history_restart=ecl_config.getLastHistoryRestart(),
            sched_file=ecl_config._get_sched_file(),
            refcase=ecl_config.getRefcase())

        configs = [
            subst_config, site_config, rng_config, analysis_config,
            ert_workflow_list, hook_manager, ert_templates, ecl_config,
            ensemble_config, model_config, log_config, queue_config
        ]

        c_ptr = None

        for conf in configs:
            conf.convertToCReference(None)
        c_ptr = self._alloc_full(config_dir, user_config_file, *configs)

        if c_ptr:
            super(ResConfig, self).__init__(c_ptr)
        else:
            raise ValueError(
                'Failed to construct ResConfig instance from %r.' %
                (user_config_file if user_config_file else config))
Exemplo n.º 11
0
 def test_analysis_config_constructor(self):
     with TestAreaContext("analysis_config_constructor_test") as work_area:
         work_area.copy_directory(self.case_directory)
         config_dict = {
             ConfigKeys.ALPHA_KEY:
             3,
             ConfigKeys.RERUN_KEY:
             False,
             ConfigKeys.RERUN_START_KEY:
             0,
             ConfigKeys.MERGE_OBSERVATIONS:
             False,
             ConfigKeys.UPDATE_LOG_PATH:
             "update_log",
             ConfigKeys.STD_CUTOFF_KEY:
             1e-6,
             ConfigKeys.STOP_LONG_RUNNING:
             False,
             ConfigKeys.SINGLE_NODE_UPDATE:
             False,
             ConfigKeys.STD_CORRELATED_OBS:
             False,
             ConfigKeys.GLOBAL_STD_SCALING:
             1,
             ConfigKeys.MAX_RUNTIME:
             0,
             ConfigKeys.MIN_REALIZATIONS:
             0,
             ConfigKeys.ANALYSIS_LOAD: [
                 {
                     ConfigKeys.USER_NAME: "RML_ENKF",
                     ConfigKeys.LIB_NAME: "rml_enkf.so",
                 },
                 {
                     ConfigKeys.USER_NAME: "MODULE_ENKF",
                     ConfigKeys.LIB_NAME: "rml_enkf.so",
                 },
             ],
             ConfigKeys.ANALYSIS_COPY: [{
                 ConfigKeys.SRC_NAME:
                 "STD_ENKF",
                 ConfigKeys.DST_NAME:
                 "ENKF_HIGH_TRUNCATION",
             }],
             ConfigKeys.ANALYSIS_SET_VAR: [
                 {
                     ConfigKeys.MODULE_NAME: "STD_ENKF",
                     ConfigKeys.VAR_NAME: "ENKF_NCOMP",
                     ConfigKeys.VALUE: 2,
                 },
                 {
                     ConfigKeys.MODULE_NAME: "ENKF_HIGH_TRUNCATION",
                     ConfigKeys.VAR_NAME: "ENKF_TRUNCATION",
                     ConfigKeys.VALUE: 0.99,
                 },
             ],
             ConfigKeys.ANALYSIS_SELECT:
             "ENKF_HIGH_TRUNCATION",
         }
         _config_file = "simple_config/analysis_config"
         analysis_config_file = AnalysisConfig(
             user_config_file=_config_file)
         analysis_config_dict = AnalysisConfig(config_dict=config_dict)
         self.assertEqual(analysis_config_dict, analysis_config_file)