mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #7331 from mvdbeek/test_data_managers
[19.01] Discriminate data managers and allow managed testing
This commit is contained in:
@@ -57,11 +57,19 @@ class DataManagers(object):
|
||||
tool_path = '.'
|
||||
self.tool_path = tool_path
|
||||
for data_manager_elem in root.findall('data_manager'):
|
||||
self.load_manager_from_elem(data_manager_elem, tool_path=self.tool_path)
|
||||
if not self.load_manager_from_elem(data_manager_elem, tool_path=self.tool_path):
|
||||
# Wasn't able to load manager, could happen when galaxy is managed by planemo.
|
||||
# Fall back to loading relative to the data_manager_conf.xml file
|
||||
tool_path = os.path.dirname(xml_filename)
|
||||
self.load_manager_from_elem(data_manager_elem, tool_path=tool_path)
|
||||
|
||||
def load_manager_from_elem(self, data_manager_elem, tool_path=None, add_manager=True):
|
||||
try:
|
||||
data_manager = DataManager(self, data_manager_elem, tool_path=tool_path)
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
# File does not exist
|
||||
return None
|
||||
except Exception as e:
|
||||
log.error("Error loading data_manager '%s':\n%s" % (e, util.xml_to_string(data_manager_elem)))
|
||||
return None
|
||||
|
||||
@@ -19,6 +19,7 @@ PATH_AND_RECURSIVE_ERROR = "Cannot specify a single file and recursive."
|
||||
LOAD_FAILURE_ERROR = "Failed to load tool with path %s."
|
||||
TOOL_LOAD_ERROR = object()
|
||||
TOOL_REGEX = re.compile(r"<tool\s")
|
||||
DATA_MANAGER_REGEX = re.compile(r"\stool_type=\"manage_data\"")
|
||||
|
||||
YAML_EXTENSIONS = [".yaml", ".yml", ".json"]
|
||||
CWL_EXTENSIONS = YAML_EXTENSIONS + [".cwl"]
|
||||
@@ -153,8 +154,7 @@ def looks_like_a_tool(path_or_uri_like, invalid_names=[], enable_beta_formats=Fa
|
||||
return looks
|
||||
|
||||
|
||||
def looks_like_a_tool_xml(path):
|
||||
"""Quick check to see if a file looks like it may be a Galaxy XML tool file."""
|
||||
def looks_like_xml(path, regex=TOOL_REGEX):
|
||||
full_path = os.path.abspath(path)
|
||||
|
||||
if not full_path.endswith(".xml"):
|
||||
@@ -172,12 +172,22 @@ def looks_like_a_tool_xml(path):
|
||||
|
||||
with open(path, "r") as f:
|
||||
start_contents = f.read(5 * 1024)
|
||||
if TOOL_REGEX.search(start_contents):
|
||||
if regex.search(start_contents):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def looks_like_a_tool_xml(path):
|
||||
"""Quick check to see if a file looks like it may be a Galaxy XML tool file."""
|
||||
return looks_like_xml(path=path, regex=TOOL_REGEX)
|
||||
|
||||
|
||||
def looks_like_a_data_manager_xml(path):
|
||||
"""Quick check to see if a file looks like it may be a Galaxy data manager XML file."""
|
||||
return looks_like_xml(path=path, regex=DATA_MANAGER_REGEX)
|
||||
|
||||
|
||||
def is_a_yaml_with_class(path, classes):
|
||||
"""Determine if a file is a valid YAML with a supplied ``class`` entry."""
|
||||
if not _has_extension(path, YAML_EXTENSIONS):
|
||||
|
||||
Reference in New Issue
Block a user