cheapvs_llm / utils /parse_config.py
sangttruong's picture
add data
27dc10f
raw
history blame contribute delete
683 Bytes
# """Command line argument parser for configuration files.
# Converts YAML config file key-value pairs into command line arguments.
# """
import sys
import yaml
# Load the YAML configuration file
config_file = sys.argv[1]
with open(config_file) as f:
config = yaml.safe_load(f)
args = []
for key, value in config.items():
if isinstance(value, bool):
# Include boolean flags only if they are True
if value:
args.append(f"--{key}")
elif value is not None:
# Include other key-value pairs
args.append(f"--{key}")
args.append(str(value))
# Print the generated arguments as a space-separated string
print(" ".join(args))