MLSysOps / MLE-agent

MLE-Agent is designed to be a pair coding agent for machine learning engineers and researchers. Support OpenAI and Ollama.
MIT License
16 stars 1 forks source link

KeyError: 'search_engine' not in the config. #56

Closed huangyz0918 closed 4 weeks ago

huangyz0918 commented 1 month ago
(mle) ➜  MLE-agent git:(feat/web) mle start
[23:30:34] Step 1: User requirements             tech_leader.py:85
           understanding
           User Requirement: I want to train a   tech_leader.py:87
           sentiment analysis model using csv
           data
           Step 2: Data quick review            tech_leader.py:102
           Data source:                         tech_leader.py:121
           /Users/huangyz0918/desktop/archive/T
           est.csv
           Dataset examples:                    tech_leader.py:124
           text  label
           0  I always wrote this series off as
           being a comp...      0
           1  1st watched 12/7/2002 - 3 out of
           10(Dir-Steve ...      0
           2  This movie was so poorly written
           and directed ...      0
           Step 3: Task & Model selection       tech_leader.py:129
           Step 5: Code generation              tech_leader.py:188
[23:30:37] Will install the following dependencies: ['pandas', 'torch',    setup_agent.py:64
           'torchmetrics', 'transformers', 'wandb']
? Are you sure to install the dependencies? No
[23:30:41] Skipped the dependencies installation.                          setup_agent.py:71
[23:30:41] Step 6: Code execution and reflection                          tech_leader.py:199
Running command: python sentiment_analysis_model_training.py
Error: Traceback (most recent call last):
Error:   File "/Users/huangyz0918/Desktop/test3/sentiment_analysis_model_training.py", line
3, in <module>
Error:     import torch
Error: ModuleNotFoundError: No module named 'torch'
Traceback (most recent call last):
  File "/Users/huangyz0918/miniconda3/envs/mle/bin/mle", line 33, in <module>
    sys.exit(load_entry_point('mle-agent', 'console_scripts', 'mle')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/huangyz0918/miniconda3/envs/mle/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/huangyz0918/miniconda3/envs/mle/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/huangyz0918/miniconda3/envs/mle/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/huangyz0918/miniconda3/envs/mle/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/huangyz0918/miniconda3/envs/mle/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/huangyz0918/Desktop/MLE-agent/agent/cli.py", line 137, in start
    chain.start()
  File "/Users/huangyz0918/Desktop/MLE-agent/agent/function/tech_leader.py", line 201, in start
    code_reflection_agent.invoke(self.requirement)
  File "/Users/huangyz0918/Desktop/MLE-agent/agent/function/reflect_agent.py", line 87, in invoke
    search_agent = SearchAgent(enable_web_search)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/huangyz0918/Desktop/MLE-agent/agent/function/search_agent.py", line 22, in __init__
    self.engine_name = config_dict['general']['search_engine']
                       ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'search_engine'

My old config doesn't has this field, it is not safe to directly get this value.

Try to check if this is None and then do something, or use config_dict['general'].get('search_engine')

HuaizhengZhang commented 1 month ago

sure

HuaizhengZhang commented 4 weeks ago

actually. this bug will only be shown for users already have a config file.

for those new users, we do a lot of validation for search engine.

adding this will make our code a little redundancy. But anyway, we add if-else code here for now.