You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am sharing below some very naive code from chatgpt. I am not suggesting that. just adding here as reference. Myabe it would be good to have a class for each version of spec, where we will define the structure for the spec and a function that will check if the config is in the correct structure .. otherwise it should return an error point where the problem is located.
import yaml
def verify_makim_yaml(file_path):
with open(file_path) as f:
makim_data = yaml.safe_load(f)
version = makim_data.get('version')
if version != '1.0.0':
raise ValueError('Incorrect version')
env_file = makim_data.get('env-file')
if env_file is not None and not isinstance(env_file, str):
raise TypeError('env-file must be a string')
groups = makim_data.get('groups')
if not isinstance(groups, list):
raise TypeError('groups must be a list')
for group in groups:
name = group.get('name')
if name is None or not isinstance(name, str):
raise ValueError('Group name must be a non-empty string')
targets = group.get('targets')
if targets is None or not isinstance(targets, dict):
raise ValueError(f'{name}: targets must be a dictionary')
for target_name, target in targets.items():
if not isinstance(target, dict):
raise ValueError(f'{name}/{target_name}: target definition must be a dictionary')
help_text = target.get('help')
if help_text is not None and not isinstance(help_text, str):
raise ValueError(f'{name}/{target_name}: help text must be a string')
run_command = target.get('run')
if not isinstance(run_command, str):
raise ValueError(f'{name}/{target_name}: run command must be a string')
dependencies = target.get('dependencies')
if dependencies is not None and not isinstance(dependencies, list):
raise ValueError(f'{name}/{target_name}: dependencies must be a list')
env_vars = target.get('env')
if env_vars is not None and not isinstance(env_vars, dict):
raise ValueError(f'{name}/{target_name}: env must be a dictionary')
args = target.get('args')
if args is not None and not isinstance(args, dict):
raise ValueError(f'{name}/{target_name}: args must be a dictionary')
if args is not None:
for arg_name, arg_data in args.items():
if not isinstance(arg_data, dict):
raise ValueError(f'{name}/{target_name}/{arg_name}: arg definition must be a dictionary')
arg_help_text = arg_data.get('help')
if arg_help_text is not None and not isinstance(arg_help_text, str):
raise ValueError(f'{name}/{target_name}/{arg_name}: arg help text must be a string')
arg_type = arg_data.get('type')
if arg_type is not None and not isinstance(arg_type, str):
raise ValueError(f'{name}/{target_name}/{arg_name}: arg type must be a string')
arg_default = arg_data.get('default')
if arg_default is not None and not isinstance(arg_default, (str, bool, int, float)):
raise ValueError(f'{name}/{target_name}/{arg_name}: arg default value must be a string, boolean, integer, or float')
arg_action = arg_data.get('action')
if arg_action is not None and not isinstance(arg_action, str):
raise ValueError(f'{name}/{target_name}/{arg_name}: arg action must be a string')
# check if arg dependencies are valid
arg_deps = arg_data.get('dependencies')
if arg_deps is not None and not isinstance(arg_deps, list):
raise ValueError(f'{
The text was updated successfully, but these errors were encountered:
I am sharing below some very naive code from chatgpt. I am not suggesting that. just adding here as reference. Myabe it would be good to have a class for each version of spec, where we will define the structure for the spec and a function that will check if the config is in the correct structure .. otherwise it should return an error point where the problem is located.
The text was updated successfully, but these errors were encountered: