@@ -504,6 +504,9 @@ def _run(self, i):
504504 env [key ] = os .environ [key ]
505505
506506 r = self ._update_env_from_input (env , i )
507+ if env .get ('MLC_OUTDIRNAME' , '' ) != '' :
508+ if not os .path .isabs (env ['MLC_OUTDIRNAME' ]):
509+ env ['MLC_OUTDIRNAME' ] = os .path .abspath (env ['MLC_OUTDIRNAME' ])
507510
508511 #######################################################################
509512 # Check if we want to skip cache (either by skip_cache or by fake_run)
@@ -796,6 +799,7 @@ def _run(self, i):
796799 run_state ['script_repo_git' ] = script_item .repo .meta .get (
797800 'git' , False )
798801 run_state ['cache' ] = meta .get ('cache' , False )
802+ run_state ['cache_expiration' ] = meta .get ('cache_expiration' , False )
799803
800804 if not recursion :
801805 run_state ['script_entry_repo_to_report_errors' ] = meta .get (
@@ -1748,12 +1752,7 @@ def _run(self, i):
17481752
17491753 tmp_curdir = os .getcwd ()
17501754 if env .get ('MLC_OUTDIRNAME' , '' ) != '' :
1751- if os .path .isabs (env ['MLC_OUTDIRNAME' ]) or recursion :
1752- c_outdirname = env ['MLC_OUTDIRNAME' ]
1753- else :
1754- c_outdirname = os .path .join (
1755- env ['MLC_TMP_CURRENT_PATH' ], env ['MLC_OUTDIRNAME' ])
1756- env ['MLC_OUTDIRNAME' ] = c_outdirname
1755+ c_outdirname = env ['MLC_OUTDIRNAME' ]
17571756
17581757 if not fake_run : # prevent permission error inside docker runs
17591758 if not os .path .exists (c_outdirname ):
@@ -2041,6 +2040,10 @@ def _run(self, i):
20412040 cached_path , dependent_cached_path ):
20422041 cached_meta ['dependent_cached_path' ] = dependent_cached_path
20432042
2043+ if run_state .get ('cache_expiration' ): # convert to seconds
2044+ cached_meta ['cache_expiration' ] = parse_expiration (
2045+ run_state ['cache_expiration' ])
2046+
20442047 ii = {'action' : 'update' ,
20452048 'target' : 'cache' ,
20462049 'uid' : cached_uid ,
@@ -3151,9 +3154,8 @@ def native_run(self, i):
31513154 if os .name == 'nt' :
31523155 script .append ('set ' + k + '=' + v )
31533156 else :
3154- if ' ' in v :
3155- v = '"' + v + '"'
3156- script .append ('export ' + k + '=' + v )
3157+ safe_v = quote_if_needed (v )
3158+ script .append ('export ' + k + '=' + safe_v )
31573159
31583160 script .append ('' )
31593161
@@ -4836,13 +4838,19 @@ def find_cached_script(i):
48364838
48374839 for cached_script in found_cached_scripts :
48384840 skip_cached_script = False
4841+ dependent_paths = []
48394842 dependent_cached_path = cached_script .meta .get (
4840- 'dependent_cached_path' , '' )
4843+ 'dependent_cached_path' )
48414844 if dependent_cached_path :
4845+ dependent_paths .append (dependent_cached_path )
4846+ dependent_cached_paths = cached_script .meta .get (
4847+ 'dependent_cached_paths' , '' ).split (':' )
4848+ dependent_paths += [p for p in dependent_cached_paths if p ]
4849+ for dep in dependent_paths :
48424850 if not os .path .exists (dependent_cached_path ):
48434851 # TODO Need to restrict the below check to within container
48444852 # env
4845- i ['tmp_dep_cached_path' ] = dependent_cached_path
4853+ i ['tmp_dep_cached_path' ] = dep
48464854 from script import docker_utils
48474855 r = docker_utils .get_container_path_script (i )
48484856 if not os .path .exists (r ['value_env' ]):
@@ -4851,7 +4859,10 @@ def find_cached_script(i):
48514859 recursion_spaces +
48524860 ' - Skipping cached entry as the dependent path {} is missing!' .format (r ['value_env' ]))
48534861 skip_cached_script = True
4854- continue
4862+ break
4863+
4864+ if skip_cached_script :
4865+ continue
48554866
48564867 os_info = self_obj .os_info
48574868
@@ -5047,7 +5058,7 @@ def update_env_with_values(env, fail_on_not_found=False, extra_env=None):
50475058 # No placeholders found
50485059 if not placeholders :
50495060 # Special handling for MLC_GIT_URL
5050- if key == 'MLC_GIT_URL' and env .get ('MLC_GIT_AUTH' , "no" ) == "yes" :
5061+ if key == 'MLC_GIT_URL' and is_true ( env .get ('MLC_GIT_AUTH' )) :
50515062 if env .get ('MLC_GH_TOKEN' ,
50525063 '' ) and '@' not in env ['MLC_GIT_URL' ]:
50535064 params = {"token" : env ['MLC_GH_TOKEN' ]}
@@ -5287,7 +5298,7 @@ def prepare_and_run_script_with_postprocessing(i, postprocess="postprocess"):
52875298 if r ['return' ] > 0 :
52885299 return r
52895300
5290- # Save file to run without CM
5301+ # Save file to run without MLC
52915302 if debug_script_tags != '' and all (
52925303 item in found_script_tags for item in debug_script_tags .split (',' )):
52935304
@@ -5593,10 +5604,12 @@ def convert_env_to_script(env, os_info, start_script=None):
55935604 os_info ['env_var' ].replace (
55945605 'env_var' , key )} """
55955606
5607+ env_quote = os_info ['env_quote' ]
55965608 # Replace placeholders in the platform-specific environment command
5609+ # and escapes any quote in the env value
55975610 env_command = os_info ['set_env' ].replace (
55985611 '${key}' , key ).replace (
5599- '${value}' , str (env_value ))
5612+ '${value}' , str (env_value ). replace ( env_quote , f""" \\ { env_quote } """ ) )
56005613 script .append (env_command )
56015614
56025615 return script
@@ -5880,6 +5893,9 @@ def update_state_from_meta(meta, env, state, const, const_state, deps, post_deps
58805893 if meta .get ('cache' , '' ) != '' :
58815894 run_state ['cache' ] = meta ['cache' ]
58825895
5896+ if meta .get ('cache_expiration' , '' ) != '' :
5897+ run_state ['cache_expiration' ] = meta ['cache_expiration' ]
5898+
58835899 default_env = meta .get ('default_env' , {})
58845900 for key in default_env :
58855901 env .setdefault (key , default_env [key ])
0 commit comments