comparison env/lib/python3.7/site-packages/ephemeris/shed_tools_args.py @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
1 """This file contains the parser for shed_tools"""
2
3 import argparse
4
5 from .common_parser import get_common_args
6
7
8 def parser():
9 """construct the parser object"""
10 common_arguments = get_common_args(log_file=True)
11 shed_parser = argparse.ArgumentParser()
12 subparsers = shed_parser.add_subparsers()
13
14 # A list of defaults is needed. Otherwise the shed-tools install parser will not return
15 # update_tools in the name space and shed-tool update will not return all the install
16 # variables.
17 shed_parser.set_defaults(
18 action="install",
19 tool_list_file=None,
20 tool_yaml=None,
21 owner=None,
22 name=None,
23 tool_panel_section_id=None,
24 tool_panel_section_label=None,
25 revisions=None,
26 tool_shed_url=None,
27 skip_tool_dependencies=False,
28 install_resolver_dependencies=False,
29 force_latest_revision=False,
30 test=False,
31 test_user_api_key=None,
32 test_user="ephemeris@galaxyproject.org",
33 test_json="tool_test_output.json",
34 test_existing=False,
35 parallel_tests=1,
36 )
37
38 # SUBPARSERS
39 install_command_parser = subparsers.add_parser(
40 "install",
41 help="This installs tools in Galaxy from the Tool Shed."
42 "Use shed-tools install --help for more information",
43 parents=[common_arguments],
44 )
45 update_command_parser = subparsers.add_parser(
46 "update",
47 help="This updates all tools in Galaxy to the latest revision. "
48 "Use shed-tools update --help for more information",
49 parents=[common_arguments])
50
51 test_command_parser = subparsers.add_parser(
52 "test",
53 help="This tests the supplied list of tools in Galaxy. "
54 "Use shed-tools test --help for more information",
55 parents=[common_arguments])
56
57 # SUBPARSER DEFAULTS
58 update_command_parser.set_defaults(
59 action="update"
60 )
61
62 test_command_parser.set_defaults(
63 action="test"
64 )
65 install_command_parser.set_defaults(
66 action="install"
67 )
68
69 # COMMON OPTIONS
70 for command_parser in [update_command_parser, install_command_parser, test_command_parser]:
71 command_parser.add_argument(
72 "-t", "--toolsfile",
73 dest="tool_list_file",
74 help="Tools file to use (see tool_list.yaml.sample)", )
75 command_parser.add_argument(
76 "-y", "--yaml_tool",
77 dest="tool_yaml",
78 help="Install tool represented by yaml string", )
79 command_parser.add_argument(
80 "--name",
81 help="The name of the tool to install (only applicable "
82 "if the tools file is not provided).")
83 command_parser.add_argument(
84 "--owner",
85 help="The owner of the tool to install (only applicable "
86 "if the tools file is not provided).")
87 command_parser.add_argument(
88 "--revisions",
89 default=None,
90 nargs='*',
91 dest="revisions",
92 help="The revisions of the tool repository that will be installed. "
93 "All revisions must be specified after this flag by a space."
94 "Example: --revisions 0a5c7992b1ac f048033da666"
95 "(Only applicable if the tools file is not provided).")
96 command_parser.add_argument(
97 "--toolshed",
98 dest="tool_shed_url",
99 help="The Tool Shed URL where to install the tool from. "
100 "This is applicable only if the tool info is "
101 "provided as an option vs. in the tools file.")
102
103 # OPTIONS COMMON FOR UPDATE AND INSTALL
104
105 for command_parser in [update_command_parser, install_command_parser]:
106 command_parser.add_argument(
107 "--skip_install_tool_dependencies",
108 action="store_false",
109 dest="install_tool_dependencies",
110 default=False, # Override True default for this function
111 help=argparse.SUPPRESS) # Deprecated function. Leave for backwards compatibility.
112 command_parser.add_argument(
113 "--install_tool_dependencies",
114 action="store_true",
115 dest="install_tool_dependencies",
116 help="Turn on installation of tool dependencies using classic toolshed packages. "
117 "Can be overwritten on a per-tool basis in the tools file.")
118 command_parser.add_argument(
119 "--install_resolver_dependencies",
120 action="store_true",
121 dest="install_resolver_dependencies",
122 default=True, # Override False default for this function
123 help=argparse.SUPPRESS) # Deprecated function. Leave for backwards compatibility.
124 command_parser.add_argument(
125 "--skip_install_resolver_dependencies",
126 action="store_false",
127 dest="install_resolver_dependencies",
128 help="Skip installing tool dependencies through resolver (e.g. conda). "
129 "Will be ignored on galaxy releases older than 16.07. "
130 "Can be overwritten on a per-tool basis in the tools file")
131 command_parser.add_argument(
132 "--skip_install_repository_dependencies",
133 action="store_false",
134 dest="install_repository_dependencies",
135 help="Skip installing the repository dependencies."
136 )
137 command_parser.add_argument(
138 "--test",
139 action="store_true",
140 dest="test",
141 help="Run tool tests on install tools, requires Galaxy 18.05 or newer."
142 )
143 command_parser.add_argument(
144 "--test_existing",
145 action="store_true",
146 help="If testing tools during install, also run tool tests on repositories already installed "
147 "(i.e. skipped repositories)."
148 )
149 command_parser.add_argument(
150 "--test_json",
151 dest="test_json",
152 default="tool_test_output.json",
153 help="If testing tools, record tool test output to specified file. "
154 "This file can be turned into reports with ``planemo test_reports <output.json>``."
155 )
156 command_parser.add_argument(
157 "--test_user_api_key",
158 dest="test_user",
159 help="If testing tools, a user is needed to execute the tests. "
160 "This can be different the --api_key which is assumed to be an admin key. "
161 "If --api_key is a valid user (e.g. it is not a master API key) this does "
162 "not need to be specified and --api_key will be reused."
163 )
164 command_parser.add_argument(
165 "--test_user",
166 dest="test_user",
167 help="If testing tools, a user is needed to execute the tests. "
168 "If --api_key is a master api key (i.e. not tied to a real user) and "
169 "--test_user_api_key isn't specified, this user email will be used. This "
170 "user will be created if needed."
171 )
172 command_parser.add_argument(
173 "--parallel_tests",
174 dest="parallel_tests",
175 default=1,
176 type=int,
177 help="Specify the maximum number of tests that will be run in parallel."
178 )
179
180 # OPTIONS UNIQUE TO INSTALL
181
182 install_command_parser.add_argument(
183 "--section",
184 dest="tool_panel_section_id",
185 help="Galaxy tool panel section ID where the tool will "
186 "be installed (the section must exist in Galaxy; "
187 "only applicable if the tools file is not provided).")
188 install_command_parser.add_argument(
189 "--section_label",
190 default=None,
191 dest="tool_panel_section_label",
192 help="Galaxy tool panel section label where tool will be installed "
193 "(if the section does not exist, it will be created; "
194 "only applicable if the tools file is not provided).")
195
196 install_command_parser.add_argument(
197 "--latest",
198 action="store_true",
199 dest="force_latest_revision",
200 help="Will override the revisions in the tools file and always install the latest revision.")
201
202 # OPTIONS UNIQUE TO TEST
203 # Same test_json as above but language modified for test instead of install/update.
204 test_command_parser.add_argument(
205 "--test_json",
206 default="tool_test_output.json",
207 dest="test_json",
208 help="Record tool test output to specified file. "
209 "This file can be turned into reports with ``planemo test_reports <output.json>``."
210 )
211
212 test_command_parser.add_argument(
213 "--test_user_api_key",
214 dest="test_user_api_key",
215 help="A user is needed to execute the tests. "
216 "This can be different the --api_key which is assumed to be an admin key. "
217 "If --api_key is a valid user (e.g. it is not a master API key) this does "
218 "not need to be specified and --api_key will be reused."
219 )
220 test_command_parser.add_argument(
221 "--test_user",
222 dest="test_user",
223 help="A user is needed to execute the tests. "
224 "If --api_key is a master api key (i.e. not tied to a real user) and "
225 "--test_user_api_key isn't specified, this user email will be used. This "
226 "user will be created if needed."
227 )
228 test_command_parser.add_argument(
229 "--parallel_tests",
230 dest="parallel_tests",
231 default=1,
232 type=int,
233 help="Specify the maximum number of tests that will be run in parallel."
234 )
235
236 return shed_parser