Created
February 24, 2023 11:47
-
-
Save drazendee/7b19a8659caea3d3f6c07f607bc42445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import valohai_yaml | |
import sys | |
import pyaml | |
import yaml | |
import pathlib | |
from valohai_yaml.objs import Step, Parameter, Config | |
params = [] | |
for yaml_fn in pathlib.Path("yaml_files").glob("*.yaml"): | |
with open(yaml_fn) as f: | |
data = yaml.safe_load(f) | |
for key, value in data.items(): | |
if isinstance(value, int): | |
params.append(Parameter(name=key, type="integer", default=value, multiple_separator='\',\'')) | |
elif isinstance(value, float): | |
params.append(Parameter(name=key, type="float", default=value, multiple_separator='\',\'')) | |
elif isinstance(value, str): | |
params.append(Parameter(name=key, type="string", default=value, multiple_separator='\',\'')) | |
elif isinstance(value, bool): | |
params.append(Parameter(name=key, type="flag", default=value)) | |
elif isinstance(value, list): | |
if not value: | |
params.append(Parameter(name=key, type="string", default="", multiple_separator='\',\'', multiple="separate")) | |
else: | |
params.append(Parameter(name=key, type="string", default=','.join([str(i) for i in value]), multiple_separator='\',\'', multiple="separate")) | |
else: | |
print(f'Skipping Key {key} Value: {value}') | |
step = Step( | |
name="test", | |
parameters=params, | |
image="python:3.9", | |
command="- python tf_train_model_template.py", | |
) | |
config = Config(steps=[step]) | |
with open(r'valohai.yaml', 'w') as file: | |
pyaml.dump(config.serialize(), file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment