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

Raise cli errors with full stack trace #56

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

hemildesai
Copy link
Collaborator

No description provided.

@skothenhill-nv
Copy link

skothenhill-nv commented Sep 20, 2024

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'})

@hemildesai
Copy link
Collaborator Author

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

Thanks for the detailed report, we'll work on fixing this in a subsequent PR. I've created an issue for it at #60

@ethanhe42
Copy link
Member

thanks! verified on my side it works well.

@hemildesai hemildesai merged commit ec614ea into main Sep 23, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

4 participants