Beispiel #1
0
 def test_sanity(self):
     d = get_temp_dir("resolved-tool-contract")
     tc = load_tool_contract_from(get_data_file(self.FILE_NAME))
     rtc = resolve_gather_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, self.TOOL_OPTIONS, self.CHUNK_KEY)
     self.assertIsInstance(rtc, ResolvedToolContract)
     self.assertIsInstance(rtc.task, ResolvedGatherToolContractTask)
     self.assertEqual(rtc.task.chunk_key, self.CHUNK_KEY)
Beispiel #2
0
 def test_sanity(self):
     d = get_temp_dir("resolved-tool-contract")
     tc = load_tool_contract_from(get_tool_contract(self.FILE_NAME))
     tool_options = {}
     rtc = resolve_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, tool_options, False)
     self.assertIsInstance(rtc, ResolvedToolContract)
     self.assertIsInstance(rtc.task, ResolvedToolContractTask)
     self.assertEqual(rtc.task.is_distributed, False)
     self.assertEqual(rtc.task.options[self.ALPHA], 25)
     self.assertEqual(rtc.task.options[self.BETA], 1.234)
     self.assertEqual(rtc.task.options[self.GAMMA], True)
     self.assertEqual(rtc.task.options[self.PLOIDY], "haploid")
     self.assertEqual(rtc.task.options[self.DELTA], 1)
     self.assertEqual(rtc.task.options[self.EPS], 0.1)
     self.assertEqual(rtc.task.options[self.COMMENTS], "asdf")
     # non-defaults
     tool_options = {self.ALPHA: 15, self.BETA: 2.5, self.GAMMA: False, self.PLOIDY: "diploid", self.DELTA: 2, self.EPS: 1.0, self.COMMENTS: "Hello, world!"}
     rtc = resolve_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, tool_options, False)
     self.assertEqual(rtc.task.options[self.ALPHA], 15)
     self.assertEqual(rtc.task.options[self.BETA], 2.5)
     self.assertEqual(rtc.task.options[self.GAMMA], False)
     self.assertEqual(rtc.task.options[self.PLOIDY], "diploid")
     self.assertEqual(rtc.task.options[self.DELTA], 2)
     self.assertEqual(rtc.task.options[self.EPS], 1.0)
     self.assertEqual(rtc.task.options[self.COMMENTS], "Hello, world!")
 def test_sanity(self):
     d = get_temp_dir("resolved-tool-contract")
     tc = load_tool_contract_from(get_tool_contract(self.FILE_NAME))
     rtc = resolve_scatter_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, self.TOOL_OPTIONS, self.MAX_NCHUNKS, self.CHUNK_KEYS, False)
     self.assertIsInstance(rtc, ResolvedToolContract)
     self.assertIsInstance(rtc.task, ResolvedScatteredToolContractTask)
     self.assertEqual(rtc.task.max_nchunks, 7)
     self.assertEqual(rtc.task.is_distributed, False)
Beispiel #4
0
 def test_sanity(self):
     d = get_temp_dir("resolved-tool-contract")
     tc = load_tool_contract_from(get_tool_contract(self.FILE_NAME))
     rtc = resolve_gather_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, self.TOOL_OPTIONS, self.CHUNK_KEY, False)
     self.assertIsInstance(rtc, ResolvedToolContract)
     self.assertIsInstance(rtc.task, ResolvedGatherToolContractTask)
     self.assertEqual(rtc.task.chunk_key, self.CHUNK_KEY)
     self.assertEqual(rtc.task.is_distributed, False)
    def test_01(self):
        file_name = "resolved_tool_contract_dev_app.json"
        rtc = load_resolved_tool_contract_from(get_data_file(file_name))
        self.assertIsInstance(rtc, ResolvedToolContract)

        d = get_temp_dir("rtc-app")
        f = get_temp_file("-resolved-tool-contract.avro", d)
        write_resolved_tool_contract_avro(rtc, f)
Beispiel #6
0
    def test_01(self):
        file_name = "resolved_tool_contract_dev_app.json"
        rtc = load_resolved_tool_contract_from(get_resolved_tool_contract(file_name))
        self.assertIsInstance(rtc, ResolvedToolContract)

        d = get_temp_dir("rtc-app")
        f = get_temp_file("-resolved-tool-contract.avro", d)
        write_resolved_tool_contract_avro(rtc, f)
Beispiel #7
0
 def test_sanity(self):
     d = get_temp_dir("resolved-tool-contract")
     tc = load_tool_contract_from(get_data_file(self.FILE_NAME))
     rtc = resolve_scatter_tool_contract(tc, self.INPUT_FILES, d, d,
                                         self.MAX_NPROC, self.TOOL_OPTIONS,
                                         self.MAX_NCHUNKS, self.CHUNK_KEYS)
     self.assertIsInstance(rtc, ResolvedToolContract)
     self.assertIsInstance(rtc.task, ResolvedScatteredToolContractTask)
     self.assertEqual(rtc.task.max_nchunks, 7)
Beispiel #8
0
 def test_failure_modes(self):
     d = get_temp_dir("resolved-tool-contract")
     tc = load_tool_contract_from(get_tool_contract(self.FILE_NAME))
     tool_options = {self.PLOIDY: "other"}
     self.assertRaises(ToolContractError, lambda: resolve_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, tool_options, False))
     tool_options = {self.ALPHA:2.5}
     self.assertRaises(ToolContractError, lambda: resolve_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, tool_options, False))
     tool_options = {self.ALPHA:"abcdef"}
     self.assertRaises(ToolContractError, lambda: resolve_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, tool_options, False))
     tool_options = {self.BETA:"asdf"}
     self.assertRaises(ToolContractError, lambda: resolve_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, tool_options, False))
     tool_options = {self.GAMMA:1.0}
     self.assertRaises(ToolContractError, lambda: resolve_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, tool_options, False))
     tool_options = {self.GAMMA:""}
     self.assertRaises(ToolContractError, lambda: resolve_tool_contract(tc, self.INPUT_FILES, d, d, self.MAX_NPROC, tool_options, False))
Beispiel #9
0
    def test_simple_run_cmd(self):
        d = get_temp_dir("simple-cmd")
        txt_in = get_temp_file(".txt", d)
        txt_out = get_temp_file("*.txt", d)
        exe = "cat {i} > {o}".format(i=txt_in, o=txt_out)

        # this could all be bundled into a context manager
        # with RunCommand('/path/stdout', '/path/to/stderr') as r:
        #   r.exe("echo 'exe1')
        #   r.exe("echo 'exe2')
        #   result = r.get_result() # close the file handles
        stdout = get_temp_file("-stdout", d)
        stderr = get_temp_file("-stderr", d)
        with open(stdout, 'w') as fo:
            with open(stderr, 'w') as fe:
                result = run_cmd(exe, fo, fe)

        emgs = "Command {e} failed".format(e=exe)
        if result.exit_code != 0:
            print(emgs)
        assert result.exit_code == 0