Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/galaxy/tool_util/deps/dependencies.py @ 0:d30785e31577 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:18:57 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d30785e31577 |
---|---|
1 from galaxy.tool_util.deps.requirements import ToolRequirements | |
2 from galaxy.util import bunch | |
3 from .mulled.mulled_build import DEFAULT_CHANNELS | |
4 | |
5 | |
6 class AppInfo(object): | |
7 | |
8 def __init__( | |
9 self, | |
10 galaxy_root_dir=None, | |
11 default_file_path=None, | |
12 tool_data_path=None, | |
13 shed_tool_data_path=None, | |
14 outputs_to_working_directory=False, | |
15 container_image_cache_path=None, | |
16 library_import_dir=None, | |
17 enable_mulled_containers=False, | |
18 containers_resolvers_config_file=None, | |
19 involucro_path=None, | |
20 involucro_auto_init=True, | |
21 mulled_channels=DEFAULT_CHANNELS, | |
22 ): | |
23 self.galaxy_root_dir = galaxy_root_dir | |
24 self.default_file_path = default_file_path | |
25 self.tool_data_path = tool_data_path | |
26 self.shed_tool_data_path = shed_tool_data_path | |
27 # TODO: Vary default value for docker_volumes based on this... | |
28 self.outputs_to_working_directory = outputs_to_working_directory | |
29 self.container_image_cache_path = container_image_cache_path | |
30 self.library_import_dir = library_import_dir | |
31 self.enable_mulled_containers = enable_mulled_containers | |
32 self.containers_resolvers_config_file = containers_resolvers_config_file | |
33 self.involucro_path = involucro_path | |
34 self.involucro_auto_init = involucro_auto_init | |
35 self.mulled_channels = mulled_channels | |
36 | |
37 | |
38 class ToolInfo(object): | |
39 # TODO: Introduce tool XML syntax to annotate the optional environment | |
40 # variables they can consume (e.g. JVM options, license keys, etc..) | |
41 # and add these to env_path_through | |
42 | |
43 def __init__(self, container_descriptions=None, requirements=None, requires_galaxy_python_environment=False, env_pass_through=["GALAXY_SLOTS"], guest_ports=None, tool_id=None, tool_version=None, profile=-1): | |
44 if container_descriptions is None: | |
45 container_descriptions = [] | |
46 if requirements is None: | |
47 requirements = [] | |
48 self.container_descriptions = container_descriptions | |
49 self.requirements = requirements | |
50 self.requires_galaxy_python_environment = requires_galaxy_python_environment | |
51 self.env_pass_through = env_pass_through | |
52 self.guest_ports = guest_ports | |
53 self.tool_id = tool_id | |
54 self.tool_version = tool_version | |
55 self.profile = profile | |
56 | |
57 | |
58 class JobInfo(object): | |
59 | |
60 def __init__( | |
61 self, working_directory, tool_directory, job_directory, tmp_directory, home_directory, job_directory_type, | |
62 ): | |
63 self.working_directory = working_directory | |
64 # Tool files may be remote staged - so this is unintuitively a property | |
65 # of the job not of the tool. | |
66 self.tool_directory = tool_directory | |
67 self.job_directory = job_directory | |
68 self.tmp_directory = tmp_directory | |
69 self.home_directory = home_directory | |
70 self.job_directory_type = job_directory_type # "galaxy" or "pulsar" | |
71 | |
72 | |
73 class DependenciesDescription(object): | |
74 """ Capture (in a readily serializable way) context related a tool | |
75 dependencies - both the tool's listed requirements and the tool shed | |
76 related context required to resolve dependencies via the | |
77 ToolShedPackageDependencyResolver. | |
78 | |
79 This is meant to enable remote resolution of dependencies, by the Pulsar or | |
80 other potential remote execution mechanisms. | |
81 """ | |
82 | |
83 def __init__(self, requirements=[], installed_tool_dependencies=[]): | |
84 self.requirements = requirements | |
85 # tool shed installed tool dependencies... | |
86 self.installed_tool_dependencies = installed_tool_dependencies | |
87 | |
88 def to_dict(self): | |
89 return dict( | |
90 requirements=[r.to_dict() for r in self.requirements], | |
91 installed_tool_dependencies=[DependenciesDescription._toolshed_install_dependency_to_dict(d) for d in self.installed_tool_dependencies] | |
92 ) | |
93 | |
94 @staticmethod | |
95 def from_dict(as_dict): | |
96 if as_dict is None: | |
97 return None | |
98 | |
99 requirements_dicts = as_dict.get('requirements', []) | |
100 requirements = ToolRequirements.from_list(requirements_dicts) | |
101 installed_tool_dependencies_dicts = as_dict.get('installed_tool_dependencies', []) | |
102 installed_tool_dependencies = list(map(DependenciesDescription._toolshed_install_dependency_from_dict, installed_tool_dependencies_dicts)) | |
103 return DependenciesDescription( | |
104 requirements=requirements, | |
105 installed_tool_dependencies=installed_tool_dependencies | |
106 ) | |
107 | |
108 @staticmethod | |
109 def _toolshed_install_dependency_from_dict(as_dict): | |
110 # Rather than requiring full models in Pulsar, just use simple objects | |
111 # containing only properties and associations used to resolve | |
112 # dependencies for tool execution. | |
113 repository_object = bunch.Bunch( | |
114 name=as_dict['repository_name'], | |
115 owner=as_dict['repository_owner'], | |
116 installed_changeset_revision=as_dict['repository_installed_changeset'], | |
117 ) | |
118 dependency_object = bunch.Bunch( | |
119 name=as_dict['dependency_name'], | |
120 version=as_dict['dependency_version'], | |
121 type=as_dict['dependency_type'], | |
122 tool_shed_repository=repository_object, | |
123 ) | |
124 return dependency_object | |
125 | |
126 @staticmethod | |
127 def _toolshed_install_dependency_to_dict(tool_dependency): | |
128 tool_shed_repository = tool_dependency.tool_shed_repository | |
129 return dict( | |
130 dependency_name=tool_dependency.name, | |
131 dependency_version=tool_dependency.version, | |
132 dependency_type=tool_dependency.type, | |
133 repository_name=tool_shed_repository.name, | |
134 repository_owner=tool_shed_repository.owner, | |
135 repository_installed_changeset=tool_shed_repository.installed_changeset_revision, | |
136 ) |