Skip to content

Commit

Permalink
Added cache validation support for get-generic-python-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsuresh committed Nov 25, 2024
1 parent 8686048 commit 1b5bda7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
24 changes: 21 additions & 3 deletions automation/script/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1945,10 +1945,9 @@ def _run(self, i):

cached_meta['associated_script_artifact_uid'] = found_script_artifact[x + 1:]

# Check if the cached entry is dependent on any other cached
# entry
# Check if the cached entry is dependent on any path
if dependent_cached_path != '':
if os.path.isdir(cached_path) and os.path.isdir(
if os.path.isdir(cached_path) and os.path.exists(
dependent_cached_path):
if not os.path.samefile(
cached_path, dependent_cached_path):
Expand Down Expand Up @@ -5020,6 +5019,25 @@ def find_cached_script(i):
skip_cached_script = True
continue

if os.path.exists(os.path.join(cached_script.path, "validate.sh")):
os_info = self_obj.os_info

# Bat extension for this host OS
bat_ext = os_info['bat_ext']
run_script_input = {
'path': cached_script.path,
'bat_ext': bat_ext,
'os_info': os_info,
'recursion_spaces': recursion_spaces,
'tmp_file_run': self_obj.tmp_file_run,
'self': self_obj,
'meta': i['meta']
}
ii = {'run_script_input': run_script_input, 'env': env, 'script_name': 'validate'}
r = self_obj.run_native_script(ii)
if r['return'] > 0:
continue

if not skip_cached_script:
cached_script_version = cached_script.meta.get('version', '')

Expand Down
5 changes: 4 additions & 1 deletion script/get-generic-python-lib/customize.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from cmind import utils
import os
import cmind as cm

import shutil

def preprocess(i):

Expand Down Expand Up @@ -179,4 +179,7 @@ def postprocess(i):
if pip_version and len(pip_version) > 1 and int(pip_version[0]) >= 23:
env['CM_PYTHON_PIP_COMMON_EXTRA'] = " --break-system-packages"

shutil.copyfile(os.path.join(env['CM_TMP_CURRENT_SCRIPT_PATH'], "detect-version.py"), "detect-version.py")
shutil.copyfile(os.path.join(env['CM_TMP_CURRENT_SCRIPT_PATH'], "run.sh"), "validate.sh")

return {'return': 0, 'version': version}

0 comments on commit 1b5bda7

Please sign in to comment.