Package: jsonargparse
jsonargparseDocs:https://jsonargparse.readthedocs.io/| Source:https://github.com/omni-us/jsonargparse/jsonargparseis a library for creating command-line interfaces (CLIs) and
making Python apps easily configurable. It is a well-maintained project with
frequent releases, adhering to high standards of development: semantic
versioning, deprecation periods, changelog, automated testing, and full test
coverage.Althoughjsonargparsemight not be widely recognized yet, it already boasts
asubstantial user base. Most notably,
it serves as the framework behind pytorch-lightning’sLightningCLI.Featuresjsonargparseis user-friendly and encourages the development ofclean,
high-quality code. It encompasses numerous powerful features, some unique tojsonargparse, while also combining advantages found in similar packages:Automaticcreation of CLIs, likeFire,Typer,ClizeandTyro.Usetype hintsfor argument validation, likeTyper,TapandTyro.Use ofdocstringsfor automatic generation of help, likeTap,TyroandSimpleParsing.Parse fromconfiguration filesandenvironment variables, likeOmegaConf,dynaconf,confuseandconfigargparse.Dataclassessupport, likeSimpleParsingandTyro.Other notable features include:Extensive type hint support:nested types (union, optional), containers
(list, dict, etc.), user-defined generics, restricted types (regex, numbers),
paths, URLs, types from stubs (*.pyi), future annotations (PEP563), and backports (PEPs604/585).Keyword arguments introspection:resolving of parameters used via**kwargs.Dependency injection:support types that expect a class instance and
callables that return a class instance.Structured configs:parse config files with more understandable non-flat
hierarchies.Config file formats:json,yaml,jsonnetand extendible to
more formats.Relative paths:within config files and parsing of config paths referenced
inside other configs.Argument linking:directing parsed values to multiple parameters,
preventing unnecessary interpolation in configs.Design principlesNon-intrusive/decoupled:There is no requirement for unrelated modifications throughout a codebase,
maintaining theseparation of concerns principle. In simpler terms,
changes should make sense even without the CLI. No need to inherit from a
special class, add decorators, or use CLI-specific type hints.Minimal boilerplate:A recommended practice is to write code with function/class parameters having
meaningful names, accurate type hints, and descriptive docstrings. Reuse these
wherever they appear to automatically generate the CLI, following thedon’t
repeat yourself principle. A notable
advantage is that when parameters are added or types changed, the CLI will
remain synchronized, avoiding the need to update the CLI’s implementation.Dependency injection:Using as type hint a class or a callable that instantiates a class, a practice
known asdependency injection, is a sound design
pattern for developing loosely coupled and highly configurable software. Such
type hints should be supported with minimal restrictions.InstallationYou can install usingpipas:pipinstalljsonargparseBy default the only dependency that jsonargparse installs isPyYAML. However, several optional features can be
enabled by specifying any of the following extras requires:signatures,jsonschema,jsonnet,urls,fsspec,ruyaml,omegaconfandargcomplete. There is also theallextras require to enable all optional
features. Installing jsonargparse with extras require is as follows:pipinstall"jsonargparse[signatures,urls]"# Enable signatures and URLs featurespipinstall"jsonargparse[all]"# Enable all optional features