@@ -974,27 +974,41 @@ def add_command_line_options(args_string):
974974 return ""
975975
976976
977- def add_additional_env_to_yaml (env_vars_string ) :
977+ def add_additional_env_to_yaml (env_vars_string : str ) -> str :
978978 """
979979 Generate additional environment variables YAML.
980980 Equivalent to the bash add_additional_env_to_yaml function.
981+
982+ Args:
983+ env_vars_string (str): Comma separated list of environment variable
984+ names to be converted to name/value pairs OR a path to a file
985+ containing a YAML snippet to be indented but otherwise not
986+ interpreted.
987+
988+ Returns:
989+ str: YAML snippet to be inserted to YAML template.
981990 """
982- if not env_vars_string :
983- return ""
984991
985992 # Determine indentation based on environment type
986993 standalone_active = int (os .environ .get ("LLMDBENCH_CONTROL_ENVIRONMENT_TYPE_STANDALONE_ACTIVE" , 0 ))
987994 modelservice_active = int (os .environ .get ("LLMDBENCH_CONTROL_ENVIRONMENT_TYPE_MODELSERVICE_ACTIVE" , 0 ))
988995
989996 if standalone_active == 1 :
990- name_indent = " " # 8 spaces
991- value_indent = " " # 10 spaces
997+ name_indent = " " * 8
998+ value_indent = " " * 10
992999 elif modelservice_active == 1 :
993- name_indent = " " # 6 spaces
994- value_indent = " " # 8 spaces
1000+ name_indent = " " * 6
1001+ value_indent = " " * 8
9951002 else :
996- name_indent = " " # default 8 spaces
997- value_indent = " " # default 10 spaces
1003+ name_indent = " " * 8
1004+ value_indent = " " * 10
1005+
1006+ if os .access (env_vars_string , os .R_OK ):
1007+ lines = []
1008+ with open (env_vars_string , 'r' ) as file :
1009+ for line in file :
1010+ lines .append (name_indent + line .rstrip ())
1011+ return '\n ' .join (lines )
9981012
9991013 # Parse environment variables (comma-separated list)
10001014 env_lines = []
0 commit comments