示例#1
0
    def test_create(self):
        with TestAreaContext("run_context"):
            arg = None
            sim_fs = EnkfFs.createFileSystem("sim_fs",
                                             EnKFFSType.BLOCK_FS_DRIVER_ID,
                                             arg)
            target_fs = None

            mask = BoolVector(initial_size=100, default_value=True)
            mask[50] = False
            runpath_fmt = PathFormat("path/to/sim%d")
            subst_list = SubstitutionList()
            itr = 0
            jobname_fmt = "job%d"
            run_context1 = ErtRunContext(EnkfRunType.ENSEMBLE_EXPERIMENT,
                                         sim_fs, target_fs, mask, runpath_fmt,
                                         jobname_fmt, subst_list, itr)
            run_id1 = run_context1.get_id()

            run_arg0 = run_context1[0]
            with self.assertRaises(ValueError):
                run_arg0.getQueueIndex()

            self.assertEqual(run_arg0.iter_id, itr)
            self.assertEqual(run_id1, run_arg0.get_run_id())

            run_context2 = ErtRunContext(EnkfRunType.ENSEMBLE_EXPERIMENT,
                                         sim_fs, target_fs, mask, runpath_fmt,
                                         jobname_fmt, subst_list, itr)
            run_id2 = run_context2.get_id()

            self.assertFalse(run_id1 == run_id2)

            self.assertTrue(run_context1.is_active(49))
            self.assertFalse(run_context1.is_active(50))
示例#2
0
    def _verify_runpath_rendering(self, itr):
        with ErtTestContext(
            "add_all_runpath_dump", model_config=self.config_path
        ) as ctx:
            res = ctx.getErt()
            fs_manager = res.getEnkfFsManager()
            sim_fs = fs_manager.getFileSystem("sim_fs")

            num_realizations = 25
            mask = BoolVector(initial_size=num_realizations, default_value=True)
            mask[13] = False

            runpath_fmt = "simulations/<GEO_ID>/realisation-%d/iter-%d/magic-real-<IENS>/magic-iter-<ITER>"
            jobname_fmt = "SNAKE_OIL_%d"

            subst_list = res.resConfig().subst_config.subst_list
            run_context = ErtRunContext.ensemble_experiment(
                sim_fs, mask, PathFormat(runpath_fmt), jobname_fmt, subst_list, itr
            )

            res.initRun(run_context)

            for i, run_arg in enumerate(run_context):
                if mask[i]:
                    run_arg.geo_id = 10 * i

            res.createRunpath(run_context)

            for i, run_arg in enumerate(run_context):
                if not mask[i]:
                    continue

                self.assertTrue(os.path.isdir("simulations/%d" % run_arg.geo_id))

            runpath_list_path = ".ert_runpath_list"
            self.assertTrue(os.path.isfile(runpath_list_path))

            exp_runpaths = [
                render_dynamic_values(runpath_fmt, itr, iens, run_arg.geo_id)
                % (iens, itr)
                for iens, run_arg in enumerate(run_context)
                if mask[iens]
            ]
            exp_runpaths = map(os.path.realpath, exp_runpaths)

            with open(runpath_list_path, "r") as f:
                dumped_runpaths = list(zip(*[line.split() for line in f.readlines()]))[
                    1
                ]

            self.assertEqual(list(exp_runpaths), list(dumped_runpaths))
示例#3
0
 def test_create(self):
     path_fmt = PathFormat("random/path/%d-%d")
     self.assertIn('random/path', repr(path_fmt))
     self.assertTrue(str(path_fmt).startswith('PathFormat('))