Skip to content

Commit

Permalink
Merge pull request MLSysOps#221 from leeeizhang/lei/fix-yml-load
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyz0918 authored Sep 24, 2024
2 parents 54b7a3e + 909bdda commit d721f10
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions mle/utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,20 @@ def check_config(console: Optional[Console] = None):
os.makedirs(config_dir, exist_ok=True)
shutil.move(old_config_path, config_path)

if not os.path.exists(config_path):
try:
with open(config_path, 'r') as file:
data = yaml.safe_load(file)
if data is None:
raise yaml.YAMLError
except FileNotFoundError:
console.log("Configuration file not found. Please run 'mle new' first.")
return False
except yaml.YAMLError:
console.log("Configuration file could not be loaded.")
return False

with open(config_path, 'r') as file:
data = yaml.safe_load(file)
if data.get('search_key'):
os.environ["SEARCH_API_KEY"] = data.get('search_key')

if data.get('search_key'):
os.environ["SEARCH_API_KEY"] = data.get('search_key')
return True


Expand Down

0 comments on commit d721f10

Please sign in to comment.