Пример #1
0
def parse_args(parser: argparse, config: Config):
    """Parse the programme arguments
    :param config:
    :param parser:
    :return: arguments
    """
    location_help = r"""location specifying the start point to scan to recursively hash files.
                        May also be a single file. 
                        """
    report_location_help = r"""location specifying the csv report file in which to write results. """

    parser.add_argument('scan_location',
                        help=location_help)

    parser.add_argument('-report', '--report',
                        default=config.report,
                        required=False,
                        help=report_location_help)

    args = parser.parse_args()
    logging.debug(str(args))
    return args
Пример #2
0
def add_parser_option(parser: argparse,
                      short_name: str = '',
                      full_name: str = '',
                      **kwargs):
    """
    Add a new option to the Parser.

    This function allows us to add a new option to the argument parser. This
    allows for every module with an entry point to set up its own set of
    arguments for multi-module startup.

    Args:
        parser (argparse): The parser we are adding the new option to.
        short_name (str): The short name of the command line flag. e.g. '-f'.
        full_name (str): The fully descriptive command line flag e.g. '--foo'.
        **kwargs: The optional parameters that will be added to the parser.
          see cref: https://github.com/python/cpython/blob/3.7/Lib/argparse.py.

    """
    if short_name and full_name:
        parser.add_argument(short_name, full_name, **kwargs)
    else:
        parser.add_argument(full_name, **kwargs)
Пример #3
0
def aws_parser_arguments(aws_parser: argparse) -> argparse:
    aws_parser.add_argument("--access_key",
                            type=str,
                            required=False,
                            help="Access key of the AWS account")
    aws_parser.add_argument("--secret_key",
                            type=str,
                            required=False,
                            help="Secret key of the AWS account")
    aws_parser.add_argument("--account_id",
                            type=str,
                            required=False,
                            help="Account ID of the AWS account")
    aws_parser.add_argument("--region",
                            type=str,
                            required=False,
                            help="Region of the AWS account")
    return aws_parser
Пример #4
0
    def add_parser(self, parser: argparse):
        # pylint: disable=protected-access
        parser.add_argument('archive_file',
                            type=str,
                            help='path to an archived trained model')

        parser.add_argument(
            'input_file',
            type=str,
            help='path to the file containing the evaluation data')

        parser.add_argument('--output-file',
                            type=str,
                            help='path to output file')

        parser.add_argument(
            '--weights-file',
            type=str,
            help='a path that overrides which weights file to use')

        cuda_device = parser.add_mutually_exclusive_group(required=False)
        cuda_device.add_argument('--cuda-device',
                                 type=int,
                                 default=-1,
                                 help='id of GPU to use (if any)')

        parser.add_argument(
            '-t',
            '--thresholds',
            type=str,
            default="0",
            help=
            'A comma (,) or underscore (_) separated list of temperature thresholds to consider'
        )

        parser.add_argument(
            '-o',
            '--overrides',
            type=str,
            default="",
            help=
            'a JSON structure used to override the experiment configuration')

        parser.add_argument(
            '--batch-weight-key',
            type=str,
            default="",
            help=
            'If non-empty, name of metric used to weight the loss on a per-batch basis.'
        )

        parser.add_argument(
            '--extend-vocab',
            action='store_true',
            default=False,
            help=
            'if specified, we will use the instances in your new dataset to '
            'extend your vocabulary. If pretrained-file was used to initialize '
            'embedding layers, you may also need to pass --embedding-sources-mapping.'
        )

        parser.add_argument(
            '--embedding-sources-mapping',
            type=str,
            default="",
            help=
            'a JSON dict defining mapping from embedding module path to embedding'
            'pretrained-file used during training. If not passed, and embedding needs to be '
            'extended, we will try to use the original file paths used during training. If '
            'they are not available we will use random vectors for embedding extension.'
        )
        parser.add_argument('--include-package',
                            type=str,
                            action='append',
                            default=[],
                            help='additional packages to include')
        parser.set_defaults(func=evaluate_from_args)