How to use the configargparse.ArgumentParser function in ConfigArgParse

To help you get started, we’ve selected a few ConfigArgParse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla-services / autopush-loadtester / aplt / runner.py View on Github external
def parse_scenario_args(args):
    parser = ArgumentParser(
        description="Run a scenario",
        default_config_files=["config.ini"],
        args_for_setting_config_path=["-c", "--config"],
    )
    parse_common_args(parser)
    parser.add_argument("scenario")
    parser.add_argument("scenario_args", nargs="*",
                        help="Arguments for the specific scenario")
    return parser.parse_args(args)
github curzon01 / mqtt2sql / mqtt2sql.py View on Github external
def parseargs():
    """
    Program argument parser

    @return:
        configargparse.parse_args() result
    """
    # pylint: disable=global-statement
    global VER
    global DEFAULTS
    global MODULE_SSL_AVAIL
    global MODULE_MYSQLDB_AVAIL
    global MODULE_SQLITE3_AVAIL
    # pylint: enable=global-statement

    parser = configargparse.ArgumentParser(\
            description='MQTT to MySQL bridge. Subscribes to MQTT broker topic(s) and write values into a database.',
            epilog="There are no required arguments, defaults are displayed using --help."
            )
    parser.add_argument(
        '-c', '--configfile',
        metavar="",
        dest='configfile',
        is_config_file=True,
        default=DEFAULTS['configfile'],
        help="Config file, can be used instead of command parameter (default {})".format(DEFAULTS['configfile'])
    )

    mqtt_group = parser.add_argument_group('MQTT Options')
    mqtt_group.add_argument(
        '--mqtt-host',
        metavar='',
github OpenNMT / OpenNMT-py / onmt / bin / server.py View on Github external
def _get_parser():
    parser = configargparse.ArgumentParser(
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        description="OpenNMT-py REST Server")
    parser.add_argument("--ip", type=str, default="0.0.0.0")
    parser.add_argument("--port", type=int, default="5000")
    parser.add_argument("--url_root", type=str, default="/translator")
    parser.add_argument("--debug", "-d", action="store_true")
    parser.add_argument("--config", "-c", type=str,
                        default="./available_models/conf.json")
    return parser
github DreamingRaven / nemesyst / nemesyst.py View on Github external
def argument_parser(description=None, cfg_files=None):
    """Parse cli>environment>config>default arguments into dictionary."""
    home = os.path.expanduser("~")
    parser = configargparse.ArgumentParser(prog=None,
                                           description=description,
                                           add_help=False,
                                           default_config_files=cfg_files)
    nemesyst = parser.add_argument_group(title="Nemesyst options")
    data = parser.add_argument_group(title="Data pre-processing options")
    deeplearning = parser.add_argument_group(title="Deep learning options")
    mongodb = parser.add_argument_group(title="MongoDb options")

    # Nemesyst specific options
    nemesyst.add_argument("-h", "--help",
                          action="help",
                          help="Print help.")
    nemesyst.add_argument("-U", "--update",
                          default=bool(False),
                          action="store_true",
                          help="Nemesyst update, and restart.")
github mozilla-services / autopush / autopush / main_argparse.py View on Github external
def parse_endpoint(config_files, args):
    """Parses out endpoint arguments for an autoendpoint node"""
    parser = configargparse.ArgumentParser(
        description='Runs an Endpoint Node.',
        default_config_files=config_files,
        )
    parser.add_argument('--config-endpoint',
                        help="Endpoint node configuration file path",
                        dest='config_file', is_config_file=True)
    parser.add_argument('-p', '--port', help='Public HTTP Endpoint Port',
                        type=int, default=8082, env_var="PORT")
    parser.add_argument('--no_cors', help='Disallow CORS PUTs for update.',
                        action="store_true",
                        default=False, env_var='ALLOW_CORS')
    parser.add_argument('--auth_key', help='Bearer Token source key',
                        type=str, default=[], env_var='AUTH_KEY',
                        action="append")
    parser.add_argument('--client_certs',
                        help="Allowed TLS client certificates",
github espnet / espnet / espnet / bin / mt_recog.py View on Github external
def get_parser():
    parser = configargparse.ArgumentParser(
        description='Transcribe text from speech using a speech recognition model on one CPU or GPU',
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        formatter_class=configargparse.ArgumentDefaultsHelpFormatter)
    # general configuration
    parser.add('--config', is_config_file=True,
               help='Config file path')
    parser.add('--config2', is_config_file=True,
               help='Second config file path that overwrites the settings in `--config`')
    parser.add('--config3', is_config_file=True,
               help='Third config file path that overwrites the settings in `--config` and `--config2`')

    parser.add_argument('--ngpu', type=int, default=0,
                        help='Number of GPUs')
    parser.add_argument('--backend', type=str, default='chainer',
                        choices=['chainer', 'pytorch'],
                        help='Backend library')
github espnet / espnet / espnet / bin / tts_train.py View on Github external
def get_parser():
    """Get parser of training arguments."""
    parser = configargparse.ArgumentParser(
        description='Train a new text-to-speech (TTS) model on one CPU, one or multiple GPUs',
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        formatter_class=configargparse.ArgumentDefaultsHelpFormatter)

    # general configuration
    parser.add('--config', is_config_file=True,
               help='config file path')
    parser.add('--config2', is_config_file=True,
               help='second config file path that overwrites the settings in `--config`.')
    parser.add('--config3', is_config_file=True,
               help='third config file path that overwrites the settings in `--config` and `--config2`.')

    parser.add_argument('--ngpu', default=None, type=int,
                        help='Number of GPUs. If not given, use all visible devices')
    parser.add_argument('--backend', default='pytorch', type=str,
                        choices=['chainer', 'pytorch'],
github espnet / espnet / espnet / bin / tts_decode.py View on Github external
def get_parser():
    """Get parser of decoding arguments."""
    parser = configargparse.ArgumentParser(
        description='Synthesize speech from text using a TTS model on one CPU',
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        formatter_class=configargparse.ArgumentDefaultsHelpFormatter)
    # general configuration
    parser.add('--config', is_config_file=True, help='config file path')
    parser.add('--config2', is_config_file=True,
               help='second config file path that overwrites the settings in `--config`.')
    parser.add('--config3', is_config_file=True,
               help='third config file path that overwrites the settings in `--config` and `--config2`.')

    parser.add_argument('--ngpu', default=0, type=int,
                        help='Number of GPUs')
    parser.add_argument('--backend', default='pytorch', type=str,
                        choices=['chainer', 'pytorch'],
                        help='Backend library')
    parser.add_argument('--debugmode', default=1, type=int,
github espnet / espnet / doc / argparse2rst.py View on Github external
def get_parser():
    parser = configargparse.ArgumentParser(
        description='generate RST from argparse options',
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        formatter_class=configargparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('src', type=str, nargs='+',
                        help='source python files that contain get_parser() func')
    return parser
github pseewald / fprettify / fprettify / __init__.py View on Github external
"""helper function to convert strings to bool"""
        if str.lower() in ('yes', 'true', 't', 'y', '1'):
            return True
        elif str.lower() in ('no', 'false', 'f', 'n', '0'):
            return False
        else:
            return None

    arguments = {'prog': argv[0],
                 'description': 'Auto-format modern Fortran source files.',
                 'formatter_class': argparse.ArgumentDefaultsHelpFormatter}

    if argparse.__name__ == "configargparse":
        arguments['default_config_files'] = ['.fprettify.rc', '~/.fprettify.rc']

    parser = argparse.ArgumentParser(**arguments)

    parser.add_argument("-i", "--indent", type=int, default=3,
                        help="relative indentation width")
    parser.add_argument("-l", "--line-length", type=int, default=132,
                        help="column after which a line should end, viz. -ffree-line-length-n for GCC")
    parser.add_argument("-w", "--whitespace", type=int,
                        choices=range(0, 5), default=2, help="Presets for the amount of whitespace - "
                                                             "   0: minimal whitespace"
                                                             " | 1: operators (except arithmetic), print/read"
                                                             " | 2: operators, print/read, plus/minus"
                                                             " | 3: operators, print/read, plus/minus, muliply/divide"
                                                             " | 4: operators, print/read, plus/minus, muliply/divide, type component selector")
    parser.add_argument("--whitespace-comma", type=str2bool, nargs="?", default="None", const=True,
            help="boolean, en-/disable whitespace for comma/semicolons")
    parser.add_argument("--whitespace-assignment", type=str2bool, nargs="?", default="None", const=True,
            help="boolean, en-/disable whitespace for assignments")