omni-us / jsonargparse

Implement minimal boilerplate CLIs derived from type hints and parse from command line, config files and environment variables
https://jsonargparse.readthedocs.io
MIT License
317 stars 44 forks source link

CLI fails with `torch.dtype` arguments #446

Closed ioangatop closed 7 months ago

ioangatop commented 7 months ago

🐛 Bug report

The CLI seems to not be able to handle torch.dtype arguments; pretty important for torchvision ToDtype transform.

To reproduce

Using the CLI:

# main.py
import torch
from jsonargparse import CLI

def interface(dtype: torch.dtype) -> None:
    print(f"dtype: {dtype} ({type(dtype)})")

CLI(interface)

Run with:

python3 main.py torch.float32

Expected behaviour:

The above to print:

dtype: torch.float32 (<class 'torch.dtype'>)

Environment

mauvilsa commented 7 months ago

Thank you for repointing! This should be fixed with the pull request that was just merged.