Skip to content

CLI fails with torch.dtype arguments #446

@ioangatop

Description

@ioangatop

🐛 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

  • jsonargparse version (e.g., 4.8.0):
  • Python version (e.g., 3.9):
  • How jsonargparse was installed (e.g. pip install jsonargparse[all]):
  • OS (e.g., Linux):

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions