def setupArguments():
    """Setup argument parser for commandline arguments.
	and Config file. The priority is (low to high):
	Default value, config file value, commandline value
	"""

    LOGGER_LEVELS = [
        "TRACE", "VERBOSE", "DEBUG", "INFO", "NOTICE", "WARNING", "SUPPRESSED",
        "ERROR", "CRITICAL", "ALERT", "EMERGENCY"
    ]
    formatter_class = configargparse.RawDescriptionHelpFormatter
    p = configargparse.ArgParser(description=DESCRIPTION,
                                 epilog=EXAMPLE_USAGE,
                                 default_config_files=[PROGRAM + ".cfg"],
                                 formatter_class=formatter_class)
    p.add("--version",
          action="version",
          version="%(prog)s {}".format(__version__))
    p.add("--config",
          required=False,
          is_config_file=True,
          help="Config file for this program")
    p.add("--logger-config",
          required=False,
          dest="logconfig",
          default="./logger.cfg",
          type=str,
          help="Logger config file for this program")
    p.add("--log-level",
          metavar="LEVEL",
          dest="loglevel",
          type=str,
          choices=LOGGER_LEVELS,
          default="INFO",
          help="Sets console log level. Valid Values are " +
          ', '.join(LOGGER_LEVELS))

    p.add('-o',
          "--output",
          metavar="OUTPUT FILE",
          dest="outfile",
          type=configargparse.FileType('w'),
          default=sys.stdout,
          help="Set output to a file")
    p.add("-i",
          "--input",
          metavar="INPUT FILES",
          dest="infile",
          type=configargparse.FileType('r'),
          nargs='+',
          help="A list of input files")
    return p.parse_args()
Exemple #2
0
    def add_yaml_arg(self):
        '''
        Add the yaml file argument, this is needed for scripts that
        parse the model config from yaml files

        '''
        # yaml configuration file
        self.add_argument('yaml_file',
                          type=configargparse.FileType('r'),
                          help='neon model specification file')
def _add_optional_group(parser):
    parser.add_argument("--entry-class",
                        type=str,
                        help="The class to analyze",
                        default="")
    parser.add_argument("--entry-func",
                        type=str,
                        help="The top function to analyze in `--entry-class`",
                        default="Top")
    parser.add_argument(
        "-o",
        type=configargparse.FileType("w"),
        help=
        "output json file containing analysis result. If not specified, result will dump in stdout",
        default=None,
        dest="output_file",
    )
    parser.add_argument(
        "--output-statistics",
        type=configargparse.FileType("w"),
        help="dump conditions statistics gathered and used to solve z3 in json",
        default=None,
        dest="output_statistics",
    )
Exemple #4
0
def add_authentication_group(parser: configargparse.ArgumentParser):
    auth_group = parser.add_argument_group(
        title="Authentication",
        description=clr_extra(
            "Authentication details are configured (and can be copied from) AppStore Connect->Users & Access->Keys."
        ),
    )
    auth_group.add_argument("--issuer-id", required=True, help="Issuer ID.")
    auth_group.add_argument("--key-id", required=True, help="Key ID.")
    key_group = auth_group.add_mutually_exclusive_group(required=True)
    key_group.add_argument("--key", help="Private Key as a string.")
    key_group.add_argument(
        "--key-file",
        type=configargparse.FileType(mode="r"),
        help="Private Key from a filepath.",
    )
Exemple #5
0
  def parseArguments(self):
    self.parser.add('-c', '--config', is_config_file=True,  
         help='config file path (default is '+",".join(default_cnf_files)+').')

    self.parser.add('--master','-M',default=default_master,
         help='Name of the master node (default: '+default_master+')'),

    self.parser.add('--node','-n',default=default_node,
         help='Name of this node (default: '+default_node+')'),
    self.parser.add('--machine','-a',default=default_machine,
         help='Machine (default :'+default_machine+')'),

    self.parser.add('-m','--mqtthost',default=default_host,
         help='MQTT host (default :'+default_host+')'),
    self.parser.add('--mqttprotocol',default=default_protocol,
         help='MQTT protocol (default :'+str(default_protocol)+')'),
    self.parser.add('--topic','-t',default=default_sub,
         help='MQTT topic to subcribe to for replies from the master (default: '+default_sub+').'),

    self.parser.add('--verbose', '-v', action='count', default=0,
         help='Verbose on (default off)')
    self.parser.add('--debug', '-d', action='count', default=0,
         help='Debuging on; implies verbose (default off)')
    self.parser.add('--no-mqtt-log', action='count',
         help='Disable logging to MQTT log channel (default on)'),
    self.parser.add('--no-syslog',  action='count',
        help='Disable syslogging (defautl on)'),
    self.parser.add('-l','--logfile', type=configargparse.FileType('w+'), 
        help='Append log entries to specified file (default: none)'),

    self.parser.add('--pidfile', action='store', default = self.default_pidfile,
         help='File to write PID to, (Default: '+self.default_pidfile+').')
    self.parser.add('--daemonize', '-b', action='count',
         help='Deamonize into the background after startup (default is to stay in the foreground).')

    self.cnf = self.parser.parse_args()
Exemple #6
0
def get_parser():
    """Get default arguments."""
    parser = configargparse.ArgumentParser(
        description="Align text to audio using CTC segmentation."
        "using a pre-trained speech recognition model.",
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        formatter_class=configargparse.ArgumentDefaultsHelpFormatter,
    )
    # general configuration
    parser.add("--config", is_config_file=True, help="Decoding config file path.")
    parser.add_argument(
        "--ngpu", type=int, default=0, help="Number of GPUs (max. 1 is supported)"
    )
    parser.add_argument(
        "--dtype",
        choices=("float16", "float32", "float64"),
        default="float32",
        help="Float precision (only available in --api v2)",
    )
    parser.add_argument(
        "--backend",
        type=str,
        default="pytorch",
        choices=["pytorch"],
        help="Backend library",
    )
    parser.add_argument("--debugmode", type=int, default=1, help="Debugmode")
    parser.add_argument("--verbose", "-V", type=int, default=1, help="Verbose option")
    parser.add_argument(
        "--preprocess-conf",
        type=str,
        default=None,
        help="The configuration file for the pre-processing",
    )
    # task related
    parser.add_argument(
        "--data-json", type=str, help="Json of recognition data for audio and text"
    )
    parser.add_argument("--utt-text", type=str, help="Text separated into utterances")
    # model (parameter) related
    parser.add_argument(
        "--model", type=str, required=True, help="Model file parameters to read"
    )
    parser.add_argument(
        "--model-conf", type=str, default=None, help="Model config file"
    )
    parser.add_argument(
        "--num-encs", default=1, type=int, help="Number of encoders in the model."
    )
    # ctc-segmentation related
    parser.add_argument(
        "--subsampling-factor",
        type=int,
        default=None,
        help="Subsampling factor."
        "If the encoder sub-samples its input, the number of frames at the CTC layer is"
        " reduced by this factor. For example, a BLSTMP with subsampling 1_2_2_1_1"
        " has a subsampling factor of 4.",
    )
    parser.add_argument(
        "--frame-duration",
        type=int,
        default=None,
        help="Non-overlapping duration of a single frame in milliseconds.",
    )
    parser.add_argument(
        "--min-window-size",
        type=int,
        default=None,
        help="Minimum window size considered for utterance.",
    )
    parser.add_argument(
        "--max-window-size",
        type=int,
        default=None,
        help="Maximum window size considered for utterance.",
    )
    parser.add_argument(
        "--use-dict-blank",
        type=int,
        default=None,
        help="Use the Blank character of the model dictionary.",
    )
    parser.add_argument(
        "--output",
        type=configargparse.FileType("w"),
        required=True,
        help="Output segments file",
    )
    return parser
Exemple #7
0
def _parse_config(args):
    def regexp(str_regex):
        try:
            return re.compile(str_regex)
        except re.error as err:
            raise configargparse.ArgumentTypeError('Invalid regexp: %r (%s)' %
                                                   (str_regex, err.msg))

    parser = configargparse.ArgParser(
        auto_env_var_prefix='MARGE_',
        ignore_unknown_config_file_keys=True,  # Don't parse unknown args
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        formatter_class=configargparse.ArgumentDefaultsRawHelpFormatter,
        description=__doc__,
    )
    parser.add_argument(
        '--config-file',
        env_var='MARGE_CONFIG_FILE',
        type=str,
        is_config_file=True,
        help='config file path',
    )
    auth_token_group = parser.add_mutually_exclusive_group(required=True)
    auth_token_group.add_argument(
        '--auth-token',
        type=str,
        metavar='TOKEN',
        help=
        ('Your GitLab token.\n'
         'DISABLED because passing credentials on the command line is insecure:\n'
         'You can still set it via ENV variable or config file, or use "--auth-token-file" flag.\n'
         ),
    )
    auth_token_group.add_argument(
        '--auth-token-file',
        type=configargparse.FileType('rt'),
        metavar='FILE',
        help='Path to your GitLab token file.\n',
    )
    parser.add_argument(
        '--gitlab-url',
        type=str,
        required=True,
        metavar='URL',
        help='Your GitLab instance, e.g. "https://gitlab.example.com".\n',
    )
    ssh_key_group = parser.add_mutually_exclusive_group(required=True)
    ssh_key_group.add_argument(
        '--ssh-key',
        type=str,
        metavar='KEY',
        help=
        ('The private ssh key for marge so it can clone/push.\n'
         'DISABLED because passing credentials on the command line is insecure:\n'
         'You can still set it via ENV variable or config file, or use "--ssh-key-file" flag.\n'
         ),
    )
    ssh_key_group.add_argument(
        '--ssh-key-file',
        type=str,  # because we want a file location, not the content
        metavar='FILE',
        help='Path to the private ssh key for marge so it can clone/push.\n',
    )
    parser.add_argument(
        '--embargo',
        type=interval.IntervalUnion.from_human,
        metavar='INTERVAL[,..]',
        help=
        'Time(s) during which no merging is to take place, e.g. "Friday 1pm - Monday 9am".\n',
    )
    experimental_group = parser.add_mutually_exclusive_group(required=False)
    experimental_group.add_argument(
        '--use-merge-strategy',
        action='store_true',
        help=
        ('Use git merge instead of git rebase to update the *source* branch (EXPERIMENTAL)\n'
         'If you need to use a strict no-rebase workflow (in most cases\n'
         'you don\'t want this, even if you configured gitlab to use merge requests\n'
         'to use merge commits on the *target* branch (the default).)'),
    )
    parser.add_argument(
        '--add-tested',
        action='store_true',
        help=
        'Add "Tested: marge-bot <$MR_URL>" for the final commit on branch after it passed CI.\n',
    )
    parser.add_argument(
        '--batch',
        action='store_true',
        help='Enable processing MRs in batches\n',
    )
    parser.add_argument(
        '--add-part-of',
        action='store_true',
        help='Add "Part-of: <$MR_URL>" to each commit in MR.\n',
    )
    parser.add_argument(
        '--add-reviewers',
        action='store_true',
        help=
        'Add "Reviewed-by: $approver" for each approver of MR to each commit in MR.\n',
    )
    parser.add_argument(
        '--impersonate-approvers',
        action='store_true',
        help='Marge-bot pushes effectively don\'t change approval status.\n',
    )
    parser.add_argument(
        '--approval-reset-timeout',
        type=time_interval,
        default='0s',
        help=
        ('How long to wait for approvals to reset after pushing.\n'
         'Only useful with the "new commits remove all approvals" option in a project\'s settings.\n'
         'This is to handle the potential race condition where approvals don\'t reset in GitLab\n'
         'after a force push due to slow processing of the event.\n'),
    )
    parser.add_argument(
        '--project-regexp',
        type=regexp,
        default='.*',
        help=
        "Only process projects that match; e.g. 'some_group/.*' or '(?!exclude/me)'.\n",
    )
    parser.add_argument(
        '--ci-timeout',
        type=time_interval,
        default='15min',
        help='How long to wait for CI to pass.\n',
    )
    parser.add_argument(
        '--max-ci-time-in-minutes',
        type=int,
        default=None,
        help='Deprecated; use --ci-timeout.\n',
    )
    parser.add_argument('--git-timeout',
                        type=time_interval,
                        default='120s',
                        help='How long a single git operation can take.\n')
    parser.add_argument(
        '--branch-regexp',
        type=regexp,
        default='.*',
        help=
        'Only process MRs whose target branches match the given regular expression.\n',
    )
    parser.add_argument(
        '--debug',
        action='store_true',
        help='Debug logging (includes all HTTP requests etc).\n',
    )
    config = parser.parse_args(args)

    if config.use_merge_strategy and config.batch:
        raise MargeBotCliArgError(
            '--use-merge-strategy and --batch are currently mutually exclusive'
        )
    if config.use_merge_strategy and config.add_tested:
        raise MargeBotCliArgError(
            '--use-merge-strategy and --add-tested are currently mutually exclusive'
        )

    cli_args = []
    # pylint: disable=protected-access
    for _, (_, value) in parser._source_to_settings.get(
            configargparse._COMMAND_LINE_SOURCE_KEY, {}).items():
        cli_args.extend(value)
    for bad_arg in ['--auth-token', '--ssh-key']:
        if bad_arg in cli_args:
            raise MargeBotCliArgError(
                '"%s" can only be set via ENV var or config file.' % bad_arg)
    return config
Exemple #8
0
     default_config_files=[
         os.path.join(camsa.root_dir, "utils", "grimm",
                      "grimm2camsa_points.ini"),
         os.path.join(camsa.root_dir, "logging.ini")
     ])
 parser.add_argument(
     "grimm",
     nargs="+",
     help=
     "A list of paths to files, that in GRIMM format contain information about scaffold assemblies."
 )
 parser.add_argument("--o-format", type=str, help="")
 parser.add_argument(
     "-o",
     "--output",
     type=configargparse.FileType("wt"),
     default=sys.stdout,
     help=
     "Path to the file, where converted assembly points will be stored.\nDEFAULT: stdout"
 )
 parser.add_argument("--o-delimiter", default="\t", type=str, help="")
 parser.add_argument(
     "--no-trim-names",
     dest="trim_names",
     default=True,
     action="store_false",
     help=
     "A flag to indicate, that genome names from grimm file need not to be trimmed by the first \".\"\nDEFAULT: true"
 )
 parser.add_argument(
     "--trimmer-char",
Exemple #9
0
    def parseArguments(self):
        self.parser.add('-c',
                        '--config',
                        is_config_file=True,
                        help='config file path (default is ' +
                        ",".join(default_cnf_files) + ').')

        self.parser.add('--master',
                        '-M',
                        default=default_master,
                        help='Name of the master node (default: ' +
                        default_master + ')'),
        self.parser.add('--drumbeat',
                        '-D',
                        default=default_drumbeat,
                        help='Name of the drumbeat node (default: ' +
                        default_drumbeat + ')'),

        self.parser.add('--node',
                        '-n',
                        default=default_node,
                        help='Name of this node (default: ' + default_node +
                        ')'),
        self.parser.add('-s',
                        '--secret',
                        default=default_secret,
                        help='Master node shared secret (default: ' +
                        default_secret + ')'),
        self.parser.add('--machine',
                        '-a',
                        default=default_machine,
                        help='Machine (default :' + default_machine + ')'),

        self.parser.add('-m',
                        '--mqtthost',
                        default=default_host,
                        help='MQTT host (default :' + default_host + ')'),
        self.parser.add('--mqttprotocol',
                        default=default_protocol,
                        help='MQTT protocol (default :' + default_protocol +
                        ')'),
        self.parser.add(
            '--topic',
            '-t',
            default=default_sub,
            help=
            'MQTT topic to subcribe to for replies from the master (default: '
            + default_sub + ').'),

        self.parser.add('--verbose',
                        '-v',
                        action='count',
                        default=0,
                        help='Verbose on (default off)')
        self.parser.add('--debug',
                        '-d',
                        action='count',
                        default=0,
                        help='Debuging on; implies verbose (default off)')
        self.parser.add(
            '--no-mqtt-log',
            action='count',
            help='Disable logging to MQTT log channel (default on)'),
        self.parser.add('--no-syslog', help='Disable syslogging (defautl on)'),
        self.parser.add(
            '-l',
            '--logfile',
            type=configargparse.FileType('w+'),
            help='Append log entries to specified file (default: none)'),

        self.parser.add('--ignorebeat',
                        help='Ignore the beat (default is to follow)')
        self.parser.add('--leeway',
                        action='store',
                        default=default_leeway,
                        type=int,
                        help='Beat leeway, in seconds (default: ' +
                        str(default_leeway) + ' seconds).')
        self.cnf = self.parser.parse_args()

        self.cnf.follower = not self.cnf.ignorebeat
        information="For more information refer to {docs}".format(docs=camsa.CAMSA_DOCS_URL),
        contact=camsa.CONTACT)
    full_description = "=" * 80 + "\n" + full_description + "=" * 80 + "\n"
    parser = configargparse.ArgParser(description=full_description, formatter_class=configargparse.RawTextHelpFormatter,
                                      default_config_files=[os.path.join(camsa.root_dir, "logging.ini")])
    parser.add_argument("-c", "--config", is_config_file=True, help="Config file overwriting some of the default settings as well as any flag starting with \"--\".")

    parser.add_argument("--version", action="version", version=camsa.VERSION)
    parser.add_argument("ragout_coords", type=str, help="A path to ragout coords file")
    parser.add_argument("--filter-indels", action="store_true", dest="filter_indels", default=False)
    parser.add_argument("--no-fragment-stats", action="store_false", dest="fragment_stats", default=True)
    parser.add_argument("--no-genome-stats", action="store_false", dest="genome_stats", default=True)
    parser.add_argument("--filter-duplications", action="store_true", dest="filter_duplications", default=False)
    parser.add_argument("--good-genomes", type=str, default="", help="A coma separated list of genome names, to be processed and conversed.\nDEFAULT: \"\" (i.e., all genomes are good)")
    parser.add_argument("--bad-genomes", type=str, default="", help="A coma separated list of genome names, to be excluded from processing and conversion.\nDEFAULT: \"\" (i.e., no genomes are bad)")
    parser.add_argument("-o", "--output", type=configargparse.FileType("wt"), default=sys.stdout)
    parser.add_argument("--c-logging-level", dest="c_logging_level", default=logging.INFO, type=int,
                        choices=[logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL],
                        help="Logging level for the converter.\nDEFAULT: {info}".format(info=logging.INFO))
    parser.add_argument("--c-logging-formatter-entry",
                        help="Format string for python logger.")
    args = parser.parse_args()

    start_time = datetime.datetime.now()

    logger = logging.getLogger("CAMSA.utils.ragout_coords2fasta")
    ch = logging.StreamHandler()
    ch.setLevel(args.c_logging_level)
    logger.setLevel(args.c_logging_level)
    logger.addHandler(ch)
    logger.info(full_description)
Exemple #11
0
    def __init__(self,
                 objects=(),
                 description="""Run the Pypelid bypass simulation of 
                    Euclid observations."""):
        """ Parse arguments """
        parser = configargparse.ArgumentParser(
            description=description,
            args_for_setting_config_path=['-c', '--conf'],
            formatter_class=configargparse.ArgumentDefaultsHelpFormatter)

        parser.register('type', 'bool', str_to_bool)

        parser.add_argument("-w",
                            metavar='filename',
                            nargs='?',
                            const=sys.stdout,
                            type=configargparse.FileType('w'),
                            help="write out config file and exit",
                            is_write_out_config_file_arg=True)
        # self.parser.add_argument('--version', action='version', version='%s'%str(misc.GitEnv()), help="show git hash and exit")

        param_list = []

        objs = []
        for o in objects:
            try:
                for dep in o._dependencies:
                    objects.append(dep)
            except AttributeError:
                pass
            if o not in objs:
                objs.append(o)

        for o in objs:
            if isinstance(o, Defaults):
                default_params = o
            else:
                try:
                    default_params = o._default_params
                except:
                    continue

            arg_group = parser.add_argument_group(o.__name__)

            for p in default_params:
                if p.name in param_list:
                    continue

                try:
                    if p.hidden:
                        continue
                except AttributeError:
                    pass

                param_list.append(p.name)
                a = {}
                for k in self.argparse_keys:
                    try:
                        a[k] = p.__dict__[k]
                    except KeyError:
                        pass
                args = ["--%s" % p.name]
                try:
                    args.append("-%s" % p.__dict__['alias'])
                except:
                    pass
                arg_group.add_argument(*args, **a)

        self.__dict__['_parser'] = parser
        self.__dict__['_args'] = parser.parse_args()

        # Run validation in each class
        for o in objs:
            try:
                o.check_config(self._args.__dict__)
            except AttributeError:
                pass
def main():
    secret_santa_config_dir = Path('~/.secret_santa').expanduser()
    parser = configargparse.ArgParser(description='Send secret Santa emails',
                                      default_config_files=[
                                          '/etc/secret_santa/*.conf',
                                          str(secret_santa_config_dir /
                                              '*.conf')
                                      ])
    parser.add_argument('--names',
                        '-n',
                        metavar='NAMES.yaml',
                        default=str(secret_santa_config_dir / 'names.yaml'),
                        type=configargparse.FileType('r'),
                        help='yaml file containing participant data')
    parser.add_argument(
        '--debug',
        action='store_true',
        help='print out hidden data such as the secret santa choices')
    parser.add_argument('--dry_run',
                        action='store_true',
                        help='dry run mode which does not send emails')
    parser.add_argument('--dry_run_email',
                        type=str,
                        default=None,
                        help='dry run mode which does not send emails address')
    parser.add_argument('--password',
                        type=str,
                        required=True,
                        help='Email Password')
    parser.add_argument('--username',
                        type=str,
                        required=True,
                        help='Email Username')
    parser.add_argument('--font',
                        type=str,
                        default='RobotoSlab-VariableFont_wght.ttf',
                        help='Font Name Username')
    parser.add_argument('--font_path',
                        type=str,
                        default='/usr/local/Caskroom/font-arial/2.82/',
                        help='Font Path')

    args = parser.parse_args()

    config, credentials, images = {}, {}, {}

    credentials['password'] = args.password
    credentials['username'] = args.username

    images['font'] = args.font
    images['font_path'] = args.font_path

    config['email'] = credentials
    config['images'] = images
    config = Box(config)

    names = load(args.names.read(), Loader=FullLoader)

    names_graph = create_graph(names)
    plt.subplot(121)
    nx.draw_circular(names_graph, with_labels=True, font_weight='bold')
    selection_graph = graph_select(names_graph)
    plt.subplot(122)
    nx.draw_networkx(selection_graph, with_labels=True, font_weight='bold')
    for edge in selection_graph.edges:
        (sender, recipient) = edge
        email = args.dry_run_email or selection_graph.nodes[sender]['email']
        exclude = ', '.join(selection_graph.nodes[sender]['exclude']
                            or ['anyone'])

        if args.debug:
            print(f"Emailing {sender} <{email}>: {recipient}")
        else:
            print(f"Emailing {sender} <{email}>: HIDDEN")
        if not args.dry_run:
            santa_email(sender, email, recipient, exclude, config=config)
    if args.debug:
        plt.show()
Exemple #13
0
def parse_options():
    '''Handle command-line options

    Return parser object and list of arguments
    '''
    parser = configargparse.ArgumentParser()
    parser.add_argument('-p', '--profile', required=False)
    parser.add_argument('-r', '--region', required=False)
    parser.add_argument('--version',
                        action='version',
                        version=__about__.__version__)
    subparsers = parser.add_subparsers(title='available subcommands',
                                       dest='subcommand')

    parser_resources = subparsers.add_parser('resources',
                                             help='List stack resources')
    parser_resources.add_argument('name', help='Stack name')
    parser_resources.add_argument(
        'logical_id',
        nargs='?',
        default=None,
        help='Logical resource id. Returns physical_resource_id.')

    parser_outputs = subparsers.add_parser('outputs',
                                           help='List stack outputs')
    parser_outputs.add_argument('name', help='Stack name')
    parser_outputs.add_argument('output_name',
                                nargs='?',
                                default=None,
                                help='Output name. Returns output value.')

    parser_config = subparsers.add_parser('config',
                                          help='Print config properties')
    parser_config.add_argument('-e', '--env', env_var='STACKS_ENV')
    parser_config.add_argument('-o',
                               '--output',
                               default='text',
                               choices=['text', 'yaml', 'json'],
                               dest='output_format',
                               help='Output format')
    parser_config.add_argument('-c',
                               '--config',
                               default='config.yaml',
                               env_var='STACKS_CONFIG',
                               required=False,
                               type=_is_file)
    parser_config.add_argument('--config-dir',
                               default='config.d',
                               env_var='STACKS_CONFIG_DIR',
                               required=False,
                               type=_is_dir)
    parser_config.add_argument('property_name', nargs='?', default=None)

    parser_list = subparsers.add_parser('list', help='List stacks')
    parser_list.add_argument('-v', '--verbose', action='store_true')
    parser_list.add_argument('name',
                             default='*',
                             nargs='?',
                             help='Stack name or unix shell-style pattern')

    parser_create = subparsers.add_parser('create', help='Create a new stack')
    parser_create.add_argument('-t',
                               '--template',
                               required=True,
                               type=configargparse.FileType())
    parser_create.add_argument('-c',
                               '--config',
                               default='config.yaml',
                               env_var='STACKS_CONFIG',
                               required=False,
                               type=_is_file)
    parser_create.add_argument('--config-dir',
                               default='config.d',
                               env_var='STACKS_CONFIG_DIR',
                               required=False,
                               type=_is_dir)
    parser_create.add_argument('name', nargs='?', default=None)
    parser_create.add_argument('-e',
                               '--env',
                               env_var='STACKS_ENV',
                               required=True)
    parser_create.add_argument('-P',
                               '--property',
                               required=False,
                               action='append')
    parser_create.add_argument('-d', '--dry-run', action='store_true')
    parser_create.add_argument('-f',
                               '--follow',
                               dest='events_follow',
                               help='Follow stack events',
                               action='store_true')

    parser_update = subparsers.add_parser('update',
                                          help='Update an existing stack')
    parser_update.add_argument('-t',
                               '--template',
                               required=True,
                               type=configargparse.FileType())
    parser_update.add_argument('-c',
                               '--config',
                               env_var='STACKS_CONFIG',
                               default='config.yaml',
                               required=False,
                               type=_is_file)
    parser_update.add_argument('--config-dir',
                               default='config.d',
                               env_var='STACKS_CONFIG_DIR',
                               required=False,
                               type=_is_dir)
    parser_update.add_argument('name', nargs='?', default=None)
    parser_update.add_argument('-e',
                               '--env',
                               env_var='STACKS_ENV',
                               required=True)
    parser_update.add_argument('-P',
                               '--property',
                               required=False,
                               action='append')
    parser_update.add_argument('-d', '--dry-run', action='store_true')
    parser_update.add_argument('--create',
                               dest='create_on_update',
                               help='Create if stack does not exist.',
                               action='store_true')
    parser_update.add_argument('-f',
                               '--follow',
                               dest='events_follow',
                               help='Follow stack events',
                               action='store_true')

    parser_delete = subparsers.add_parser('delete',
                                          help='Delete an existing stack')
    parser_delete.add_argument('-f',
                               '--follow',
                               dest='events_follow',
                               help='Follow stack events',
                               action='store_true')
    parser_delete.add_argument('-y',
                               '--yes',
                               help='Confirm stack deletion.',
                               action='store_true')
    parser_delete.add_argument('name')

    parser_events = subparsers.add_parser('events',
                                          help='List events from a stack')
    parser_events.add_argument('name')
    parser_events.add_argument('-f',
                               '--follow',
                               dest='events_follow',
                               action='store_true',
                               help='Poll for new events until stopped.')
    parser_events.add_argument(
        '-n',
        '--lines',
        default='10',
        type=int,
        help=
        'Maximum number of lines of CF output returned per 5 second iteration')

    return parser, parser.parse_args()
Exemple #14
0
if __name__ == "__main__":
    full_description = camsa.full_description_template.format(
        names=camsa.CAMSA_AUTHORS,
        affiliations=camsa.AFFILIATIONS,
        dummy=" ",
        tool="Converting FASTA formatted fragments further CAMSA processing.",
        information="For more information refer to {docs}".format(docs=camsa.CAMSA_DOCS_URL),
        contact=camsa.CONTACT)
    full_description = "=" * 80 + "\n" + full_description + "=" * 80 + "\n"
    parser = configargparse.ArgParser(description=full_description, formatter_class=configargparse.RawTextHelpFormatter,
                                      default_config_files=[os.path.join(camsa.root_dir, "utils", "fasta", "fasta2camsa_seqi.ini"),
                                                            os.path.join(camsa.root_dir, "logging.ini")])

    parser.add_argument("--version", action="version", version=camsa.VERSION)
    parser.add_argument("-o", "--output-file", metavar="OUTPUT", dest="output", type=configargparse.FileType("wt"), default=sys.stdout,
                        help="A file to which the CAMSA readable fragments lengths would be written. Standard extension is \".camsa.lengths\".\nDEFAULT: stdout")
    parser.add_argument("--o-format", type=str, help="")
    parser.add_argument("contigs", nargs="+", metavar="CONTIGS", type=configargparse.FileType("rt"), default=sys.stdin,
                        help="A list of input *.fasta files with contigs.\nDEFAULT: stdin")
    parser.add_argument("--c-logging-level", dest="logging_level", default=logging.INFO, type=int,
                        choices=[logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL],
                        help="Logging level for the converter.\nDEFAULT: {info}".format(info=logging.INFO))
    parser.add_argument("--c-logging-formatter-entry",
                        help="Format string for python logger.")
    parser.add_argument("--o-delimiter", type=str, default="\t",
                        help="A single character string, used as a delimiter in the output (t)/(c)sv file.\nDEFAULT: \\t")
    args = parser.parse_args()
    start_time = datetime.datetime.now()

    logger = logging.getLogger("CAMSA.utils.fasta2camsa_seqi")
Exemple #15
0
def get_parser():
    """Get default arguments."""
    parser = configargparse.ArgumentParser(
        description="Align text to audio using CTC segmentation."
        "using a pre-trained speech recognition model.",
        config_file_parser_class=configargparse.YAMLConfigFileParser,
        formatter_class=configargparse.ArgumentDefaultsHelpFormatter,
    )
    # general configuration
    parser.add("--config", is_config_file=True, help="Decoding config file path.")
    parser.add_argument(
        "--ngpu", type=int, default=0, help="Number of GPUs (max. 1 is supported)"
    )
    parser.add_argument(
        "--dtype",
        choices=("float16", "float32", "float64"),
        default="float32",
        help="Float precision (only available in --api v2)",
    )
    parser.add_argument(
        "--backend",
        type=str,
        default="pytorch",
        choices=["pytorch"],
        help="Backend library",
    )
    parser.add_argument("--debugmode", type=int, default=1, help="Debugmode")
    parser.add_argument("--verbose", "-V", type=int, default=1, help="Verbose option")
    parser.add_argument(
        "--preprocess-conf",
        type=str,
        default=None,
        help="The configuration file for the pre-processing",
    )
    # task related
    parser.add_argument(
        "--data-json", type=str, help="Json of recognition data for audio and text"
    )
    parser.add_argument("--utt-text", type=str, help="Text separated into utterances")
    # model (parameter) related
    parser.add_argument(
        "--model", type=str, required=True, help="Model file parameters to read"
    )
    parser.add_argument(
        "--model-conf", type=str, default=None, help="Model config file"
    )
    parser.add_argument(
        "--num-encs", default=1, type=int, help="Number of encoders in the model."
    )
    # ctc-segmentation related
    parser.add_argument(
        "--subsampling-factor",
        type=int,
        default=None,
        help="Subsampling factor."
        " If the encoder sub-samples its input, the number of frames at the CTC layer"
        " is reduced by this factor. For example, a BLSTMP with subsampling 1_2_2_1_1"
        " has a subsampling factor of 4.",
    )
    parser.add_argument(
        "--frame-duration",
        type=int,
        default=None,
        help="Non-overlapping duration of a single frame in milliseconds.",
    )
    parser.add_argument(
        "--min-window-size",
        type=int,
        default=None,
        help="Minimum window size considered for utterance.",
    )
    parser.add_argument(
        "--max-window-size",
        type=int,
        default=None,
        help="Maximum window size considered for utterance.",
    )
    parser.add_argument(
        "--use-dict-blank",
        type=int,
        default=None,
        help="DEPRECATED.",
    )
    parser.add_argument(
        "--set-blank",
        type=int,
        default=None,
        help="Index of model dictionary for blank token (default: 0).",
    )
    parser.add_argument(
        "--gratis-blank",
        type=int,
        default=None,
        help="Set the transition cost of the blank token to zero. Audio sections"
        " labeled with blank tokens can then be skipped without penalty. Useful"
        " if there are unrelated audio segments between utterances.",
    )
    parser.add_argument(
        "--replace-spaces-with-blanks",
        type=int,
        default=None,
        help="Fill blanks in between words to better model pauses between words."
        " Segments can be misaligned if this option is combined with --gratis-blank."
        " May increase length of ground truth.",
    )
    parser.add_argument(
        "--scoring-length",
        type=int,
        default=None,
        help="Changes partitioning length L for calculation of the confidence score.",
    )
    parser.add_argument(
        "--output",
        type=configargparse.FileType("w"),
        required=True,
        help="Output segments file",
    )
    return parser
Exemple #16
0
def define_args(parser):
    """ Define the input, output, scaling, and decimation command-line arguments.
    """
    # Would like this to be a mutually-exclusive group with one arg required,
    # but those don't have title and description parms and don't group their
    # help separately. Mutual exclusion is tested for in _process_args.
    input_group = parser.add_argument_group(
        title='Inputs',
        description='These arguments each specify a different input data '
        'source.  Use exactly one.')
    input_group.add_argument(
        '--in_eos_file_base',
        metavar='<base path>. ',
        help='Read source data points from EOS data <base path>'
        '[default: %(default)s]. '
        'If this is set, --out_eos_file_base must also be set.')
    input_group.add_argument(
        '--input_file',
        metavar='<path>',
        type=configargparse.FileType('r'),
        help='Read this input file for source data points')
    input_group.add_argument(
        '--parabola_in',
        action='store_true',
        help='(For developer testing) Use the internal noisy input parabola '
        'as source data [default: %(default)s]')
    input_group.add_argument(
        '--predefined_in',
        action='store_true',
        help='(For developer testing) Use the internal predefined data as '
        'source data [default: %(default)s]')

    # Would like this to be a mutually-exclusive group, but those don't
    # have title and description parms and don't group their help separately.
    # Mutual exclusion is tested for in _process_args.
    output_group = parser.add_argument_group(
        title='Outputs',
        description='These arguments each specify where the changed data '
        'is written to.  Use no more than one.')
    output_group.add_argument(
        '--out_eos_file_base',
        metavar='<base path>',
        help='Use the EOS file <base path> for '
        'the adjusted/moved data points [default: %(default)s]. '
        'If this is set, --in_eos_file_base must also be set.')
    output_group.add_argument(
        '--output_file_name',
        metavar='<path>',
        # Not setting "type=argparse.FileType('w')" because that opens the
        # file for writing in the argument parser, and that conflicts with
        # opening it for writing later:
        help='Use this output file for the adjusted/moved data points '
        '[default: %(default)s]')

    shifts = parser.add_argument_group(
        title='Shifts, Limits, and Point Exclusion',
        description='These arguments limit, exclude or alter the input data.')
    shifts.add_argument(
        '--decimate',
        metavar='<count>',
        type=int,
        help='Only use <count> points from the input data, minimum 2 '
        '[default: all points]')
    shifts.add_argument(
        '--step',
        metavar='<step>',
        type=int,
        help='Only use every <step>th input point.  e.g. --step 2 only' +
        ' uses every other point, minimum 1 [default: %(default)s]')
    shifts.add_argument(
        '--t_step',
        metavar='<step>',
        type=int,
        help='Only use every <step>th isotherm.  e.g. --step 2 only' +
        ' uses every other isotherm, minimum 1 [default: %(default)s]')
    shifts.add_argument(
        '--x_include',
        '--xinclude',
        nargs=2,
        metavar=('<lo>', '<hi>'),
        type=float,
        help=
        'Only consume input points when <lo> > x > <hi> [default: %(default)s]'
    )
    shifts.add_argument(
        '--x_scale',
        '--xscale',
        nargs=3,
        metavar=('<scale>', '<lo>', '<hi>'),
        type=float,
        help='Multiply the x value of each input point by <scale> '
        'when <lo> > x > <hi> [default: %(default)s] '
        '>>NOTE<< applied AFTER --x_include')
    shifts.add_argument('--x_shift',
                        '--xshift',
                        nargs=3,
                        type=float,
                        help='Add <shift> to the x value of each input point '
                        'when <lo> > x > <hi> [default: %(default)s] '
                        '>>NOTE<< applied AFTER --x_scale',
                        metavar=('<shift>', '<lo>', '<hi>'))
    shifts.add_argument(
        '--y_include',
        '--yinclude',
        nargs=2,
        metavar=('<lo>', '<hi>'),
        type=float,
        help='Only consume input points when <lo> > y > <hi> [default: '
        '%(default)s]')
    shifts.add_argument(
        '--y_scale',
        '--yscale',
        nargs=3,
        metavar=('<scale>', '<lo>', '<hi>'),
        type=float,
        help='Multiply the y value of each input point by <scale> '
        'when <lo> > x > <hi> [default: %(default)s].  '
        '>>NOTE<< uses x to trigger, not y.  '
        '>>NOTE<< applied BEFORE x adjustments, and AFTER --y_include.  ')
    shifts.add_argument('--y_shift',
                        '--yshift',
                        nargs=3,
                        metavar=('<shift>', '<lo>', '<hi>'),
                        type=float,
                        help='Add <shift> to the y value of each input point '
                        'when <lo> > x > <hi> [default: %(default)s] '
                        '>>NOTE<< uses x to trigger, not y.  ')
    shifts.add_argument(
        '--t_include',
        '--tinclude',
        nargs=2,
        metavar=('<lo>', '<hi>'),
        type=float,
        help='Only consume input points when <lo> > t > <hi> [default: '
        '%(default)s]')
    shifts.add_argument(
        '--v_axis',
        action='store_true',
        help=
        'Use v as x axis instead or rho. Note curve fits don\'t work like this.'
    )

    # TODO: Add the rest of the arguments in alphabetical order, so they come
    # out that way in help. (Even though the arguments are defined in different
    # modules)
    parser.add_argument(
        '--background_file',
        metavar='<path>',
        nargs='+',
        type=configargparse.FileType('r'),
        help='Use this input file for background (unchanging) data points '
        '[default: %(default)s]')
    parser.add_argument(
        '--curve_output_file_name',
        metavar='<path>',
        # Not setting "type=argparse.FileType('w')" because that opens the file
        # for writing in the argument parser, and that conflicts with opening it
        # for writing later.
        help='Use this output file for data points generated from the '
        'current fit curve [default: %(default)s]')
    parser.add_argument('--eos_function',
                        help='Only read in the data for this function'
                        '[default: %(default)s]')
    parser.add_argument(
        '--use_eos_info_file',
        action='store_true',
        help=
        'When EOS is selected as input, read and write the .info file with the'
        ' same name as the eos data file with extension .info. [default: %(default)s]'
    )
    # parser.add_argument(
    #     '--yaml', action='store_true',
    #     dest='use_yaml_io',
    #     help='Use YAML format for input and output files [default: %(default)s]')

    output_group = parser.add_argument_group(
        title='View',
        description='Change the view but don\'t change the actual data')
    output_group.add_argument('--x_max',
                              metavar='<num>',
                              help='Set the maximum x value for the window')
    output_group.add_argument('--x_min',
                              metavar='<num>',
                              help='Set the minimum x value for the window')
    output_group.add_argument('--y_max',
                              metavar='<num>',
                              help='Set the maximum y value for the window')
    output_group.add_argument('--y_min',
                              metavar='<num>',
                              help='Set the minimum y value for the window')

    parser.set_defaults(
        # Input group:
        in_eos_file_base=None,
        input_file=None,
        parabola_in=False,
        predefined_in=False,

        # Output group:
        out_eos_file_base=None,
        output_file_name='moved_points_out.dat',

        # Shifts group:
        decimate=_NO_DECIMATE,
        step=1,
        t_step=1,
        x_include=[_NEG_INFINITY, _INFINITY],
        x_scale=[1.0, _NEG_INFINITY, _INFINITY],
        x_shift=[0.0, _NEG_INFINITY, _INFINITY],
        y_include=[_NEG_INFINITY, _INFINITY],
        y_scale=[1.0, _NEG_INFINITY, _INFINITY],
        y_shift=[0.0, _NEG_INFINITY, _INFINITY],
        t_include=[_NEG_INFINITY, _INFINITY],

        # other:
        background_file=[],
        curve_output_file_name='fit_curve_out.dat',
        use_eos_info_file=False,
        use_yaml_io=False,
        eos_function='all',
    )
Exemple #17
0
    default=None,
    type=str,
    help='comma-separated list of email addresses to send messages to',
    env_var="SEND_MESSAGES_TO")
parser.add_argument('--notification_interval',
                    default=86400,
                    type=int,
                    help='time in seconds between status emails',
                    env_var="NOTIFICATION_INTERVAL")
parser.add_argument('--account',
                    type=str,
                    help='Account to perform delegations for',
                    env_var="ACCOUNT")
parser.add_argument(
    '--wif',
    type=configargparse.FileType('r'),
    help=
    'An active WIF for account. The flag expects a path to a file. The environment variable REDEEMER_WIF will be checked for a literal WIF also.'
)
parser.add_argument('--log_level',
                    type=str,
                    default='INFO',
                    env_var="LOG_LEVEL")
parser.add_argument('--dry_run',
                    type=int,
                    default=1,
                    help='Set this to 0 to actually broadcast transactions',
                    env_var="DRY_RUN")
parser.add_argument(
    '--interval',
    type=int,