Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/planemo/options.py @ 5:9b1c78e6ba9c draft default tip
"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author | shellac |
---|---|
date | Mon, 01 Jun 2020 08:59:25 -0400 |
parents | 79f47841a781 |
children |
comparison
equal
deleted
inserted
replaced
4:79f47841a781 | 5:9b1c78e6ba9c |
---|---|
1 """Click definitions for various shared options and arguments.""" | |
2 | |
3 from __future__ import absolute_import | |
4 | |
5 import functools | |
6 import os | |
7 | |
8 import click | |
9 from galaxy.tool_util.deps import docker_util | |
10 | |
11 from .config import planemo_option | |
12 | |
13 | |
14 def force_option(what="files"): | |
15 return planemo_option( | |
16 "-f", | |
17 "--force", | |
18 is_flag=True, | |
19 help="Overwrite existing %s if present." % what, | |
20 ) | |
21 | |
22 | |
23 def skip_venv_option(): | |
24 return planemo_option( | |
25 "--skip_venv", | |
26 is_flag=True, | |
27 help=("Do not create or source a virtualenv environment for Galaxy, " | |
28 "this should be used or instance to preserve an externally " | |
29 "configured virtual environment or conda environment.") | |
30 ) | |
31 | |
32 | |
33 def run_engine_option(): | |
34 return planemo_option( | |
35 "--engine", | |
36 type=click.Choice(["galaxy", "docker_galaxy", "cwltool", "toil", "external_galaxy"]), | |
37 default=None, | |
38 use_global_config=True, | |
39 help=("Select an engine to run or test artifacts such as tools " | |
40 "and workflows. Defaults to a local Galaxy, but running Galaxy within " | |
41 "a Docker container or the CWL reference implementation 'cwltool' and " | |
42 "'toil' be selected.") | |
43 ) | |
44 | |
45 | |
46 def non_strict_cwl_option(): | |
47 return planemo_option( | |
48 "--non_strict_cwl", | |
49 default=False, | |
50 is_flag=True, | |
51 help="Disable strict validation of CWL.", | |
52 ) | |
53 | |
54 | |
55 def serve_engine_option(): | |
56 return planemo_option( | |
57 "--engine", | |
58 type=click.Choice(["galaxy", "docker_galaxy", "external_galaxy"]), | |
59 default="galaxy", | |
60 use_global_config=True, | |
61 use_env_var=True, | |
62 help=("Select an engine to serve artifacts such as tools " | |
63 "and workflows. Defaults to a local Galaxy, but running Galaxy within " | |
64 "a Docker container.") | |
65 ) | |
66 | |
67 | |
68 def ignore_dependency_problems_option(): | |
69 return planemo_option( | |
70 "--ignore_dependency_problems", | |
71 is_flag=True, | |
72 default=False, | |
73 use_global_config=True, | |
74 help=("When installing shed repositories for workflows, ignore dependency issues. " | |
75 "These likely indicate a problem but in some cases may not prevent a workflow " | |
76 "from successfully executing.") | |
77 ) | |
78 | |
79 | |
80 def cwltool_no_container_option(): | |
81 return planemo_option( | |
82 "--no-container", | |
83 "--no_container", | |
84 is_flag=True, | |
85 default=False, | |
86 use_global_config=True, | |
87 help=("If cwltool engine is used, disable Docker container usage.") | |
88 ) | |
89 | |
90 | |
91 def test_data_option(): | |
92 return planemo_option( | |
93 "--test_data", | |
94 type=click.Path(exists=True, file_okay=False, resolve_path=True), | |
95 help="test-data directory to for specified tool(s).", | |
96 ) | |
97 | |
98 | |
99 def extra_tools_option(): | |
100 return planemo_option( | |
101 "--extra_tools", | |
102 type=click.Path(exists=True, | |
103 file_okay=True, | |
104 dir_okay=True, | |
105 resolve_path=True), | |
106 multiple=True, | |
107 help=("Extra tool sources to include in Galaxy's tool panel (file or " | |
108 "directory). These will not be linted/tested/etc... but they " | |
109 "will be available to workflows and for interactive use.") | |
110 ) | |
111 | |
112 | |
113 def tool_data_table_option(): | |
114 return planemo_option( | |
115 "--tool_data_table", | |
116 type=click.Path(exists=True, file_okay=True, resolve_path=True), | |
117 help="tool_data_table_conf.xml file to for specified tool(s).", | |
118 ) | |
119 | |
120 | |
121 def galaxy_email_option(): | |
122 return planemo_option( | |
123 "--galaxy_email", | |
124 type=str, | |
125 default="planemo@galaxyproject.org", | |
126 use_global_config=True, | |
127 use_env_var=True, | |
128 help="E-mail address to use when launching single-user Galaxy server.", | |
129 ) | |
130 | |
131 | |
132 def galaxy_python_version(): | |
133 return planemo_option( | |
134 '--galaxy_python_version', | |
135 use_global_config=True, | |
136 default=None, | |
137 type=click.Choice(['2', '2.7', '3', '3.5', '3.6', '3.7', '3.8']), | |
138 help="Python version to start Galaxy under", | |
139 ) | |
140 | |
141 | |
142 def galaxy_root_option(): | |
143 return planemo_option( | |
144 "--galaxy_root", | |
145 use_global_config=True, | |
146 extra_global_config_vars=["galaxy_root"], | |
147 use_env_var=True, | |
148 type=click.Path(file_okay=False, dir_okay=True, resolve_path=True), | |
149 help="Root of development galaxy directory to execute command with.", | |
150 ) | |
151 | |
152 | |
153 def galaxy_cwl_root_option(): | |
154 return planemo_option( | |
155 "--cwl_galaxy_root", | |
156 use_global_config=True, | |
157 extra_global_config_vars=["cwl_galaxy_root"], | |
158 use_env_var=True, | |
159 type=click.Path(exists=True, file_okay=False, resolve_path=True), | |
160 help=("Root of development galaxy directory to execute command with" | |
161 " (must be branch of Galaxy with CWL support, this option" | |
162 " is experimental and will be replaced with --galaxy_root when" | |
163 " and if CWL support is merged into Galaxy."), | |
164 ) | |
165 | |
166 | |
167 def galaxy_port_option(): | |
168 return planemo_option( | |
169 "--port", | |
170 type=int, | |
171 default="9090", | |
172 use_global_config=True, | |
173 help="Port to serve Galaxy on (default is 9090).", | |
174 ) | |
175 | |
176 | |
177 def galaxy_host_option(): | |
178 return planemo_option( | |
179 "--host", | |
180 type=str, | |
181 default="127.0.0.1", | |
182 use_global_config=True, | |
183 help=("Host to bind Galaxy to. Default is 127.0.0.1 that is " | |
184 "restricted to localhost connections for security reasons " | |
185 "set to 0.0.0.0 to bind Galaxy to all ports including " | |
186 "potentially publicly accessible ones."), | |
187 ) | |
188 | |
189 | |
190 def dependency_resolvers_option(): | |
191 return planemo_option( | |
192 "--dependency_resolvers_config_file", | |
193 type=click.Path( | |
194 exists=True, | |
195 file_okay=True, | |
196 dir_okay=False, | |
197 resolve_path=True | |
198 ), | |
199 use_global_config=True, | |
200 help="Dependency resolver configuration for Galaxy to target.", | |
201 ) | |
202 | |
203 | |
204 def enable_cwl_option(): | |
205 return planemo_option( | |
206 "--cwl", | |
207 is_flag=True, | |
208 help=("Configure Galaxy for use with CWL tool." | |
209 " (this option is experimental and will be replaced when" | |
210 " and if CWL support is merged into Galaxy)."), | |
211 ) | |
212 | |
213 | |
214 def build_cwl_option(): | |
215 return planemo_option( | |
216 "--cwl", | |
217 is_flag=True, | |
218 help="Build a CWL tool instead of a Galaxy tool.", | |
219 ) | |
220 | |
221 | |
222 def run_output_directory_option(): | |
223 return planemo_option( | |
224 "output_directory", | |
225 "--output_directory", | |
226 "--outdir", | |
227 type=click.Path( | |
228 file_okay=False, | |
229 dir_okay=True, | |
230 resolve_path=True, | |
231 ), | |
232 default=None, | |
233 help=("Where to store outputs of a 'run' task."), | |
234 ) | |
235 | |
236 | |
237 def run_output_json_option(): | |
238 return planemo_option( | |
239 "output_json", | |
240 "--output_json", | |
241 type=click.Path( | |
242 file_okay=True, | |
243 dir_okay=False, | |
244 resolve_path=True, | |
245 ), | |
246 default=None, | |
247 help=("Where to store JSON dictionary describing outputs of " | |
248 "a 'run' task."), | |
249 ) | |
250 | |
251 | |
252 def no_dependency_resolution(): | |
253 return planemo_option( | |
254 "--no_dependency_resolution", | |
255 is_flag=True, | |
256 help="Configure Galaxy with no dependency resolvers.", | |
257 ) | |
258 | |
259 | |
260 def brew_dependency_resolution(): | |
261 return planemo_option( | |
262 "--brew_dependency_resolution", | |
263 is_flag=True, | |
264 help="Configure Galaxy to use plain brew dependency resolution.", | |
265 ) | |
266 | |
267 | |
268 def conda_dependency_resolution(): | |
269 return planemo_option( | |
270 "--conda_dependency_resolution", | |
271 is_flag=True, | |
272 help="Configure Galaxy to use only conda for dependency resolution.", | |
273 ) | |
274 | |
275 | |
276 def shed_dependency_resolution(): | |
277 return planemo_option( | |
278 "--shed_dependency_resolution", | |
279 is_flag=True, | |
280 help=("Configure Galaxy to use brewed Tool Shed dependency" | |
281 " resolution."), | |
282 ) | |
283 | |
284 | |
285 def file_path_option(): | |
286 return planemo_option( | |
287 "--file_path", | |
288 type=click.Path( | |
289 file_okay=False, | |
290 dir_okay=True, | |
291 resolve_path=True | |
292 ), | |
293 help="Location for files created by Galaxy (e.g. database/files).", | |
294 default=None, | |
295 use_global_config=True, | |
296 ) | |
297 | |
298 | |
299 def database_connection_option(): | |
300 return planemo_option( | |
301 "--database_connection", | |
302 type=str, | |
303 help="Database connection string to use for Galaxy.", | |
304 default=None, | |
305 use_global_config=True, | |
306 ) | |
307 | |
308 | |
309 def shed_tools_conf_option(): | |
310 return planemo_option( | |
311 "--shed_tool_conf", | |
312 type=str, | |
313 help="Location of shed tools conf file for Galaxy.", | |
314 default=None, | |
315 use_global_config=True, | |
316 ) | |
317 | |
318 | |
319 def shed_tools_directory_option(): | |
320 return planemo_option( | |
321 "--shed_tool_path", | |
322 type=str, | |
323 help="Location of shed tools directory for Galaxy.", | |
324 default=None, | |
325 use_global_config=True, | |
326 ) | |
327 | |
328 | |
329 def tool_dependency_dir_option(): | |
330 return planemo_option( | |
331 "--tool_dependency_dir", | |
332 type=click.Path( | |
333 exists=True, | |
334 file_okay=False, | |
335 dir_okay=True, | |
336 resolve_path=True | |
337 ), | |
338 default=None, | |
339 use_global_config=True, | |
340 help="Tool dependency dir for Galaxy to target.", | |
341 ) | |
342 | |
343 | |
344 def job_config_option(): | |
345 return planemo_option( | |
346 "--job_config_file", | |
347 type=click.Path( | |
348 exists=True, | |
349 file_okay=True, | |
350 dir_okay=False, | |
351 resolve_path=True | |
352 ), | |
353 help="Job configuration file for Galaxy to target.", | |
354 default=None, | |
355 use_global_config=True, | |
356 ) | |
357 | |
358 | |
359 def mulled_containers_option(): | |
360 return planemo_option( | |
361 "mulled_containers", | |
362 "--mulled_containers", | |
363 "--biocontainers", | |
364 is_flag=True, | |
365 help="Test tools against mulled containers (forces --docker).", | |
366 ) | |
367 | |
368 | |
369 def install_galaxy_option(): | |
370 return planemo_option( | |
371 "--install_galaxy", | |
372 is_flag=True, | |
373 help="Download and configure a disposable copy of Galaxy from github." | |
374 ) | |
375 | |
376 | |
377 def docker_galaxy_image_option(): | |
378 return planemo_option( | |
379 "--docker_galaxy_image", | |
380 default="quay.io/bgruening/galaxy", | |
381 use_global_config=True, | |
382 help=("Docker image identifier for docker-galaxy-flavor used if " | |
383 "engine type is specified as ``docker-galaxy``. Defaults to " | |
384 "quay.io/bgruening/galaxy.") | |
385 ) | |
386 | |
387 | |
388 def docker_extra_volume_option(): | |
389 arg_type = click.Path( | |
390 exists=True, | |
391 file_okay=True, | |
392 dir_okay=True, | |
393 readable=True, | |
394 resolve_path=True, | |
395 ) | |
396 return planemo_option( | |
397 "--docker_extra_volume", | |
398 type=arg_type, | |
399 default=None, | |
400 use_global_config=True, | |
401 help=("Extra path to mount if --engine docker.") | |
402 ) | |
403 | |
404 | |
405 def galaxy_url_option(): | |
406 return planemo_option( | |
407 "--galaxy_url", | |
408 use_global_config=True, | |
409 extra_global_config_vars=["galaxy_url"], | |
410 use_env_var=True, | |
411 type=str, | |
412 help="Remote Galaxy URL to use with external Galaxy engine.", | |
413 ) | |
414 | |
415 | |
416 def galaxy_admin_key_option(): | |
417 return planemo_option( | |
418 "--galaxy_admin_key", | |
419 use_global_config=True, | |
420 extra_global_config_vars=["admin_key"], | |
421 use_env_var=True, | |
422 type=str, | |
423 help="Admin key to use with external Galaxy engine.", | |
424 ) | |
425 | |
426 | |
427 def galaxy_user_key_option(): | |
428 return planemo_option( | |
429 "--galaxy_user_key", | |
430 use_global_config=True, | |
431 extra_global_config_vars=["admin_key"], | |
432 use_env_var=True, | |
433 type=str, | |
434 help="User key to use with external Galaxy engine.", | |
435 ) | |
436 | |
437 | |
438 def no_cache_galaxy_option(): | |
439 return planemo_option( | |
440 "--no_cache_galaxy", | |
441 is_flag=True, | |
442 help=("Skip caching of Galaxy source and dependencies obtained with " | |
443 "--install_galaxy. Not caching this results in faster " | |
444 "downloads (no git) - so is better on throw away instances such " | |
445 "with TravisCI. ") | |
446 ) | |
447 | |
448 | |
449 def galaxy_branch_option(): | |
450 return planemo_option( | |
451 "--galaxy_branch", | |
452 default=None, | |
453 use_global_config=True, | |
454 use_env_var=True, | |
455 help=("Branch of Galaxy to target (defaults to master) if a Galaxy " | |
456 "root isn't specified.") | |
457 ) | |
458 | |
459 | |
460 def galaxy_source_option(): | |
461 return planemo_option( | |
462 "--galaxy_source", | |
463 default=None, | |
464 use_global_config=True, | |
465 help=("Git source of Galaxy to target (defaults to the official " | |
466 "galaxyproject github source if a Galaxy root isn't " | |
467 "specified.") | |
468 ) | |
469 | |
470 | |
471 def skip_install_option(): | |
472 return planemo_option( | |
473 "--skip_install", | |
474 is_flag=True, | |
475 help="Skip installation - only source requirements already available." | |
476 ) | |
477 | |
478 | |
479 def brew_option(): | |
480 return planemo_option( | |
481 "--brew", | |
482 use_global_config=True, | |
483 type=click.Path(exists=True, file_okay=True, dir_okay=False), | |
484 help="Homebrew 'brew' executable to use." | |
485 ) | |
486 | |
487 | |
488 def conda_prefix_option(): | |
489 return planemo_option( | |
490 "--conda_prefix", | |
491 use_global_config=True, | |
492 use_env_var=True, | |
493 type=click.Path(file_okay=False, dir_okay=True), | |
494 help="Conda prefix to use for conda dependency commands." | |
495 ) | |
496 | |
497 | |
498 def conda_exec_option(): | |
499 return planemo_option( | |
500 "--conda_exec", | |
501 use_global_config=True, | |
502 type=click.Path(exists=True, file_okay=True, dir_okay=False), | |
503 help="Location of conda executable." | |
504 ) | |
505 | |
506 | |
507 def conda_debug_option(): | |
508 return planemo_option( | |
509 "--conda_debug", | |
510 is_flag=True, | |
511 help="Enable more verbose conda logging." | |
512 ) | |
513 | |
514 | |
515 def conda_use_local_option(): | |
516 return planemo_option( | |
517 "--conda_use_local", | |
518 is_flag=True, | |
519 help="Use locally built packages while building Conda environments." | |
520 ) | |
521 | |
522 | |
523 def conda_ensure_channels_option(): | |
524 return planemo_option( | |
525 "conda_ensure_channels", | |
526 "--conda_channels", | |
527 "--conda_ensure_channels", | |
528 type=str, | |
529 use_global_config=True, | |
530 use_env_var=True, | |
531 help=("Ensure conda is configured with specified comma separated " | |
532 "list of channels."), | |
533 default="iuc,conda-forge,bioconda,defaults", | |
534 ) | |
535 | |
536 | |
537 def conda_copy_dependencies_option(): | |
538 return planemo_option( | |
539 "--conda_copy_dependencies", | |
540 is_flag=True, | |
541 help=("Conda dependency resolution for Galaxy will copy dependencies " | |
542 "instead of attempting to link them.") | |
543 ) | |
544 | |
545 | |
546 def conda_auto_install_option(): | |
547 return planemo_option( | |
548 "--conda_auto_install/--no_conda_auto_install", | |
549 is_flag=True, | |
550 default=True, | |
551 help=("Conda dependency resolution for Galaxy will attempt to install " | |
552 "requested but missing packages.") | |
553 ) | |
554 | |
555 | |
556 def conda_auto_init_option(): | |
557 return planemo_option( | |
558 "--conda_auto_init/--no_conda_auto_init", | |
559 is_flag=True, | |
560 default=True, | |
561 help=("Conda dependency resolution for Galaxy will auto install " | |
562 "conda itself using miniconda if not availabe on conda_prefix.") | |
563 ) | |
564 | |
565 | |
566 def conda_global_option(): | |
567 return planemo_option( | |
568 "--global", | |
569 is_flag=True, | |
570 default=False, | |
571 help=("Install Conda dependencies globally instead of in requirement specific " | |
572 "environments packaged for tools. If the Conda bin directory is on your " | |
573 "PATH, tools may still use binaries but this is more designed for " | |
574 "interactive testing and debugging.") | |
575 ) | |
576 | |
577 | |
578 def required_tool_arg(allow_uris=False): | |
579 """ Decorate click method as requiring the path to a single tool. | |
580 """ | |
581 arg_type_class = click.Path if not allow_uris else UriLike | |
582 arg_type = arg_type_class( | |
583 exists=True, | |
584 file_okay=True, | |
585 dir_okay=False, | |
586 readable=True, | |
587 resolve_path=True, | |
588 ) | |
589 if allow_uris: | |
590 name = "uri" | |
591 metavar = "TOOL_URI" | |
592 else: | |
593 name = "path" | |
594 metavar = "TOOL_PATH" | |
595 return click.argument(name, metavar=metavar, type=arg_type) | |
596 | |
597 | |
598 def paste_test_data_paths_option(): | |
599 return planemo_option( | |
600 "--paste_test_data_paths/--no_paste_test_data_paths", | |
601 is_flag=True, | |
602 default=None, | |
603 help=("By default Planemo will use or not use Galaxy's path paste option to load " | |
604 "test data into a history based on the engine type it is targeting. This can " | |
605 "override the logic to explicitly enable or disable path pasting.") | |
606 ) | |
607 | |
608 | |
609 def shed_install_option(): | |
610 return planemo_option( | |
611 "--shed_install/--no_shed_install", | |
612 is_flag=True, | |
613 default=True, | |
614 help=("By default Planemo will attempt to install repositories needed for workflow " | |
615 "testing. This may not be appropriate for production servers and so this can " | |
616 "disabled by calling planemo with --no_shed_install.") | |
617 ) | |
618 | |
619 | |
620 def single_user_mode_option(): | |
621 return planemo_option( | |
622 "galaxy_single_user", | |
623 "--galaxy_single_user/--no_galaxy_single_user", | |
624 is_flag=True, | |
625 default=True, | |
626 help=("By default Planemo will configure Galaxy to run in single-user mode where there " | |
627 "is just one user and this user is automatically logged it. Use --no_galaxy_single_user " | |
628 "to prevent Galaxy from running this way.") | |
629 ) | |
630 | |
631 | |
632 def required_workflow_arg(): | |
633 arg_type = click.Path( | |
634 exists=True, | |
635 file_okay=True, | |
636 dir_okay=False, | |
637 readable=True, | |
638 resolve_path=False, | |
639 ) | |
640 return click.argument("workflow_path", metavar="WORKFLOW_PATH", type=arg_type) | |
641 | |
642 | |
643 def required_job_arg(): | |
644 """Decorate click method as requiring the path to a single tool. | |
645 """ | |
646 arg_type = click.Path( | |
647 exists=True, | |
648 file_okay=True, | |
649 dir_okay=False, | |
650 readable=True, | |
651 resolve_path=False, | |
652 ) | |
653 return click.argument("job_path", metavar="JOB_PATH", type=arg_type) | |
654 | |
655 | |
656 def _optional_tools_default(ctx, param, value): | |
657 if param.name in ["paths", "uris"] and len(value) == 0: | |
658 return [os.path.abspath(os.getcwd())] | |
659 else: | |
660 return value | |
661 | |
662 | |
663 def optional_tools_or_packages_arg(multiple=False): | |
664 """ Decorate click method as optionally taking in the path to a tool | |
665 or directory of tools or a Conda package. If no such argument is given | |
666 the current working directory will be treated as a directory of tools. | |
667 """ | |
668 name = "paths" if multiple else "path" | |
669 nargs = -1 if multiple else 1 | |
670 return click.argument( | |
671 name, | |
672 metavar="TARGET", | |
673 nargs=nargs, | |
674 ) | |
675 | |
676 | |
677 class UriLike(click.Path): | |
678 | |
679 def convert(self, value, param, ctx): | |
680 if "://" in value: | |
681 return value | |
682 else: | |
683 return super(UriLike, self).convert(value, param, ctx) | |
684 | |
685 | |
686 def optional_tools_arg(multiple=False, allow_uris=False): | |
687 """ Decorate click method as optionally taking in the path to a tool | |
688 or directory of tools. If no such argument is given the current working | |
689 directory will be treated as a directory of tools. | |
690 """ | |
691 arg_type_class = click.Path if not allow_uris else UriLike | |
692 arg_type = arg_type_class( | |
693 exists=True, | |
694 file_okay=True, | |
695 dir_okay=True, | |
696 readable=True, | |
697 resolve_path=True, | |
698 ) | |
699 if allow_uris: | |
700 name = "uris" if multiple else "uri" | |
701 else: | |
702 name = "paths" if multiple else "path" | |
703 nargs = -1 if multiple else 1 | |
704 return click.argument( | |
705 name, | |
706 metavar="TOOL_PATH", | |
707 type=arg_type, | |
708 nargs=nargs, | |
709 callback=_optional_tools_default, | |
710 ) | |
711 | |
712 | |
713 class ProjectOrRepositry(click.Path): | |
714 | |
715 def __init__(self, **kwds): | |
716 super(ProjectOrRepositry, self).__init__(**kwds) | |
717 | |
718 def convert(self, value, param, ctx): | |
719 if value and value.startswith("git:") or value.startswith("git+"): | |
720 return value | |
721 else: | |
722 return super(ProjectOrRepositry, self).convert(value, param, ctx) | |
723 | |
724 | |
725 def shed_project_arg(multiple=True): | |
726 arg_type = ProjectOrRepositry( | |
727 exists=True, | |
728 file_okay=False, | |
729 dir_okay=True, | |
730 resolve_path=True, | |
731 ) | |
732 name = "paths" if multiple else "path" | |
733 nargs = -1 if multiple else 1 | |
734 return click.argument( | |
735 name, | |
736 metavar="PROJECT", | |
737 type=arg_type, | |
738 nargs=nargs, | |
739 callback=_optional_tools_default, | |
740 ) | |
741 | |
742 | |
743 def recipe_arg(multiple=True): | |
744 name = "paths" if multiple else "path" | |
745 nargs = -1 if multiple else 1 | |
746 return click.argument( | |
747 name, | |
748 metavar="RECIPE_DIR", | |
749 type=click.Path( | |
750 exists=True, | |
751 file_okay=True, | |
752 dir_okay=True, | |
753 resolve_path=True, | |
754 ), | |
755 nargs=nargs, | |
756 callback=_optional_tools_default, | |
757 ) | |
758 | |
759 | |
760 def optional_project_arg(exists=True, default="."): | |
761 arg_type = click.Path( | |
762 exists=exists, | |
763 file_okay=False, | |
764 dir_okay=True, | |
765 writable=True, | |
766 resolve_path=True, | |
767 ) | |
768 return click.argument( | |
769 "path", | |
770 metavar="PROJECT", | |
771 default=default, | |
772 type=arg_type | |
773 ) | |
774 | |
775 | |
776 def no_cleanup_option(): | |
777 return planemo_option( | |
778 "--no_cleanup", | |
779 is_flag=True, | |
780 help=("Do not cleanup temp files created for and by Galaxy.") | |
781 ) | |
782 | |
783 | |
784 def docker_enable_option(): | |
785 return planemo_option( | |
786 "--docker/--no_docker", | |
787 default=False, | |
788 help=("Run Galaxy tools in Docker if enabled.") | |
789 ) | |
790 | |
791 | |
792 def docker_cmd_option(): | |
793 return planemo_option( | |
794 "--docker_cmd", | |
795 default=docker_util.DEFAULT_DOCKER_COMMAND, | |
796 help="Command used to launch docker (defaults to docker)." | |
797 ) | |
798 | |
799 | |
800 def docker_sudo_option(): | |
801 return planemo_option( | |
802 "--docker_sudo/--no_docker_sudo", | |
803 is_flag=True, | |
804 help="Flag to use sudo when running docker." | |
805 ) | |
806 | |
807 | |
808 def docker_sudo_cmd_option(): | |
809 return planemo_option( | |
810 "--docker_sudo_cmd", | |
811 help="sudo command to use when --docker_sudo is enabled " + | |
812 "(defaults to sudo).", | |
813 default=docker_util.DEFAULT_SUDO_COMMAND, | |
814 use_global_config=True, | |
815 ) | |
816 | |
817 | |
818 def docker_host_option(): | |
819 return planemo_option( | |
820 "--docker_host", | |
821 help="Docker host to target when executing docker commands " + | |
822 "(defaults to localhost).", | |
823 use_global_config=True, | |
824 default=docker_util.DEFAULT_HOST, | |
825 ) | |
826 | |
827 | |
828 def docker_config_options(): | |
829 return _compose( | |
830 docker_cmd_option(), | |
831 docker_sudo_option(), | |
832 docker_host_option(), | |
833 docker_sudo_cmd_option(), | |
834 ) | |
835 | |
836 | |
837 def galaxy_docker_options(): | |
838 return _compose( | |
839 docker_enable_option(), | |
840 docker_config_options(), | |
841 ) | |
842 | |
843 | |
844 def shed_owner_option(): | |
845 return planemo_option( | |
846 "--owner", | |
847 help="Tool Shed repository owner (username)." | |
848 ) | |
849 | |
850 | |
851 def shed_name_option(): | |
852 return planemo_option( | |
853 "--name", | |
854 help="Tool Shed repository name (defaults to the inferred " | |
855 "tool directory name)." | |
856 ) | |
857 | |
858 | |
859 def validate_shed_target_callback(ctx, param, value): | |
860 if value is None: | |
861 ctx.fail("default_shed_target set to None, must specify a value for " | |
862 "--shed_target to run this command.") | |
863 return value | |
864 | |
865 | |
866 def shed_target_option(): | |
867 return planemo_option( | |
868 "-t", | |
869 "--shed_target", | |
870 help="Tool Shed to target (this can be 'toolshed', 'testtoolshed', " | |
871 "'local' (alias for http://localhost:9009/), an arbitrary url " | |
872 "or mappings defined ~/.planemo.yml.", | |
873 default=None, | |
874 use_global_config=True, | |
875 callback=validate_shed_target_callback, | |
876 ) | |
877 | |
878 | |
879 def shed_key_option(): | |
880 return planemo_option( | |
881 "--shed_key", | |
882 help=("API key for Tool Shed access. An API key is required unless " | |
883 "e-mail and password is specified. This key can be specified " | |
884 "with either --shed_key or --shed_key_from_env.") | |
885 ) | |
886 | |
887 | |
888 def shed_key_from_env_option(): | |
889 return planemo_option( | |
890 "--shed_key_from_env", | |
891 help="Environment variable to read API key for Tool Shed access from." | |
892 ) | |
893 | |
894 | |
895 def shed_email_option(): | |
896 return planemo_option( | |
897 "--shed_email", | |
898 help="E-mail for Tool Shed auth (required unless shed_key is " | |
899 "specified)." | |
900 ) | |
901 | |
902 | |
903 def shed_password_option(): | |
904 return planemo_option( | |
905 "--shed_password", | |
906 help="Password for Tool Shed auth (required unless shed_key is " | |
907 "specified)." | |
908 ) | |
909 | |
910 | |
911 def shed_skip_upload(): | |
912 return planemo_option( | |
913 "--skip_upload", | |
914 is_flag=True, | |
915 help=("Skip upload contents as part of operation, only update " | |
916 "metadata.") | |
917 ) | |
918 | |
919 | |
920 def shed_skip_metadata(): | |
921 return planemo_option( | |
922 "--skip_metadata", | |
923 is_flag=True, | |
924 help=("Skip metadata update as part of operation, only upload " | |
925 "new contents.") | |
926 ) | |
927 | |
928 | |
929 def shed_message_option(): | |
930 return planemo_option( | |
931 "-m", | |
932 "--message", | |
933 help="Commit message for tool shed upload." | |
934 ) | |
935 | |
936 | |
937 def shed_force_create_option(): | |
938 return planemo_option( | |
939 "--force_repository_creation", | |
940 help=("If a repository cannot be found for the specified user/repo " | |
941 "name pair, then automatically create the repository in the " | |
942 "toolshed."), | |
943 is_flag=True, | |
944 default=False | |
945 ) | |
946 | |
947 | |
948 def shed_check_diff_option(): | |
949 return planemo_option( | |
950 "--check_diff", | |
951 is_flag=True, | |
952 help=("Skip uploading if the shed_diff detects there would be no " | |
953 "'difference' (only attributes populated by the shed would " | |
954 "be updated.)") | |
955 ) | |
956 | |
957 | |
958 def shed_upload_options(): | |
959 return _compose( | |
960 shed_message_option(), | |
961 shed_force_create_option(), | |
962 shed_check_diff_option(), | |
963 ) | |
964 | |
965 | |
966 def shed_realization_options(): | |
967 return _compose( | |
968 shed_project_arg(multiple=True), | |
969 recursive_shed_option(), | |
970 shed_fail_fast_option(), | |
971 ) | |
972 | |
973 | |
974 def shed_repo_options(): | |
975 return _compose( | |
976 shed_owner_option(), | |
977 shed_name_option(), | |
978 ) | |
979 | |
980 | |
981 def shed_publish_options(): | |
982 """ Common options for commands that require publishing to a | |
983 a shed. | |
984 """ | |
985 return _compose( | |
986 shed_realization_options(), | |
987 shed_repo_options(), | |
988 shed_target_options(), | |
989 ) | |
990 | |
991 | |
992 def shed_read_options(): | |
993 """ Common options that require read access to mapped repositories | |
994 in a shed. | |
995 """ | |
996 return _compose( | |
997 shed_realization_options(), | |
998 shed_repo_options(), | |
999 shed_target_options(), | |
1000 ) | |
1001 | |
1002 | |
1003 def shed_target_options(): | |
1004 """ Common options for commands that require read-only | |
1005 interactions with a shed. | |
1006 """ | |
1007 return _compose( | |
1008 shed_email_option(), | |
1009 shed_key_option(), | |
1010 shed_key_from_env_option(), | |
1011 shed_password_option(), | |
1012 shed_target_option(), | |
1013 ) | |
1014 | |
1015 | |
1016 def conda_target_options(include_local=True): | |
1017 return _compose( | |
1018 conda_prefix_option(), | |
1019 conda_exec_option(), | |
1020 conda_debug_option(), | |
1021 conda_ensure_channels_option(), | |
1022 conda_use_local_option(), | |
1023 ) | |
1024 | |
1025 | |
1026 def galaxy_run_options(): | |
1027 return _compose( | |
1028 galaxy_target_options(), | |
1029 galaxy_port_option(), | |
1030 galaxy_host_option(), | |
1031 ) | |
1032 | |
1033 | |
1034 def galaxy_config_options(): | |
1035 return _compose( | |
1036 test_data_option(), | |
1037 tool_data_table_option(), | |
1038 dependency_resolvers_option(), | |
1039 brew_dependency_resolution(), | |
1040 shed_dependency_resolution(), | |
1041 no_dependency_resolution(), | |
1042 conda_target_options(), | |
1043 conda_dependency_resolution(), | |
1044 conda_copy_dependencies_option(), | |
1045 conda_auto_install_option(), | |
1046 conda_auto_init_option(), | |
1047 # Profile options... | |
1048 profile_option(), | |
1049 profile_database_options(), | |
1050 file_path_option(), | |
1051 database_connection_option(), | |
1052 shed_tools_conf_option(), | |
1053 shed_tools_directory_option(), | |
1054 single_user_mode_option(), | |
1055 ) | |
1056 | |
1057 | |
1058 def galaxy_target_options(): | |
1059 return _compose( | |
1060 galaxy_root_option(), | |
1061 galaxy_python_version(), | |
1062 extra_tools_option(), | |
1063 install_galaxy_option(), | |
1064 galaxy_branch_option(), | |
1065 galaxy_source_option(), | |
1066 skip_venv_option(), | |
1067 no_cache_galaxy_option(), | |
1068 no_cleanup_option(), | |
1069 galaxy_email_option(), | |
1070 galaxy_docker_options(), | |
1071 mulled_containers_option(), | |
1072 # Profile options... | |
1073 job_config_option(), | |
1074 tool_dependency_dir_option(), | |
1075 ) | |
1076 | |
1077 | |
1078 def pid_file_option(): | |
1079 pid_file_type = click.Path( | |
1080 file_okay=True, | |
1081 dir_okay=False, | |
1082 resolve_path=True, | |
1083 ) | |
1084 return planemo_option( | |
1085 "--pid_file", | |
1086 type=pid_file_type, | |
1087 default=None, | |
1088 help="Location of pid file is executed with --daemon." | |
1089 ) | |
1090 | |
1091 | |
1092 def daemon_option(): | |
1093 return planemo_option( | |
1094 "--daemon", | |
1095 is_flag=True, | |
1096 help="Serve Galaxy process as a daemon." | |
1097 ) | |
1098 | |
1099 | |
1100 def profile_option(): | |
1101 return planemo_option( | |
1102 "--profile", | |
1103 type=str, | |
1104 default=None, | |
1105 help=("Name of profile (created with the profile_create command) to use " | |
1106 "with this command.") | |
1107 ) | |
1108 | |
1109 | |
1110 def galaxy_serve_options(): | |
1111 return _compose( | |
1112 galaxy_run_options(), | |
1113 serve_engine_option(), | |
1114 non_strict_cwl_option(), | |
1115 docker_galaxy_image_option(), | |
1116 docker_extra_volume_option(), | |
1117 galaxy_config_options(), | |
1118 daemon_option(), | |
1119 pid_file_option(), | |
1120 ignore_dependency_problems_option(), | |
1121 shed_install_option() | |
1122 ) | |
1123 | |
1124 | |
1125 def training_topic_name_option(): | |
1126 return planemo_option( | |
1127 "--topic_name", | |
1128 required=True, | |
1129 help="Name (directory name) of the topic to create or in which " | |
1130 "a tutorial should be created or updates" | |
1131 ) | |
1132 | |
1133 | |
1134 def training_topic_option(): | |
1135 return _compose( | |
1136 training_topic_name_option(), | |
1137 planemo_option( | |
1138 "--topic_title", | |
1139 default="Title of the topic", | |
1140 help="Title of the topic to create"), | |
1141 planemo_option( | |
1142 "--topic_summary", | |
1143 default="Summary of the topic", | |
1144 help="Summary of the topic"), | |
1145 planemo_option( | |
1146 "--topic_target", | |
1147 type=click.Choice(['use', 'admin-dev', 'instructors']), | |
1148 default="use", | |
1149 help="Target audience for the topic") | |
1150 ) | |
1151 | |
1152 | |
1153 def training_tutorial_name_option(): | |
1154 return planemo_option( | |
1155 "--tutorial_name", | |
1156 help="Name (directory name) of the tutorial to create or to modify" | |
1157 ) | |
1158 | |
1159 | |
1160 def training_tutorial_name_req_option(): | |
1161 return planemo_option( | |
1162 "--tutorial_name", | |
1163 required=True, | |
1164 help="Name (directory name) of the tutorial to modify" | |
1165 ) | |
1166 | |
1167 | |
1168 def training_datatype_option(): | |
1169 return planemo_option( | |
1170 "--datatypes", | |
1171 type=click.Path(file_okay=True, resolve_path=True), | |
1172 help="YAML file with the correspondance between Zenodo extension and Galaxy datatypes", | |
1173 default="shared/datatypes.yaml" | |
1174 ) | |
1175 | |
1176 | |
1177 def training_zenodo_option(): | |
1178 return planemo_option( | |
1179 "--zenodo_link", | |
1180 help="Zenodo URL with the input data") | |
1181 | |
1182 | |
1183 def training_tutorial_worflow_option(): | |
1184 return _compose( | |
1185 planemo_option( | |
1186 "--workflow", | |
1187 type=click.Path(file_okay=True, resolve_path=True), | |
1188 help="Workflow of the tutorial (locally)", | |
1189 default=None), | |
1190 planemo_option( | |
1191 "--galaxy_url", | |
1192 help="URL of a Galaxy instance with the workflow"), | |
1193 planemo_option( | |
1194 "--galaxy_api_key", | |
1195 help="API key on the Galaxy instance with the workflow"), | |
1196 planemo_option( | |
1197 "--workflow_id", | |
1198 help="ID of the workflow on the Galaxy instance") | |
1199 ) | |
1200 | |
1201 | |
1202 def training_tutorial_option(): | |
1203 return _compose( | |
1204 training_tutorial_name_option(), | |
1205 planemo_option( | |
1206 "--tutorial_title", | |
1207 default="Title of the tutorial", | |
1208 help="Title of the tutorial"), | |
1209 planemo_option( | |
1210 "--hands_on", | |
1211 is_flag=True, | |
1212 default=True, | |
1213 help="Add hands-on for the new tutorial"), | |
1214 planemo_option( | |
1215 "--slides", | |
1216 is_flag=True, | |
1217 default=False, | |
1218 help="Add slides for the new tutorial"), | |
1219 training_tutorial_worflow_option(), | |
1220 training_zenodo_option() | |
1221 ) | |
1222 | |
1223 | |
1224 def training_init_options(): | |
1225 return _compose( | |
1226 training_topic_option(), | |
1227 training_tutorial_option(), | |
1228 training_datatype_option() | |
1229 ) | |
1230 | |
1231 | |
1232 def training_fill_data_library_options(): | |
1233 return _compose( | |
1234 training_topic_name_option(), | |
1235 training_tutorial_name_req_option(), | |
1236 training_zenodo_option(), | |
1237 training_datatype_option() | |
1238 ) | |
1239 | |
1240 | |
1241 def training_generate_tuto_from_wf_options(): | |
1242 return _compose( | |
1243 training_topic_name_option(), | |
1244 training_tutorial_name_req_option(), | |
1245 training_tutorial_worflow_option() | |
1246 ) | |
1247 | |
1248 | |
1249 def shed_fail_fast_option(): | |
1250 return planemo_option( | |
1251 "--fail_fast", | |
1252 is_flag=True, | |
1253 default=False, | |
1254 help="If multiple repositories are specified and an error occurs " | |
1255 "stop immediately instead of processing remaining repositories." | |
1256 ) | |
1257 | |
1258 | |
1259 def lint_xsd_option(): | |
1260 return planemo_option( | |
1261 "--xsd/--no_xsd", | |
1262 is_flag=True, | |
1263 default=True, | |
1264 help=("Include tool XSD validation in linting process.") | |
1265 ) | |
1266 | |
1267 | |
1268 def report_level_option(): | |
1269 return planemo_option( | |
1270 "--report_level", | |
1271 type=click.Choice(["all", "warn", "error"]), | |
1272 default="all", | |
1273 ) | |
1274 | |
1275 | |
1276 def report_xunit(): | |
1277 return planemo_option( | |
1278 "--report_xunit", | |
1279 type=click.Path(file_okay=True, resolve_path=True), | |
1280 help="Output an XUnit report, useful for CI testing", | |
1281 default=None, | |
1282 ) | |
1283 | |
1284 | |
1285 def skip_option(): | |
1286 return planemo_option( | |
1287 "-s", | |
1288 "--skip", | |
1289 default=None, | |
1290 help=("Comma-separated list of lint tests to skip (e.g. passing " | |
1291 "--skip 'citations,xml_order' would skip linting of citations " | |
1292 "and best-practice XML ordering.") | |
1293 ) | |
1294 | |
1295 | |
1296 def fail_level_option(): | |
1297 return planemo_option( | |
1298 "--fail_level", | |
1299 type=click.Choice(['warn', 'error']), | |
1300 default="warn" | |
1301 ) | |
1302 | |
1303 | |
1304 def recursive_shed_option(): | |
1305 return recursive_option( | |
1306 "Recursively perform command for nested repository directories.", | |
1307 ) | |
1308 | |
1309 | |
1310 def recursive_option(help="Recursively perform command for subdirectories."): | |
1311 return planemo_option( | |
1312 "-r", | |
1313 "--recursive", | |
1314 is_flag=True, | |
1315 help=help, | |
1316 ) | |
1317 | |
1318 | |
1319 def merge_test_json(): | |
1320 target_path = click.Path( | |
1321 file_okay=True, | |
1322 dir_okay=False, | |
1323 resolve_path=True, | |
1324 ) | |
1325 return click.argument( | |
1326 'input_paths', | |
1327 metavar="INPUT_PATHS", | |
1328 type=target_path, | |
1329 nargs=-1, | |
1330 ) | |
1331 | |
1332 | |
1333 def tool_test_json(var="path"): | |
1334 target_path = click.Path( | |
1335 file_okay=True, | |
1336 dir_okay=False, | |
1337 resolve_path=True, | |
1338 ) | |
1339 return click.argument( | |
1340 var, | |
1341 metavar="FILE_PATH", | |
1342 type=target_path, | |
1343 default="tool_test_output.json", | |
1344 ) | |
1345 | |
1346 | |
1347 def engine_options(): | |
1348 return _compose( | |
1349 run_engine_option(), | |
1350 non_strict_cwl_option(), | |
1351 cwltool_no_container_option(), | |
1352 docker_galaxy_image_option(), | |
1353 docker_extra_volume_option(), | |
1354 ignore_dependency_problems_option(), | |
1355 shed_install_option(), | |
1356 galaxy_url_option(), | |
1357 galaxy_admin_key_option(), | |
1358 galaxy_user_key_option(), | |
1359 ) | |
1360 | |
1361 | |
1362 def test_report_options(): | |
1363 return _compose( | |
1364 planemo_option( | |
1365 "--test_output", | |
1366 type=click.Path(file_okay=True, resolve_path=True), | |
1367 use_global_config=True, | |
1368 default="tool_test_output.html", | |
1369 help=("Output test report (HTML - for humans) defaults to " | |
1370 "tool_test_output.html."), | |
1371 ), | |
1372 planemo_option( | |
1373 "--test_output_text", | |
1374 type=click.Path(file_okay=True, resolve_path=True), | |
1375 use_global_config=True, | |
1376 help=("Output test report (Basic text - for display in CI)"), | |
1377 default=None, | |
1378 ), | |
1379 planemo_option( | |
1380 "--test_output_markdown", | |
1381 type=click.Path(file_okay=True, resolve_path=True), | |
1382 use_global_config=True, | |
1383 help=("Output test report (Markdown style - for humans & " | |
1384 "computers)"), | |
1385 default=None, | |
1386 ), | |
1387 planemo_option( | |
1388 "--test_output_xunit", | |
1389 type=click.Path(file_okay=True, resolve_path=True), | |
1390 use_global_config=True, | |
1391 help=("Output test report (xunit style - for CI systems"), | |
1392 default=None, | |
1393 ), | |
1394 planemo_option( | |
1395 "--test_output_junit", | |
1396 type=click.Path(file_okay=True, resolve_path=True), | |
1397 use_global_config=True, | |
1398 help=("Output test report (jUnit style - for CI systems"), | |
1399 default=None, | |
1400 ), | |
1401 ) | |
1402 | |
1403 | |
1404 def profile_name_argument(): | |
1405 return click.argument( | |
1406 'profile_name', | |
1407 metavar="PROFILE_NAME", | |
1408 type=str, | |
1409 ) | |
1410 | |
1411 | |
1412 def database_identifier_argument(): | |
1413 return click.argument( | |
1414 'identifier', | |
1415 metavar="IDENTIFIER", | |
1416 type=str, | |
1417 ) | |
1418 | |
1419 | |
1420 def postgres_datatype_type_option(): | |
1421 return planemo_option( | |
1422 "--postgres", | |
1423 "database_type", | |
1424 flag_value="postgres", | |
1425 help=("Use postgres database type."), | |
1426 ) | |
1427 | |
1428 | |
1429 def database_type_option(): | |
1430 return planemo_option( | |
1431 "--database_type", | |
1432 default="auto", | |
1433 type=click.Choice([ | |
1434 "postgres", | |
1435 "postgres_docker", | |
1436 "sqlite", | |
1437 "auto", | |
1438 ]), | |
1439 use_global_config=True, | |
1440 help=("Type of database to use for profile - " | |
1441 "'auto', 'sqlite', 'postgres', and 'postgres_docker' are available options. " | |
1442 "Use postgres to use an existing postgres server you user can " | |
1443 "access without a password via the psql command. Use postgres_docker " | |
1444 "to have Planemo manage a docker container running postgres. " | |
1445 "Data with postgres_docker is not yet persisted past when you restart " | |
1446 "the docker container launched by Planemo so be careful with this option."), | |
1447 ) | |
1448 | |
1449 | |
1450 def database_source_options(): | |
1451 """Database connection options for commands that utilize a database.""" | |
1452 return _compose( | |
1453 planemo_option( | |
1454 "--postgres_psql_path", | |
1455 default="psql", | |
1456 use_global_config=True, | |
1457 help=("Name or or path to postgres client binary (psql)."), | |
1458 ), | |
1459 planemo_option( | |
1460 "--postgres_database_user", | |
1461 default="postgres", | |
1462 use_global_config=True, | |
1463 help=("Postgres username for managed development databases."), | |
1464 ), | |
1465 planemo_option( | |
1466 "--postgres_database_host", | |
1467 default=None, | |
1468 use_global_config=True, | |
1469 help=("Postgres host name for managed development databases."), | |
1470 ), | |
1471 planemo_option( | |
1472 "--postgres_database_port", | |
1473 default=None, | |
1474 use_global_config=True, | |
1475 help=("Postgres port for managed development databases."), | |
1476 ), | |
1477 ) | |
1478 | |
1479 | |
1480 def profile_database_options(): | |
1481 return _compose( | |
1482 postgres_datatype_type_option(), | |
1483 database_type_option(), | |
1484 database_source_options(), | |
1485 ) | |
1486 | |
1487 | |
1488 def test_options(): | |
1489 return _compose( | |
1490 planemo_option( | |
1491 "--update_test_data", | |
1492 is_flag=True, | |
1493 help="Update test-data directory with job outputs (normally" | |
1494 " written to directory --job_output_files if specified.)" | |
1495 ), | |
1496 paste_test_data_paths_option(), | |
1497 test_report_options(), | |
1498 planemo_option( | |
1499 "--test_output_json", | |
1500 type=click.Path(file_okay=True, resolve_path=True), | |
1501 use_global_config=True, | |
1502 help=("Output test report (planemo json) defaults to " | |
1503 "tool_test_output.json."), | |
1504 default="tool_test_output.json", | |
1505 ), | |
1506 planemo_option( | |
1507 "--job_output_files", | |
1508 type=click.Path(file_okay=False, resolve_path=True), | |
1509 help="Write job outputs to specified directory.", | |
1510 default=None, | |
1511 ), | |
1512 planemo_option( | |
1513 "--summary", | |
1514 type=click.Choice(["none", "minimal", "compact"]), | |
1515 default="minimal", | |
1516 help=("Summary style printed to planemo's standard output (see " | |
1517 "output reports for more complete summary). Set to 'none' " | |
1518 "to disable completely.") | |
1519 ) | |
1520 ) | |
1521 | |
1522 | |
1523 def _compose(*functions): | |
1524 def compose2(f, g): | |
1525 return lambda x: f(g(x)) | |
1526 return functools.reduce(compose2, functions) | |
1527 | |
1528 | |
1529 def dependencies_script_options(): | |
1530 return _compose( | |
1531 planemo_option( | |
1532 "--download_cache", | |
1533 type=click.Path(file_okay=False, resolve_path=True), | |
1534 use_global_config=True, | |
1535 help=("Directory to cache downloaded files, default is $DOWNLOAD_CACHE"), | |
1536 default=None, | |
1537 ), | |
1538 ) | |
1539 | |
1540 | |
1541 def filter_exclude_option(): | |
1542 return planemo_option( | |
1543 "--exclude", | |
1544 type=click.Path(resolve_path=False), | |
1545 multiple=True, | |
1546 help="Paths to exclude.", | |
1547 ) | |
1548 | |
1549 | |
1550 def filter_exclude_from_option(): | |
1551 return planemo_option( | |
1552 "--exclude_from", | |
1553 type=click.Path(exists=True, file_okay=True, dir_okay=False, resolve_path=True), | |
1554 multiple=True, | |
1555 help="File of paths to exclude.", | |
1556 ) | |
1557 | |
1558 | |
1559 def filter_changed_in_commit_option(): | |
1560 return planemo_option( | |
1561 "--changed_in_commit_range", | |
1562 help="Exclude paths unchanged in git commit range.", | |
1563 ) | |
1564 | |
1565 | |
1566 def ci_chunk_count_option(): | |
1567 return planemo_option( | |
1568 "--chunk_count", | |
1569 type=int, | |
1570 help="Split output into chunks of this many item and print --chunk such group.", | |
1571 default=1, | |
1572 ) | |
1573 | |
1574 | |
1575 def ci_chunk_option(): | |
1576 return planemo_option( | |
1577 "--chunk", | |
1578 type=int, | |
1579 help=("When output is split into --chunk_count groups, output the group 0-indexed" | |
1580 "by this option."), | |
1581 default=0, | |
1582 ) | |
1583 | |
1584 | |
1585 def ci_output_option(): | |
1586 return planemo_option( | |
1587 "--output", | |
1588 help="File to output to, or - for standard output.", | |
1589 default="-", | |
1590 ) | |
1591 | |
1592 | |
1593 def ci_find_options(): | |
1594 return _compose( | |
1595 filter_exclude_option(), | |
1596 filter_exclude_from_option(), | |
1597 filter_changed_in_commit_option(), | |
1598 ci_chunk_count_option(), | |
1599 ci_chunk_option(), | |
1600 ci_output_option(), | |
1601 ) | |
1602 | |
1603 | |
1604 def tool_init_id_option(prompt=True): | |
1605 return planemo_option( | |
1606 "-i", | |
1607 "--id", | |
1608 type=click.STRING, | |
1609 prompt=prompt, | |
1610 help="Short identifier for new tool (no whitespace)", | |
1611 ) | |
1612 | |
1613 | |
1614 def tool_init_tool_option(): | |
1615 return planemo_option( | |
1616 "-t", | |
1617 "--tool", | |
1618 default=None, | |
1619 type=click.Path(exists=False, | |
1620 file_okay=True, | |
1621 dir_okay=False, | |
1622 writable=True, | |
1623 resolve_path=True), | |
1624 help="Output path for new tool (default is <id>.xml)", | |
1625 ) | |
1626 | |
1627 | |
1628 def tool_init_name_option(prompt=True, help="Name for new tool (user facing)"): | |
1629 return planemo_option( | |
1630 "-n", | |
1631 "--name", | |
1632 type=click.STRING, | |
1633 prompt=prompt, | |
1634 help=help, | |
1635 ) | |
1636 | |
1637 | |
1638 def tool_init_version_option(): | |
1639 return planemo_option( | |
1640 "--version", | |
1641 default="0.1.0", | |
1642 type=click.STRING, | |
1643 help="Tool XML version.", | |
1644 ) | |
1645 | |
1646 | |
1647 def tool_init_description_option(): | |
1648 return planemo_option( | |
1649 "-d", | |
1650 "--description", | |
1651 type=click.STRING, | |
1652 default=None, | |
1653 prompt=False, | |
1654 help="Short description for new tool (user facing)", | |
1655 ) | |
1656 | |
1657 | |
1658 def tool_init_command_option(): | |
1659 return planemo_option( | |
1660 "-c", | |
1661 "--command", | |
1662 type=click.STRING, | |
1663 default=None, | |
1664 prompt=False, | |
1665 help=("Command potentially including cheetah variables ()" | |
1666 "(e.g. 'seqtk seq -a $input > $output')"), | |
1667 ) | |
1668 | |
1669 | |
1670 def tool_init_doi_option(): | |
1671 return planemo_option( | |
1672 "--doi", | |
1673 type=click.STRING, | |
1674 default=None, | |
1675 multiple=True, | |
1676 prompt=False, | |
1677 help=("Supply a DOI (http://www.doi.org/) easing citation of the tool " | |
1678 "for Galxy users (e.g. 10.1101/014043).") | |
1679 ) | |
1680 | |
1681 | |
1682 def tool_init_test_case_option(): | |
1683 return planemo_option( | |
1684 "--test_case", | |
1685 is_flag=True, | |
1686 default=None, | |
1687 prompt=False, | |
1688 help=("For use with --example_commmand, generate a tool test case from " | |
1689 "the supplied example."), | |
1690 ) | |
1691 | |
1692 | |
1693 def tool_init_macros_option(): | |
1694 return planemo_option( | |
1695 "--macros", | |
1696 is_flag=True, | |
1697 default=None, | |
1698 prompt=False, | |
1699 help="Generate a macros.xml for reuse across many tools.", | |
1700 ) | |
1701 | |
1702 | |
1703 def tool_init_cite_url_option(): | |
1704 return planemo_option( | |
1705 "--cite_url", | |
1706 type=click.STRING, | |
1707 default=None, | |
1708 multiple=True, | |
1709 prompt=False, | |
1710 help=("Supply a URL for citation.") | |
1711 ) | |
1712 | |
1713 | |
1714 def tool_init_input_option(): | |
1715 return planemo_option( | |
1716 "--input", | |
1717 type=click.STRING, | |
1718 default=None, | |
1719 prompt=False, | |
1720 multiple=True, | |
1721 help="An input description (e.g. input.fasta)", | |
1722 ) | |
1723 | |
1724 | |
1725 def tool_init_output_option(): | |
1726 return planemo_option( | |
1727 "--output", | |
1728 type=click.STRING, | |
1729 multiple=True, | |
1730 default=None, | |
1731 prompt=False, | |
1732 help=("An output location (e.g. output.bam), the Galaxy datatype is " | |
1733 "inferred from the extension."), | |
1734 ) | |
1735 | |
1736 | |
1737 def tool_init_help_text_option(): | |
1738 return planemo_option( | |
1739 "--help_text", | |
1740 type=click.STRING, | |
1741 default=None, | |
1742 prompt=False, | |
1743 help="Help text (reStructuredText)", | |
1744 ) | |
1745 | |
1746 | |
1747 def tool_init_help_from_command_option(): | |
1748 return planemo_option( | |
1749 "--help_from_command", | |
1750 type=click.STRING, | |
1751 default=None, | |
1752 prompt=False, | |
1753 help="Auto populate help from supplied command.", | |
1754 ) | |
1755 | |
1756 | |
1757 def tool_init_example_input_option(): | |
1758 return planemo_option( | |
1759 "--example_input", | |
1760 type=click.STRING, | |
1761 default=None, | |
1762 prompt=False, | |
1763 multiple=True, | |
1764 help=("For use with --example_command, replace input file (e.g. 2.fastq " | |
1765 "with a data input parameter)."), | |
1766 ) | |
1767 | |
1768 | |
1769 def tool_init_example_output_option(): | |
1770 return planemo_option( | |
1771 "--example_output", | |
1772 type=click.STRING, | |
1773 default=None, | |
1774 prompt=False, | |
1775 multiple=True, | |
1776 help=("For use with --example_command, replace input file (e.g. 2.fastq " | |
1777 "with a tool output)."), | |
1778 ) | |
1779 | |
1780 | |
1781 def tool_init_named_output_option(): | |
1782 return planemo_option( | |
1783 "--named_output", | |
1784 type=click.STRING, | |
1785 multiple=True, | |
1786 default=None, | |
1787 prompt=False, | |
1788 help=("Create a named output for use with command block for example " | |
1789 "specify --named_output=output1.bam and then use '-o $output1' " | |
1790 "in your command block."), | |
1791 ) | |
1792 | |
1793 | |
1794 def tool_init_version_command_option(): | |
1795 return planemo_option( | |
1796 "--version_command", | |
1797 type=click.STRING, | |
1798 default=None, | |
1799 prompt=False, | |
1800 help="Command to print version (e.g. 'seqtk --version')", | |
1801 ) | |
1802 | |
1803 | |
1804 REQUIREMENT_HELP = "Add a tool requirement package (e.g. 'seqtk' or 'seqtk@1.68')." | |
1805 | |
1806 | |
1807 def tool_init_requirement_option(help=REQUIREMENT_HELP): | |
1808 return planemo_option( | |
1809 "--requirement", | |
1810 type=click.STRING, | |
1811 default=None, | |
1812 multiple=True, | |
1813 prompt=False, | |
1814 help=help, | |
1815 ) | |
1816 | |
1817 | |
1818 def tool_init_container_option(): | |
1819 return planemo_option( | |
1820 "--container", | |
1821 type=click.STRING, | |
1822 default=None, | |
1823 multiple=True, | |
1824 prompt=False, | |
1825 help="Add a Docker image identifier for this tool." | |
1826 ) | |
1827 | |
1828 | |
1829 EXAMPLE_COMMAND_HELP = ( | |
1830 "Example to command with paths to build Cheetah template from " | |
1831 "(e.g. 'seqtk seq -a 2.fastq > 2.fasta'). Option cannot be used " | |
1832 "with --command, should be used --example_input and " | |
1833 "--example_output." | |
1834 ) | |
1835 | |
1836 | |
1837 def tool_init_example_command_option(help=EXAMPLE_COMMAND_HELP): | |
1838 return planemo_option( | |
1839 "--example_command", | |
1840 type=click.STRING, | |
1841 default=None, | |
1842 prompt=False, | |
1843 help=help, | |
1844 ) | |
1845 | |
1846 | |
1847 def mulled_conda_option(): | |
1848 return planemo_option( | |
1849 "--mulled_conda_version", | |
1850 type=click.STRING, | |
1851 default=None, | |
1852 help=("Install a specific version of Conda before running the command, by " | |
1853 "default the version that comes with the continuumio miniconda3 image " | |
1854 "will be used under Linux and under Mac OS X Conda will be upgraded to " | |
1855 "to work around a bug in 4.2.") | |
1856 ) | |
1857 | |
1858 | |
1859 def mulled_namespace_option(): | |
1860 return planemo_option( | |
1861 "--mulled_namespace", | |
1862 type=click.STRING, | |
1863 default="biocontainers", | |
1864 help=("Build a mulled image with the specified namespace - defaults to " | |
1865 "biocontainers. Galaxy currently only recognizes images with the " | |
1866 "namespace biocontainers.") | |
1867 ) | |
1868 | |
1869 | |
1870 def mulled_action_option(): | |
1871 return planemo_option( | |
1872 "--mulled_command", | |
1873 type=click.STRING, | |
1874 default="build-and-test", | |
1875 help=("Mulled action to perform for targets - this defaults to 'build-and-test'.") | |
1876 ) | |
1877 | |
1878 | |
1879 def mulled_options(): | |
1880 return _compose( | |
1881 mulled_conda_option(), | |
1882 mulled_namespace_option(), | |
1883 mulled_action_option(), | |
1884 ) |