Ejemplo n.º 1
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!")
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
    def test_tc_no_inputs(self):
        file_name = "dev_example_tool_contract.json"
        path = get_tool_contract(file_name)
        tc = load_tool_contract_from(path)
        tc.task.input_file_types = []

        def _run():
            return tc.to_dict()

        self.assertRaises(MalformedToolContractError, _run)
    def test_tc_no_inputs(self):
        file_name = "dev_example_tool_contract.json"
        path = get_tool_contract(file_name)
        tc = load_tool_contract_from(path)
        tc.task.input_file_types = []

        def _run():
            return tc.to_dict()

        self.assertRaises(MalformedToolContractError, _run)
Ejemplo n.º 6
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))
Ejemplo n.º 7
0
 def test_01(self):
     name = "dev_example_dev_txt_app_tool_contract.json"
     p = get_tool_contract(name)
     tc = load_tool_contract_from(p)
     input_files = ["/tmp/file.txt"]
     root_output_dir = "/tmp"
     root_tmp_dir = root_output_dir
     tmp_file = tempfile.NamedTemporaryFile().name
     max_nproc = 2
     tool_options = {}
     rtc = resolve_tool_contract(tc, input_files, root_output_dir, root_tmp_dir, max_nproc, tool_options, False)
     log.info(pprint.pformat(rtc))
     self.assertIsNotNone(rtc)
     self.assertEqual(os.path.basename(rtc.task.output_files[0]),
         "output.txt")
     # Validate Resolved Resource Types
     log.debug("Resources {t}".format(t=rtc.task.resources))
     self.assertEqual(len(rtc.task.tmpdir_resources), 1)
     self.assertEqual(len(rtc.task.tmpfile_resources), 2)
Ejemplo n.º 8
0
 def test_01(self):
     file_name = "dev_example_tool_contract.json"
     path = get_tool_contract(file_name)
     tc = load_tool_contract_from(path)
     self.assertIsInstance(tc, ToolContract)
 def test_01(self):
     file_name = "dev_example_tool_contract.json"
     path = get_tool_contract(file_name)
     tc = load_tool_contract_from(path)
     self.assertIsInstance(tc, ToolContract)