Example #1
0
    def test_load_single_job_group_cascading_tool(self):
        text = """
        job-group:
          name: abc
          tool: tool1
          labels: 
            - def
            - def
          jobs:
            - name: abc
            
            - name: def
              tool: tool2
        """
        
        sp = StreamProviderTesting({
            "job.yaml" : text
        })

        loader = JobspecLoader(sp)
        loader.tool_s.append("default")
        specs : JobSpecSet = loader.load("job.yaml")
        self.assertEqual(len(specs.jobspecs), 2)
        self.assertEqual(specs.jobspecs[0].name, "abc")
        self.assertEqual(specs.jobspecs[0].fullname, "abc.abc")
        self.assertEqual(specs.jobspecs[0].tool, "tool1")
        self.assertEqual(specs.jobspecs[1].name, "def")
        self.assertEqual(specs.jobspecs[1].fullname, "abc.def")
        self.assertEqual(specs.jobspecs[1].tool, "tool2")
Example #2
0
    def runLoadJobSpec(self, 
                       file_m : Dict[str,str], 
                       exp_s : set(),
                       specfile=None):
        
        for f in file_m.keys():
            f_dir = os.path.dirname(f)
            if f_dir != "" and not os.path.isdir(f_dir):
                os.makedirs(f_dir)
            with open(f, "w") as fp:
                fp.write(file_m[f])

        loader = JobspecLoader()
        jobspec_s = loader.load(
            os.getcwd(), 
            specfile,
            prefix="test")

        for i,gen in enumerate(jobspec_s.jobspec_gen):
            dir = "gen_%d" % i
            
            os.makedirs(dir)
            
            jobset_sg = JobSpecGenLoader(dir).load(gen)
            
            jobspec_s.jobspecs.extend(jobset_sg.jobspecs)

        for j in jobspec_s.jobspecs:
            self.assertIn(j.fullname, exp_s)
            exp_s.remove(j.fullname)

        self.assertEqual(0, len(exp_s))
Example #3
0
    def test_dflt_var_complex(self):
        file1 = """
        job-group:
            setup-vars:
              - var: var1
                val: val1
              
            jobs:
              - name: j1
              - name: j2
                setup-vars:
                  - var: var1
                    val: val2
        """
        
        sp = StreamProviderTesting({
            "job.yaml" : file1
        })

        loader = JobspecLoader(sp)
        loader.tool_s.append("default")
        specs : JobSpecSet = loader.load("job.yaml")
        self.assertEqual(len(specs.jobspecs), 2)
        self.assertEqual(specs.jobspecs[0].name, "j1")
        self.assertEqual(specs.jobspecs[0].fullname, "j1")
        self.assertEqual(specs.jobspecs[1].name, "j2")
        self.assertEqual(specs.jobspecs[1].fullname, "j2")
        self.assertEqual(specs.jobspecs[0].setupvars["var1"], "val1")
        self.assertEqual(specs.jobspecs[1].setupvars["var1"], "val2")
Example #4
0
    def test_load_single_job_group_two_files(self):
        file1 = """
        job-group:
          name: abc
          labels: 
            - def
            - def
          jobs:
            - path: file2.yaml
        """
        
        file2 = """
        job-group:
            jobs:
              - name: abc
              - name: def
        """
        
        sp = StreamProviderTesting({
            "job.yaml" : file1,
            "file2.yaml" : file2
        })

        loader = JobspecLoader(sp)
        loader.tool_s.append("default")
        specs : JobSpecSet = loader.load("job.yaml")
        self.assertEqual(len(specs.jobspecs), 2)
        self.assertEqual(specs.jobspecs[0].name, "abc")
        self.assertEqual(specs.jobspecs[1].name, "def")
        self.assertEqual(specs.jobspecs[0].fullname, "abc.abc")
        self.assertEqual(specs.jobspecs[1].fullname, "abc.def")
Example #5
0
    def test_same_runner_two_diff_settings(self):
        text = """
        job-group:
            name: top
            jobs:
                - name: j1
                  setup-vars:
                    - var1: val1
                - name: j2
                  setup-vars:
                    - var1: val2
                - name: j3
                  setup-vars:
                    - var1: val2
        """

        sp = StreamProviderTesting({"job.yaml": text})

        loader = JobspecLoader(sp)
        loader.tool_s.append("default")
        specs: JobSpecSet = loader.load("job.yaml")

        self.assertEqual(len(specs.jobspecs), 3)
        queue_s = JobQueueBuilder().build(specs.jobspecs)
        self.assertEqual(len(queue_s.queues), 2)
        self.assertEqual(len(queue_s.queues[0].jobs), 2)
        self.assertEqual(len(queue_s.queues[1].jobs), 3)
Example #6
0
    def test_load_single_job(self):
        text = """
        job:
          name: abc
        """
        
        sp = StreamProviderTesting({
            "job.yaml" : text
        })

        loader = JobspecLoader(sp)
        loader.tool_s.append("default")
        specs : JobSpecSet = loader.load("job.yaml")
        self.assertEqual(len(specs.jobspecs), 1)
        self.assertEqual(specs.jobspecs[0].name, "abc")
        self.assertEqual(specs.jobspecs[0].fullname, "abc")
Example #7
0
    def test_load_single_job_setup_generator(self):
        file1 = """
        job:
          name: abc
          setup-generators:
            - id: abc
              config:
                a: b
                c: d
          runner:
            id: makefile
            config:
              path: ${basedir}/Makefile
              properties:
                - a
                - b
              
        """
        
        file2 = """
        job-group:
            jobs:
              - job:
                  name: abc
              - job:
                  name: def
        """
        
        sp = StreamProviderTesting({
            "job.yaml" : file1,
            "file2.yaml" : file2
        })

        loader = JobspecLoader(sp)
        loader.tool_s.append("default")
        specs : JobSpecSet = loader.load("job.yaml")
        self.assertEqual(len(specs.jobspecs), 1)
        self.assertEqual(specs.jobspecs[0].name, "abc")
        self.assertEqual(specs.jobspecs[0].fullname, "abc")
Example #8
0
def run(args):
    loader = JobspecLoader()
    specs = loader.load(os.getcwd())
   
    pass
Example #9
0
def list_tests(args):
    loader = JobspecLoader()
    specs = loader.load(os.getcwd())