Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Argparse HParams

A simple argument parser for hyper-parameters.

Installation

From PyPI:

pip install argparse-hparams

From Github:

pip install git+https://github.com/enhuiz/argparse-hparams.git

Example

from argparse_hparams import dataclass, HParams, Annotated, Flag


@dataclass
class HParamsTest(HParams):
    # This will call: parser.add_argument(type=int, default=0)
    x: int = 0

    # You may annotate custom data for parser.add_argument(...).
    # The annotated default will overwrite dataclass default
    # This will call: parser.add_argument(type=str.upper, default='bad')
    y: Annotated[str, dict(type=str.upper, default="bad")] = "good"

    # This will call: parser.add_argument(type=int, nargs=2, default=(2, 3))
    pair: Annotated[tuple[int, int], dict(type=int, nargs=2)] = (2, 3)

    # This will call: parser.add_argument(action="store_true", default=False)
    ok: Flag = False


if __name__ == "__main__":
    test = HParamsTest()
    test.show()
$ python example.py
┌────────────┐
│ Arguments  │
├────────────┤
│x: 0        │
│y: BAD      │
│pair: (2, 3)│
│ok: False   │
└────────────┘

$ python example.py --default default.yml 
┌────────────┐
│ Arguments  │
├────────────┤
│x: 0        │
│y: 1        │
│pair: [4, 5]│
│ok: False   │
└────────────┘

$ python example.py --help
usage: example.py [-h] [--x int] [--y upper] [--pair int int] [--ok] [--default Path]

optional arguments:
  -h, --help      show this help message and exit
  --x int         x (default: 0)
  --y upper       y (default: bad)
  --pair int int  pair (default: (2, 3))
  --ok            ok (default: False)
  --default Path  A YAML configuration file that overrides the defaults (default: None)

Metadata

Release files for argparse-hparams 0.0.1.dev20211127192230

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for argparse-hparams 0.0.1.dev20211127192230
File Size Uploaded Provenance Actions
argparse-hparams-0.0.1.dev20211127192230.tar.gz 5.0 kB Without provenance Details for argparse-hparams-0.0.1.dev20211127192230.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for argparse-hparams 0.0.1.dev20211127192230
File Interpreter ABI Platform Actions
argparse_hparams-0.0.1.dev20211127192230-py3-none-any.whl Python 3 none any Details for argparse_hparams-0.0.1.dev20211127192230-py3-none-any.whl

Total release size: 10.9 kB

Release files / argparse-hparams-0.0.1.dev20211127192230.tar.gz

Download URL argparse-hparams-0.0.1.dev20211127192230.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
806cae6a115ac1e22da5512003f6fa42ed2c13856c4cd56d115df41788d4b7d8
BLAKE2b-256 checksum
How to use checksums
66c713f2784b6a971083fcd882aeeeac839c980083ac47d1547e0911c5d503c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release files / argparse_hparams-0.0.1.dev20211127192230-py3-none-any.whl

Download URL argparse_hparams-0.0.1.dev20211127192230-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c40b625fc2e325e7ab1ee6f84f1bd2cba8cb0c6a5dc0d146d8e682a9c8b222f4
BLAKE2b-256 checksum
How to use checksums
1a2aa4aea698dd14faf8c43e452c0fa4d4cbba5c391a395f7abdbd2b7f140025
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Security for argparse-hparams 0.0.1.dev20211127192230

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page