fidelity / spock

spock is a framework that helps manage complex parameter configurations during research and development of Python applications
https://fidelity.github.io/spock/
Apache License 2.0
121 stars 13 forks source link

Spock seems to be unusable, when running inside a jupyter notebook. #291

Closed mburges-cvl closed 1 year ago

mburges-cvl commented 1 year ago

Describe the bug

When loading a trained model together with a Spock config an error is thrown:

usage: ipykernel_launcher.py [-c CONFIG [CONFIG ...]] [-h] [--ModelConfig.save_path MODELCONFIG.SAVE_PATH] [--ModelConfig.lr MODELCONFIG.LR] pykernel_launcher.py: error: unrecognized arguments: --ip=127.0.0.1 --stdin=9028 ...

To Reproduce Steps to reproduce the behavior: Load config inside of a jupyter notebook:

config = SpockBuilder(ModelConfig, desc='Quick start example').save(file_name='config', file_extension='.yaml', create_save_path=True).generate() args = config.ModelConfig

--> Results in error.

Expected behavior The command line should probably be ignored inside a jupyter notebook.

Environment (please complete the following information):

Is this expected behavior? How could I circumvent this problem?

ncilfone commented 1 year ago

You need to use the no_cmd_line flag in the SpockBuilder (https://fidelity.github.io/spock/reference/builder#__init__) since ipython takes args and those clash with the ones that spock automatically creates

See here: https://fidelity.github.io/spock/advanced_features/Keyword-Configs#specifying-the-config-keyword-argument--the-no-command-line-flag

mburges-cvl commented 1 year ago

Perfect, it works. Thank you very much 👍