TypedArgs
Strong type args.
Install
From pypi
pip install typed-args
From github
pip install git+https://github.com/SunDoge/typed-args.git@v0.3
Usage
from dataclasses import dataclass
from typed_args import TypedArgs, add_argument
@dataclass
class Args(TypedArgs):
data: str = add_argument('data', metavar='DIR', help='path to dataset')
arch: str = add_argument('-a', '--arch', metavar='ARCH', default='resnet18',
help='model architecture (default: resnet18)')
num_workers: int = add_argument('-j', '--workers', default=4, metavar='N',
help='number of data loading workers (default: 4)')
def test_args():
data = '/path/to/dataset'
arch = 'resnet50'
num_workers = 8
argv = f'{data} -a {arch} --workers {num_workers}'.split()
args = Args.from_args(argv)
assert args.arch == arch
assert args.data == data
assert args.num_workers == num_workers
if __name__ == "__main__":
test_args()
Release files for typed-args 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| typed-args-0.3.1.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| typed_args-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / typed-args-0.3.1.tar.gz
| Download URL | typed-args-0.3.1.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ee11b875dc082bb3eec791eb775e59b1488fa6296822a7bef23d8f3f9095f1e
|
|
BLAKE2b-256 checksum How to use checksums |
f2698d4670b30c7954c6651d1342262c1904e279323227c8ce124780dac12ee1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.6
|
Release files / typed_args-0.3.1-py3-none-any.whl
| Download URL | typed_args-0.3.1-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
baa324462377070625b180391f35f2dbd1fb66697054ff3aaf8ff978c37995aa
|
|
BLAKE2b-256 checksum How to use checksums |
f1d8bf8ab7cd8d64c1969803e5905bfc43eb0669a1827c16c51de518ca872ae2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.6
|