Skip to content

Commit 4eb72a2

Browse files
authored
Fixed a bug in cache validation (mlcommons#865)
1 parent bba0f6b commit 4eb72a2

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

.github/pull_request_template.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@
1616
- [ ] No secrets or credentials are committed
1717
- [ ] Paths, shell commands, and environment handling are safe and portable
1818

19-

automation/script/cache_utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,10 @@ def run_validate_cache_if_present(i, cached_script):
323323
)
324324

325325
# reconstruct env/state from cached metadata
326-
env_tmp = copy.deepcopy(i['env'])
327-
state_tmp = copy.deepcopy(i['state'])
326+
env = i['env']
327+
state = i['state']
328+
env_saved = copy.deepcopy(env)
329+
state_saved = copy.deepcopy(state)
328330

329331
path_to_cached_state_file = os.path.join(
330332
cached_script.path,
@@ -340,10 +342,10 @@ def run_validate_cache_if_present(i, cached_script):
340342
return None
341343
new_env = cached_meta.get("new_env", {})
342344
if new_env:
343-
env_tmp.update(new_env)
345+
env.update(new_env)
344346
new_state = cached_meta.get("new_state", {})
345347
if new_state:
346-
state_tmp.update(new_state)
348+
state.update(new_state)
347349

348350
# re-run deps
349351
deps = i['meta'].get('deps')
@@ -377,11 +379,14 @@ def run_validate_cache_if_present(i, cached_script):
377379

378380
r = i['self'].run_native_script({
379381
'run_script_input': run_script_input,
380-
'env': env_tmp,
382+
'env': env,
381383
'script_name': 'validate_cache',
382384
'detect_version': True
383385
})
384386

387+
i['env'] = env_saved
388+
i['state'] = state_saved
389+
385390
if r['return'] > 0:
386391
return None
387392

0 commit comments

Comments
 (0)