NVIDIA / NeMo-Run

A tool to configure, launch and manage your machine learning experiments.
Apache License 2.0
78 stars 20 forks source link

[BUG] Using the shorthand union type operator `|` in entrypoint type signatures causes universal failures on parsing. #64

Open skothenhill-nv opened 2 months ago

skothenhill-nv commented 2 months ago

Using the union type operator in entrypoint type signatures causes universal failures on parsing.

@run.cli.entrypoint
def simple_example(
    this_or_that: str | int 
):
   print(this_or_that) 
$> python main.py this_or_that='asdf'
$> UnknownTypeError: Failed to parse 'Error parsing argument: Failed to parse 'asdf' as str | int: Unsupported type: str | int (Argument: asdf, Context: {'expected_type': str | 
int})' as this_or_that=asdf: {'key': 'this_or_that', 'value': 'asdf', 'expected_type': str | int} (Argument: Error parsing argument: Failed to parse 'asdf' as str | int: 
Unsupported type: str | int (Argument: asdf, Context: {'expected_type': str | int}), Context: {'expected_type': 'this_or_that=asdf'})

On the contrary, using Union to achieve the same signature does not fail:

@run.cli.entrypoint
def simple_example(
    this_or_that: Union[str, int]
):
   print(this_or_that) 

(omitted outputs, works as expected)