vllm_omni.utils.tracking_parser ¶
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 an arg to the parser & the shadow, where the latter has UNSET for the default.
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.
TrackingGroup ¶
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.
TrackingSubparsers ¶
Proxy that wraps a subparser and its corresponding shadow subparser.
add_parser ¶
Add a parser to the encapsulated real parser and its shadow.
build_shadow_kwargs ¶
Build kwargs for the shadow argument with an UNSET default.
Actions that mutate their default in place (append/extend/append_const/ count) would crash on the bare UNSET sentinel, so they are remapped to an equivalent store-style action; the shadow value only needs to flip away from UNSET when the arg is passed explicitly.