ludwig-ai / ludwig

Low-code framework for building custom LLMs, neural networks, and other AI models
http://ludwig.ai
Apache License 2.0
11.22k stars 1.19k forks source link

Getting `ValueError: Hyperopt Section not present in config` while loading hyperopt from YAML config #3850

Closed mohangk closed 10 months ago

mohangk commented 11 months ago

Description

The code in https://github.com/ludwig-ai/ludwig/blob/7e34450188f1265e6cd9cbda600dc0a605627099/ludwig/hyperopt/run.py#L208 seems to have a bug where its comparing if the HYPEROPT key is contained in the variable config - which is actually a string that contains the path to the config file. I believe the original intention was to compare it with config_dict

To Reproduce

#hyperopt.py
from ludwig.hyperopt.run import hyperopt
import pandas

df = pandas.read_csv('./rotten_tomatoes.csv')
results = hyperopt(config='./rotten_tomatoes.yaml', dataset=df)

Running the above results in the following error: The rottent_tomatoes.csv and rotten_tomatoes.yaml file is as per the tutorial here https://ludwig.ai/latest/getting_started/hyperopt/

$ python hyperopt.py
Traceback (most recent call last):
  File "/Users/mohan.krishnan/Workspace/autotrain/hyperopt.py", line 12, in <module>
    results = hyperopt(config='./rotten_tomatoes.yaml', dataset=df)
  File "/Users/mohan.krishnan/Workspace/autotrain/env/lib/python3.10/site-packages/ludwig/hyperopt/run.py", line 209, in hyperopt
    raise ValueError("Hyperopt Section not present in config")
ValueError: Hyperopt Section not present in config

Expected behavior The config is correctly parsed without the exception being thrown

Environment:

arnavgarg1 commented 10 months ago

Hey @mohangk! Thanks for reporting this issue - you are right that this is a typo overlooked by us and we should be checking for the hyperopt section of the config in config_dict as opposed to config.

I've created this PR to patch this issue. Are you able to confirm that with this fix, things work as expected? https://github.com/ludwig-ai/ludwig/pull/3865