options package

Submodules

options.errors module

exception options.errors.UnrecognizedYamlConfigEntry(key: str)[source]

Bases: Warning

__init__(key: str) None[source]

options.opts module

class options.opts.ParseKwargs(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: Action

options.opts.arguments_common(parser: ArgumentParser) ArgumentParser[source]
options.opts.arguments_ddp(parser: ArgumentParser) ArgumentParser[source]
options.opts.parser_to_opts(parser: ArgumentParser, args: List[str] | None = None)[source]
options.opts.get_training_arguments(parse_args: bool | None = True, args: List[str] | None = None)[source]
options.opts.get_eval_arguments(parse_args=True, args: List[str] | None = None)[source]
options.opts.get_conversion_arguments(args: List[str] | None = None)[source]
options.opts.get_benchmarking_arguments(args: List[str] | None = None)[source]
options.opts.get_loss_landscape_args(args: List[str] | None = None)[source]

options.parse_args module

options.parse_args.parse_validation_metric_names(opts)[source]

This function contains common command-line parsing logic for validation metrics

class options.parse_args.JsonValidator(expected_type: type)[source]

Bases: object

__init__(expected_type: type)[source]

JsonValidator(T) is function (s)->x that parses json string s into python value x, where x is of type T.

Example Usage: >>> from typing import Union, List >>> import argparse >>> parser = argparse.ArgumentParser() >>> parser.add_argument(”–x”, type=JsonValidator(Union[int, List[float]])) >>> assert parser.parse_args([”–x=123”]).x == 123 >>> assert parser.parse_args([”–x=[1, 2]”]).x == [1., 2.]

options.utils module

options.utils.flatten_yaml_as_dict(d, parent_key='', sep='.')[source]
options.utils.load_config_file(opts)[source]
options.utils.extend_selected_args_with_prefix(parser: ArgumentParser, match_prefix: str, additional_prefix: str) ArgumentParser[source]

Helper function to select arguments with certain prefix and duplicate them with a replaced prefix. An example use case is distillation, where we want to add –teacher.model.* as a prefix to all –model.* arguments.

In that case, we provide the following arguments: * match_prefix=”–model.” * additional_prefix=”–teacher.model.”

Parameters:
  • match_prefix – Prefix to select arguments for duplication. The value should start with “–”, contain no underscores, and with “.”.

  • additional_prefix – Prefix to replace the @match_prefix in duplicated arguments. The value should start with “–”, contain no underscores, and with “.”.

options.utils.extract_opts_with_prefix_replacement(opts: Namespace, match_prefix: str, replacement_prefix: str) Namespace[source]

Helper function to extract a copy options with certain prefix and return them with an alternative prefix. An example usage is distillation, when we have used @extend_selected_args_with_prefix to add –teacher.model.*

arguments to argparser, and now we want to re-use the handlers of model.* opts by teacher.model.* opts

Parameters:
  • match_prefix – Prefix to select opts for extraction. The value should not contain dashes and should end with “.”

  • replacement_prefix – Prefix to replace the @match_prefix The value should not contain dashes and should end with “.”

Module contents