Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The error message when a factory is ill typed is still incorrect #60

Open
hemildesai opened this issue Sep 21, 2024 · 0 comments
Open

Comments

@hemildesai
Copy link
Collaborator

          Thanks for this, the error message when a factory is ill typed is still incorrect I believe. In the example below we get:

(repeats)

ERROR:nemo_run.cli.cli_parser:Error processing argument 'Error parsing argument: Failed to parse 'simple_recipe' as <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>: Unsupported type: <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>

But I would have expected the Unsupprted type message to say OtherCfg. Looking at the call stack it seems like the value in annotation is of the underlying entrypoing and not the return signature of the factory.

Expected:

ERROR:nemo_run.cli.cli_parser:Error processing argument 'Error parsing argument: Failed to parse 'simple_recipe' as <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>: Unsupported type: <class 'bionemo.geneformer.run.exploring_factories.OtherCfg'>

Simple example to reproduce:

factories.py

@dataclass
class SimpleCfg:
    field1: str
@dataclass 
class OtherCfg:
    field1: int

@run.cli.factory
@run.autoconvert
def simple_cfg_recipe() -> SimpleCfg:
    return SimpleCfg('1')
@run.cli.factory
@run.autoconvert
def other_cfg_recipe() -> OtherCfg:
    return OtherCfg(1)

@run.cli.entrypoint
def simple_entry(simple_cfg: SimpleCfg):
    print(simple_cfg)

main.py

if __name__ == "__main__":
    run.cli.main(simple_entry)
python main.py simple_cfg=other_cfg_recipe

bionemo@131abe601699:/workspaces/bionemo-fw-ea$ python sub-packages/bionemo-geneformer/src/bionemo/geneformer/run/test3.py simple_cfg=other_cfg_recipe.py
ERROR:nemo_run.cli.cli_parser:Error processing argument 'Error parsing argument: Failed to parse 'other_cfg_recipe.py' as <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>: Unsupported type: <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'> (Argument: other_cfg_recipe.py, Context: {'expected_type': <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>})': Failed to parse 'Error parsing argument: Failed to parse 'other_cfg_recipe.py' as <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>: Unsupported type: <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'> (Argument: other_cfg_recipe.py, Context: {'expected_type': <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>})' as simple_cfg=other_cfg_recipe.py: {'key': 'simple_cfg', 'value': 'other_cfg_recipe.py', 'expected_type': <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>} (Argument: Error parsing argument: Failed to parse 'other_cfg_recipe.py' as <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>: Unsupported type: <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'> (Argument: other_cfg_recipe.py, Context: {'expected_type': <class 'bionemo.geneformer.run.exploring_factories.SimpleCfg'>}), Context: {'expected_type': 'simple_cfg=other_cfg_recipe.py'})

Originally posted by @skothenhill-nv in #56 (comment)

@hemildesai hemildesai changed the title The error message when a factory is ill typed is still incorrect incorrect I The error message when a factory is ill typed is still incorrect Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant