def main(argsl=None): if not argsl: argsl = sys.argv[1:] parser = get_parser() args = parser.parse_args(argsl) logger.debug("command:{}".format(args.command)) if args.command == 'tool': logger.debug("subtool names:{}".format(args.subtool_names)) add_tool(args.tool_name, args.version_name, subtool_names=args.subtool_names, biotools_id=args.biotoolsID, has_primary=args.has_primary, init_cwl=args.init_cwl, init_wdl=args.init_wdl, init_sm=args.init_sm, init_nf=args.init_nf, root_repo_path=args.root_path, refresh_index=args.refresh_index, no_clobber=args.no_clobber) elif args.command == 'subtool': add_subtool(args.tool_name, args.version_name, args.subtool_name, update_featureList=args.update_featureList, init_cwl=args.init_cwl, init_wdl=args.init_wdl, init_sm=args.init_sm, init_nf=args.init_nf, root_repo_path=args.root_path, no_clobber=args.no_clobber) elif args.command == 'tool-instance': add_tool_instance(args.tool_name, args.version_name, args.subtool_name, root_repo_path=args.root_path) elif args.command == 'common-script': add_common_script_metadata(args.group_name, args.project_name, args.script_version, args.filename, root_repo_path=args.root_path) elif args.command == 'script': add_script(args.group_name, args.project_name, args.script_version, args.script_name, parentMetadata=args.parent_metadata, init_cwl=args.init_cwl, root_repo_path=args.root_path) elif args.command == 'script-instance': raise NotImplementedError elif args.command == 'workflow': print(add_workflow.__name__) add_workflow(args.group_name, args.workflow_name, args.workflow_version) else: parser.print_help() return
def test_add_with_main(self): with TemporaryDirectory() as tmp_dir: self.make_empty_tools_index(tmp_dir) tool_name = 'test___2' tool_version = '123' add_tool(tool_name, tool_version, has_primary=True, root_repo_path=tmp_dir, refresh_index=False) return
def test_add_with_subtools(self): with TemporaryDirectory() as tmp_dir: self.make_empty_tools_index(tmp_dir) tool_name = 'test___3' tool_version = '123' add_tool(tool_name, tool_version, subtool_names=['first', 'second'], has_primary=True, root_repo_path=tmp_dir, refresh_index=False) assert True return
def test_add_parent_then_subtool(self): with TemporaryDirectory() as tmp_dir: self.make_empty_tools_index(tmp_dir) tool_name = 'test_tool' tool_version = '0.1' add_tool(tool_name, tool_version, root_repo_path=tmp_dir, refresh_index=False) add_subtool(tool_name, tool_version, 'subtool1', root_repo_path=tmp_dir, update_featureList=True) assert True return
def test_add_with_main(self): with TemporaryDirectory() as tmp_dir: tool_name = 'test___2' tool_version = '123' add_tool(tool_name, tool_version, has_primary=True, root_repo_path=tmp_dir) return
def test_make_file(self): with TemporaryDirectory(prefix="xD_test") as tmpdir: self.make_empty_tools_index(tmpdir) add_tool('test1', '1.0', 'subtool1', root_repo_path=tmpdir, refresh_index=False) assert True return
def test_add_with_subtools(self): with TemporaryDirectory() as tmp_dir: tool_name = 'test___3' tool_version = '123' add_tool(tool_name, tool_version, subtool_names=['first', 'second'], has_primary=True, root_repo_path=tmp_dir) return
def test_add_parent_then_subtool(self): with TemporaryDirectory() as tmp_dir: tool_name = 'test_tool' tool_version = '0.1' add_tool(tool_name, tool_version, root_repo_path=tmp_dir) add_subtool(tool_name, tool_version, 'subtool1', root_repo_path=tmp_dir, update_featureList=True) assert True return
def test_add_parent_only(self): with TemporaryDirectory(prefix='dont_see me_') as tmp_dir: self.make_empty_tools_index(tmp_dir) tool_name = 'test__1' tool_version = '123' add_tool(tool_name, tool_version, root_repo_path=tmp_dir, refresh_index=False) # Index is not refreshed because there is nothing in the content repo. Will throw FileNotFound error when trying to traverse directories. # the tool added should be the only identifier in the index. parent_metadata_path = get_tool_metadata(tool_name, tool_version, parent=True, base_dir=tmp_dir) with self.assertRaises(InIndexError): # This should fail because trying to assign identifier that is already uses (by itself). parent_metadata = ParentToolMetadata.load_from_file(parent_metadata_path, _in_index=False, root_repo_path=tmp_dir) assert True parent_metadata = ParentToolMetadata.load_from_file(parent_metadata_path, root_repo_path=tmp_dir) # this should succeed with the _in_index flag. assert True return
def test_handle_duplicate_subtool_identifier_2(self): """ Add two subtools and parent with one command. :return: """ tool_name = 'samtools' tool_version = '1.x' subtool_name = 'dict' # both subtool identifiers start with 'bb' subtool_name_2 = 'faidx' with TemporaryDirectory() as temp_dir: self.make_empty_tools_index(temp_dir) add_tool(tool_name, tool_version, [subtool_name, subtool_name_2], root_repo_path=temp_dir, refresh_index=False) subtool_1_metadata_path = get_tool_metadata(tool_name, tool_version, subtool_name, base_dir=temp_dir) subtool_2_metadata_path = get_tool_metadata(tool_name, tool_version, subtool_name_2, base_dir=temp_dir) subtool_1_metadata = SubtoolMetadata.load_from_file(subtool_1_metadata_path) subtool_2_metadata = SubtoolMetadata.load_from_file(subtool_2_metadata_path) self.assertNotEqual(subtool_1_metadata.identifier, subtool_2_metadata.identifier) return
def main(argsl=None): if not argsl: argsl = sys.argv[1:] parser = get_parser() args = parser.parse_args(argsl) if args.command == 'tool': add_tool(args.tool_name, args.version_name, subtool_names=args.subtool_names, biotools_id=args.biotoolsID, has_primary=args.has_primary, init_cwl=args.init_cwl, root_repo_path=args.root_path) elif args.command == 'subtool': add_subtool(args.tool_name, args.version_name, args.subtool_name, update_featureList=args.update_featureList, init_cwl=args.init_cwl, root_repo_path=args.root_path) elif args.command == 'common_script': add_common_script_metadata(args.group_name, args.project_name, args.script_version, args.filename, root_repo_path=args.root_path) elif args.command == 'script': add_script(args.group_name, args.project_name, args.script_version, args.script_name, parentMetadata=args.parent_metadata, init_cwl=args.init_cwl, root_repo_path=args.root_path) elif args.command == 'workflow': add_workflow(args.group_name, args.workflow_name, args.workflow_version) else: parser.print_help() return
def test_handle_duplicate_subtool_identifier(self): """ Add subtools one at a time. :return: """ tool_name = 'samtools' tool_version = '1.x' subtool_name = 'dict' # both subtool identifiers start with 'bb' subtool_name_2 = 'faidx' with TemporaryDirectory() as temp_dir: self.make_empty_tools_index(temp_dir) add_tool(tool_name, tool_version, subtool_name, root_repo_path=temp_dir, refresh_index=False) add_subtool(tool_name, tool_version, subtool_name_2, root_repo_path=temp_dir, update_featureList=True) subtool_1_metadata_path = get_tool_metadata(tool_name, tool_version, subtool_name, base_dir=temp_dir) subtool_2_metadata_path = get_tool_metadata(tool_name, tool_version, subtool_name_2, base_dir=temp_dir) with self.assertRaises(InIndexError): subtool_1_metadata = SubtoolMetadata.load_from_file(subtool_1_metadata_path, _in_index=False, root_repo_path=temp_dir) subtool_1_metadata = SubtoolMetadata.load_from_file(subtool_1_metadata_path, _in_index=True, root_repo_path=temp_dir) subtool_2_metadata = SubtoolMetadata.load_from_file(subtool_2_metadata_path, _in_index=True, root_repo_path=temp_dir) self.assertNotEqual(subtool_1_metadata.identifier, subtool_2_metadata.identifier) return
def test_add_multiple(self): with TemporaryDirectory() as tmp_dir: self.make_empty_tools_index(tmp_dir) add_tool('fake_1', '123', root_repo_path=tmp_dir, refresh_index=False) # parent only. Don't try to assemble index. Paths it would need to access aren't there yet. add_tool('fake_2', '123', has_primary=True, root_repo_path=tmp_dir) # # parent with main tool add_tool('fake_3', '123', subtool_names=['first', 'second'], has_primary=True, root_repo_path=tmp_dir) assert True return
def test_add_multiple(self): with TemporaryDirectory() as tmp_dir: add_tool('fake_1', '123', root_repo_path=tmp_dir) # parent only. add_tool('fake_2', '123', has_primary=True, root_repo_path=tmp_dir) # # parent with main tool add_tool('fake_3', '123', subtool_names=['first', 'second'], has_primary=True, root_repo_path=tmp_dir) assert True return
def test_add_parent_only(self): with TemporaryDirectory(prefix='dont_see me_') as tmp_dir: tool_name = 'test__1' tool_version = '123' add_tool(tool_name, tool_version, root_repo_path=tmp_dir) return
def test_make_file(self): with TemporaryDirectory(prefix="xD_test") as tmpdir: add_tool('test1', '1.0', 'subtool1', root_repo_path=tmpdir) assert True return