Ejemplo n.º 1
0
    def test_tc_no_inputs(self):
        file_name = "dev_example_tool_contract.json"
        path = get_data_file(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_01(self):
     name = "dev_example_tool_contract.json"
     p = get_data_file(name)
     tc = load_tool_contract_from(p)
     input_files = ["/tmp/file.txt"]
     root_output_dir = "/tmp"
     root_tmp_dir = root_output_dir
     max_nproc = 2
     rtc = resolve_tool_contract(tc, input_files, root_output_dir, root_tmp_dir, max_nproc, {})
     log.info(pprint.pformat(rtc))
     self.assertIsNotNone(rtc)
     self.assertEqual(os.path.basename(rtc.task.output_files[0]),
         "output.txt")
 def test_01(self):
     name = "dev_example_dev_txt_app_tool_contract.json"
     p = get_data_file(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)
 def test_resolved_tool_contract_is_distributed(self):
     workflow_options_json = os.path.join(self.job_dir, "workflow",
         "options-workflow.json")
     workflow_options = json.load(open(workflow_options_json))
     distributed_mode = workflow_options["pbsmrtpipe.options.distributed_mode"]
     tasks_dir = os.path.join(self.job_dir, "tasks")
     for task_dir in os.listdir(tasks_dir):
         if task_dir.startswith("."):
             continue
         tc_file = os.path.join(tasks_dir, task_dir, "tool-contract.json")
         tc = load_tool_contract_from(tc_file)
         rtc_file = os.path.join(tasks_dir, task_dir,
             "resolved-tool-contract.json")
         rtc = load_resolved_tool_contract_from(rtc_file)
         if distributed_mode and tc.task.is_distributed:
             self.assertTrue(rtc.task.is_distributed,
                 "Resolved tool contract {f} has unexpected is_distributed=False".format(f=rtc_file))
         else:
             self.assertFalse(rtc.task.is_distributed,
                 "Resolved tool contract {f} has unexpected is_distributed=True".format(f=rtc_file))
 def _to_object(self, path):
     log.debug("Loading from {p}".format(p=path))
     return load_tool_contract_from(path)
Ejemplo n.º 6
0
 def test_01(self):
     file_name = "dev_example_tool_contract.json"
     path = get_data_file(file_name)
     tc = load_tool_contract_from(path)
     self.assertIsInstance(tc, ToolContract)
Ejemplo n.º 7
0
def tool_contract_to_meta_task_from_file(path):
    """Loads a tool contract from a path and converts it to a StaticMetaTask"""
    tc = load_tool_contract_from(path)
    # FIXME
    max_chunks = 5
    return tool_contract_to_meta_task(tc, max_chunks)