Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer dashes instead of underscores in flags
Browse files Browse the repository at this point in the history
natefoo committed Dec 14, 2022

Partially verified

This commit is signed with the committer’s verified signature.
gsmet’s contribution has been verified via GPG key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent f4ece80 commit a8ca741
Showing 11 changed files with 74 additions and 30 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -36,7 +36,9 @@ def get_var(var_name):
workflow-to-tools=ephemeris.generate_tool_list_from_ga_workflow_files:main
setup-data-libraries=ephemeris.setup_data_libraries:main
galaxy-wait=ephemeris.sleep:main
install-tool-deps=ephemeris.install_tool_deps:main
install_tool_deps=ephemeris.install_tool_deps:main
set-library-permissions=ephemeris.set_library_permissions:main
set_library_permissions=ephemeris.set_library_permissions:main
'''
PACKAGE_DATA = {
19 changes: 17 additions & 2 deletions src/ephemeris/common_parser.py
Original file line number Diff line number Diff line change
@@ -3,13 +3,28 @@
import argparse


class HideUnderscoresHelpFormatter(argparse.HelpFormatter):
def add_arguments(self, actions):
for action in actions:
action.option_strings = list(s for s in action.option_strings if "_" not in s)
self.add_argument(action)


class RawDescriptionHideUnderscoresHelpFormatter(HideUnderscoresHelpFormatter, argparse.RawDescriptionHelpFormatter):
pass


class ArgumentDefaultsHideUnderscoresHelpFormatter(HideUnderscoresHelpFormatter, argparse.ArgumentDefaultsHelpFormatter):
pass


def get_common_args(login_required=True, log_file=False):

parser = argparse.ArgumentParser(add_help=False)
general_group = parser.add_argument_group('General options')
general_group.add_argument("-v", "--verbose", help="Increase output verbosity.", action="store_true")
if log_file:
general_group.add_argument("--log_file",
general_group.add_argument("--log-file", "--log_file",
dest="log_file",
help="Where the log file should be stored. "
"Default is a file in your system's temp folder",
@@ -25,7 +40,7 @@ def get_common_args(login_required=True, log_file=False):
help="Galaxy user email address")
con_group.add_argument("-p", "--password",
help="Password for the Galaxy user")
con_group.add_argument("-a", "--api_key",
con_group.add_argument("-a", "--api-key", "--api_key",
dest="api_key",
help="Galaxy admin user API key (required if not defined in the tools list file)")

7 changes: 4 additions & 3 deletions src/ephemeris/generate_tool_list_from_ga_workflow_files.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
'''Tool to generate tools from workflows'''
import json
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from argparse import ArgumentParser

import yaml

from .common_parser import RawDescriptionHideUnderscoresHelpFormatter
from .shed_tools_methods import format_tool_shed_url

INSTALL_TOOL_DEPENDENCIES = 'install_tool_dependencies: True'
@@ -21,7 +22,7 @@ def _parse_cli_options():


def _parser():
parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
parser = ArgumentParser(formatter_class=RawDescriptionHideUnderscoresHelpFormatter,
usage="%(prog)s <options>",
epilog="Workflow files must have been exported from Galaxy release 16.04 or newer.\n\n"
"example:\n"
@@ -37,7 +38,7 @@ def _parser():
required=True,
dest='output_file',
help='The output file with a yml tool list')
parser.add_argument('-l', '--panel_label',
parser.add_argument('-l', '--panel-label', '--panel_label',
dest='panel_label',
default='Tools from workflows',
help='The name of the panel where the tools will show up in Galaxy.'
15 changes: 7 additions & 8 deletions src/ephemeris/get_tool_list_from_galaxy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
"""Tool to extract a tool list from galaxy."""

from argparse import ArgumentDefaultsHelpFormatter
from argparse import ArgumentParser
from distutils.version import StrictVersion

@@ -10,7 +9,7 @@
from bioblend.galaxy.toolshed import ToolShedClient

from . import get_galaxy_connection
from .common_parser import get_common_args
from .common_parser import ArgumentDefaultsHideUnderscoresHelpFormatter, get_common_args
from .shed_tools_methods import format_tool_shed_url


@@ -216,29 +215,29 @@ def _parser():
"""Creates the parser object."""
parent = get_common_args(login_required=True)
parser = ArgumentParser(parents=[parent],
formatter_class=ArgumentDefaultsHelpFormatter)
formatter_class=ArgumentDefaultsHideUnderscoresHelpFormatter)
parser.add_argument("-o", "--output-file",
required=True,
dest="output",
help="tool_list.yml output file")
parser.add_argument("--include_tool_panel_id",
parser.add_argument("--include-tool-panel-id", "--include_tool_panel_id",
action="store_true",
help="Include tool_panel_id in tool_list.yml ? "
"Use this only if the tool panel id already exists. See "
"https://github.com/galaxyproject/ansible-galaxy-tools/blob/master/files/tool_list.yaml.sample")
parser.add_argument("--skip_tool_panel_name",
parser.add_argument("--skip-tool-panel-name", "--skip_tool_panel_name",
action="store_true",
help="Do not include tool_panel_name in tool_list.yml ?")
parser.add_argument("--skip_changeset_revision",
parser.add_argument("--skip-changeset-revision", "--skip_changeset_revision",
action="store_true",
help="Do not include the changeset revision when generating the tool list."
"Use this if you would like to use the list to update all the tools in"
"your galaxy instance using shed-install."
)
parser.add_argument("--get_data_managers",
parser.add_argument("--get-data-managers", "--get_data_managers",
action="store_true",
help="Include the data managers in the tool list. Requires admin login details")
parser.add_argument("--get_all_tools",
parser.add_argument("--get-all-tools", "--get_all_tools",
action="store_true",
help="Get all tools and revisions, not just those which are present on the web ui."
"Requires login details.")
4 changes: 2 additions & 2 deletions src/ephemeris/install_tool_deps.py
Original file line number Diff line number Diff line change
@@ -10,14 +10,14 @@
from bioblend.galaxy.tools import ToolClient

from ephemeris import get_galaxy_connection
from ephemeris.common_parser import get_common_args
from ephemeris.common_parser import get_common_args, HideUnderscoresHelpFormatter

timeout_codes = (408, 502, 504)


def _parser():
parent = get_common_args()
parser = argparse.ArgumentParser(parents=[parent])
parser = argparse.ArgumentParser(parents=[parent], formatter_class=HideUnderscoresHelpFormatter)
parser.add_argument("-t", "--tool", help='Path to a tool file, tool_conf file, or yaml file containing a sequence of tool ids', nargs='*')
parser.add_argument("-i", "--id", help='Space-separated list of tool ids', nargs='*')

5 changes: 3 additions & 2 deletions src/ephemeris/run_data_managers.py
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@

from . import get_galaxy_connection
from . import load_yaml_file
from .common_parser import get_common_args
from .common_parser import get_common_args, HideUnderscoresHelpFormatter
from .ephemeris_log import disable_external_library_logging, setup_global_logger

DEFAULT_URL = "http://localhost"
@@ -288,13 +288,14 @@ def _parser():

parser = argparse.ArgumentParser(
parents=[parent],
formatter_class=HideUnderscoresHelpFormatter,
description='Running Galaxy data managers in a defined order with defined parameters.'
"'watch_tool_data_dir' in galaxy config should be set to true.'")
parser.add_argument("--config", required=True,
help="Path to the YAML config file with the list of data managers and data to install.")
parser.add_argument("--overwrite", action="store_true",
help="Disables checking whether the item already exists in the tool data table.")
parser.add_argument("--ignore_errors", action="store_true",
parser.add_argument("--ignore-errors", "--ignore_errors", action="store_true",
help="Do not stop running when jobs have failed.")
return parser

6 changes: 4 additions & 2 deletions src/ephemeris/set_library_permissions.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
from bioblend import galaxy
from rich.progress import Progress

from .common_parser import get_common_args
from .common_parser import get_common_args, HideUnderscoresHelpFormatter

# Print iterations progress

@@ -74,7 +74,9 @@ def _parser():
"""Constructs the parser object"""
parent = get_common_args()
parser = argparse.ArgumentParser(
parents=[parent], description="Populate the Galaxy data library with data."
parents=[parent],
formatter_class=HideUnderscoresHelpFormatter,
description="Populate the Galaxy data library with data."
)
parser.add_argument("library", help="Specify the data library ID")
parser.add_argument("--roles", nargs="+", help="Specify a list of comma separated role IDs")
3 changes: 2 additions & 1 deletion src/ephemeris/setup_data_libraries.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import yaml
from bioblend import galaxy

from .common_parser import get_common_args
from .common_parser import get_common_args, HideUnderscoresHelpFormatter


def create_legacy(gi, desc):
@@ -189,6 +189,7 @@ def _parser():
parent = get_common_args()
parser = argparse.ArgumentParser(
parents=[parent],
formatter_class=HideUnderscoresHelpFormatter,
description='Populate the Galaxy data library with data.'
)
parser.add_argument('-i', '--infile', required=True, type=argparse.FileType('r'))
Loading

0 comments on commit a8ca741

Please sign in to comment.