Skip to content

vllm_omni.utils.tracking_parser

UNSET module-attribute

UNSET = object()

TrackingArgumentParser

Bases: FlexibleArgumentParser

Drop-in replacement for FlexibleArgumentParser, which tracks keys that were explicitly passed as args on the parser namespace.

Unfortunately, Argparse does not provide an easy way of doing this without depending on a lot of internal attributes, so we implement it by instead using a 'shadow' parser, which is essentially a clone of the parser, where defaults are overridden to None. By comparing the parser against its shadow, we can tell which values were passed in a non-destructive manner.

add_argument

add_argument(*args: Any, **kwargs: Any) -> Action

Add an arg to the parser & the shadow, where the latter has UNSET for the default.

add_argument_group

add_argument_group(*args, **kwargs) -> TrackingGroup

add_mutually_exclusive_group

add_mutually_exclusive_group(
    *args, **kwargs
) -> TrackingGroup

add_subparsers

add_subparsers(*args, **kwargs) -> TrackingSubparsers

build_tracking_namespace

build_tracking_namespace(
    real_ns: Namespace, shadow_ns: Namespace
) -> TrackingNamespace

Build a tracking namespace for the real / shadow namespaces.

parse_args

parse_args(
    args: list[str] | None = None,
    namespace: Namespace | None = None,
) -> TrackingNamespace

Parse the args on the real/shadow parser.

parse_known_args

parse_known_args(
    args: list[str] | None = None,
    namespace: Namespace | None = None,
) -> tuple[TrackingNamespace, list[str]]

Parse the known args on the real/shadow parser.

TrackingGroup

Proxy that wraps an argument group and its corresponding shadow group.

add_argument

add_argument(*args: Any, **kwargs: Any) -> Action

Add an argument to the real group and to the shadow group.

TrackingNamespace

Bases: Namespace

Proxy that wraps an argparse namespace with explicit keys, which can be filtered down to a dict containing only explicitly passed values.

explicit_keys instance-attribute

explicit_keys = explicit_keys

unfiltered_ns instance-attribute

unfiltered_ns = unfiltered_ns

get_explicit_kwargs_dict

get_explicit_kwargs_dict()

Return a dict containing only the explicitly passed key-value pairs.

TrackingSubparsers

Proxy that wraps a subparser and its corresponding shadow subparser.

add_parser

add_parser(name, *args, **kwargs)

Add a parser to the encapsulated real parser and its shadow.