Skip to main content

No project description provided

Project description

PAI Argument Parser

The PAI Argument Parser extends the common python argument parser by allowing to automatically parse and add arguments based on dataclasses.

See the following example for usage:

Simple Example

from typing import List
from paiargparse import pai_dataclass, pai_meta, PAIArgumentParser
from dataclasses import dataclass, field

@pai_dataclass
@dataclass
class SubmoduleParams:
    required_float_arg: float
    list_arg: List[int] = field(default_factory=lambda: [1, 2])
    arg_with_custom_help: str = field(default="You can specify a custom help string", metadata=pai_meta(
        help="Custom help string."
    ))

@pai_dataclass
@dataclass
class MyArguments:
    required_int_arg: int
    optional_str_arg: str = "This is cool stuff"
    sub_params: SubmoduleParams = field(default_factory=lambda: SubmoduleParams(required_float_arg=2))


if __name__ == "__main__":
    parser = PAIArgumentParser()
    parser.add_root_argument("myArgs", MyArguments)
    args = parser.parse_args()

Call with

python my_program.py --myArgs.required_int_arg 1 --myArgs.sub_params.required_float_arg 0.1

Other Features

  • Changing of dataclasses to select different modules
  • Default params from initial value

See examples and tests for a bunch of different settings and scenarios.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paiargparse-1.0.3.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paiargparse-1.0.3-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file paiargparse-1.0.3.tar.gz.

File metadata

  • Download URL: paiargparse-1.0.3.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for paiargparse-1.0.3.tar.gz
Algorithm Hash digest
SHA256 747f48ac7dec00a2a251b3176c88de7cf615a70cdc96d2fbf08e16cefaaf382c
MD5 f3f87bacf2998f5aaedb0d7c1a7c9140
BLAKE2b-256 1c6a8df15d82bd70a43003bebc64c25c3f0b5b562b64ae51a8825d356de7cf05

See more details on using hashes here.

File details

Details for the file paiargparse-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: paiargparse-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for paiargparse-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6924f22f3ded3c50365cc964573496c1df66b69896ccf7f7010532972dc5ae7a
MD5 6cec291b8d76be2684f70b61f274d0f7
BLAKE2b-256 fad03825566e4c0b3086a1bfa7e4541a50ef38cac88803b0aec6ba83004287a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page