Пример #1
0
    def set_up_forward_model(self, selected_jobs=None):
        if selected_jobs is None:
            selected_jobs = range(len(joblist))
        jobs = [self.generate_job_from_dict(job) for job in joblist]

        ext_joblist = ExtJoblist()
        for job in jobs:
            ext_joblist.add_job(job.name(), job)

        forward_model = ForwardModel(ext_joblist)
        for index in selected_jobs:
            forward_model.add_job(jobs[index].name())

        return forward_model
Пример #2
0
    def test_transfer_arg_types(self):
        with TestAreaContext(
                "python/job_queue/forward_model_transfer_arg_types"):
            with open("FWD_MODEL", "w") as f:
                f.write("EXECUTABLE ls\n")
                f.write("MIN_ARG 2\n")
                f.write("MAX_ARG 6\n")
                f.write("ARG_TYPE 0 INT\n")
                f.write("ARG_TYPE 1 FLOAT\n")
                f.write("ARG_TYPE 2 STRING\n")
                f.write("ARG_TYPE 3 BOOL\n")
                f.write("ARG_TYPE 4 RUNTIME_FILE\n")
                f.write("ARG_TYPE 5 RUNTIME_INT\n")

            job = ExtJob("FWD_MODEL", True)

            ext_joblist = ExtJoblist()
            ext_joblist.add_job(job.name(), job)
            forward_model = ForwardModel(ext_joblist)
            forward_model.add_job("FWD_MODEL")

            run_id = "test_no_jobs_id"
            umask = 4
            global_args = SubstitutionList()

            forward_model.formatted_fprintf(run_id, os.getcwd(), "data_root",
                                            global_args, umask,
                                            EnvironmentVarlist())
            config = load_configs(self.JOBS_JSON_FILE)
            printed_job = config["jobList"][0]
            self.assertEqual(printed_job["min_arg"], 2)
            self.assertEqual(printed_job["max_arg"], 6)
            self.assertEqual(printed_job["arg_types"], [
                "INT", "FLOAT", "STRING", "BOOL", "RUNTIME_FILE", "RUNTIME_INT"
            ])
Пример #3
0
    def from_legacy(
        run_context: ErtRunContext,
        forward_model: ForwardModel,
        queue_config: QueueConfig,
        analysis_config: AnalysisConfig,
        res_config: ResConfig,
    ) -> "_EnsembleBuilder":
        builder = _EnsembleBuilder().set_legacy_dependencies(
            queue_config,
            analysis_config,
        )

        num_cpu = res_config.queue_config.num_cpu
        if num_cpu == 0:
            num_cpu = res_config.ecl_config.num_cpu

        for iens, run_arg in enumerate(run_context):
            active = run_context.is_active(iens)
            real = _RealizationBuilder().set_iens(iens).active(active)
            step = _StepBuilder().set_id("0").set_dummy_io().set_name("legacy step")
            if active:
                real.active(True).add_step(step)
                for index in range(0, len(forward_model)):
                    ext_job = forward_model.iget_job(index)
                    step.add_job(
                        _LegacyJobBuilder()
                        .set_id(str(index))
                        .set_name(ext_job.name())
                        .set_ext_job(ext_job)
                    )
                step.set_max_runtime(
                    analysis_config.get_max_runtime()
                ).set_callback_arguments((run_arg, res_config)).set_done_callback(
                    EnKFState.forward_model_ok_callback
                ).set_exit_callback(
                    EnKFState.forward_model_exit_callback
                ).set_num_cpu(
                    num_cpu
                ).set_run_path(
                    run_arg.runpath
                ).set_job_script(
                    res_config.queue_config.job_script
                ).set_job_name(
                    run_arg.job_name
                ).set_run_arg(
                    run_arg
                )
            builder.add_realization(real)
        return builder