示例#1
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"
            ])
示例#2
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