Skip to content

Commit

Permalink
Merge pull request #470 from GATEOverflow/mlperf-inference
Browse files Browse the repository at this point in the history
Cleanups for get-generic-sys-util
  • Loading branch information
arjunsuresh authored Nov 3, 2024
2 parents da413c7 + 196c9b8 commit 695897b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions script/get-generic-sys-util/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ def preprocess(i):
state = i['state']
automation = i['automation']

if env['CM_SYS_UTIL_NAME'] == "psmisc" and env.get('CM_HOST_OS_PACKAGE_MANAGER', '') == "brew":
env['CM_SYS_UTIL_VERSION_CMD_OVERRIDE'] = "brew info pstree > tmp-ver.out 2>&1"
env['CM_SYS_UTIL_VERSION_RE'] = r"\\b(\\d+\\.\\d+(?:\\.\\d+)?)\\b"
env['CM_TMP_VERSION_DETECT_GROUP_NUMBER'] = 0

#Use VERSION_CMD and CHECK_CMD if no CHECK_CMD is set
if env.get('CM_SYS_UTIL_VERSION_CMD', '') != '' and env.get('CM_SYS_UTIL_CHECK_CMD', '') == '':
env['CM_SYS_UTIL_CHECK_CMD'] = env['CM_SYS_UTIL_VERSION_CMD']

if env.get('CM_GENERIC_SYS_UTIL_RUN_MODE', '') == "install":
i['run_script_input']['script_name'] = "install"

if env.get('CM_GENERIC_SYS_UTIL_RUN_MODE', '') == "detect":
if env.get('CM_SYS_UTIL_VERSION_CMD', '') != '' or env.get('CM_SYS_UTIL_VERSION_CMD_OVERRIDE', '') != '':
r = automation.run_native_script({'run_script_input':i['run_script_input'], 'env':env, 'script_name':'detect'})
Expand All @@ -27,9 +25,11 @@ def preprocess(i):
env['CM_GENERIC_SYS_UTIL_INSTALL_NEEDED'] = "yes"
return {'return': 0}
else: #detection is successful, no need to install
#print("detection success")
env['CM_SYS_UTIL_INSTALL_CMD'] = ""
return {'return': 0}
else: #No detction command available, just install
#print("No detection possible, going for installation")
env['CM_GENERIC_SYS_UTIL_INSTALL_NEEDED'] = "yes"
return {'return': 0}

Expand Down Expand Up @@ -121,6 +121,7 @@ def detect_version(i):
'group_number': group_number,
'env_key': version_env_key,
'which_env': env})

if r['return'] >0: return r

version = r['version']
Expand All @@ -133,8 +134,9 @@ def postprocess(i):

version_env_key = f"CM_{env['CM_SYS_UTIL_NAME'].upper()}_VERSION"

if (env.get('CM_SYS_UTIL_VERSION_CMD', '') != '' or env.get('CM_SYS_UTIL_VERSION_CMD_OVERRIDE', '') != '') and (env['CM_GENERIC_SYS_UTIL_RUN_MODE'] == "install" and env.get(version_env_key, '') == '') and str(env.get('CM_TMP_GENERIC_SYS_UTIL_PACKAGE_INSTALL_IGNORED', '')).lower() not in ["yes", "1", "true"] and env.get('CM_GET_GENERIC_SYS_UTIL_INSTALL_FAILED', '') != 'yes':
if (env.get('CM_SYS_UTIL_VERSION_CMD', '') != '' or env.get('CM_SYS_UTIL_VERSION_CMD_OVERRIDE', '') != '') and env.get(version_env_key, '') == '' and str(env.get('CM_TMP_GENERIC_SYS_UTIL_PACKAGE_INSTALL_IGNORED', '')).lower() not in ["yes", "1", "true"] and env.get('CM_GET_GENERIC_SYS_UTIL_INSTALL_FAILED', '') != 'yes':
automation = i['automation']

r = automation.run_native_script({'run_script_input':i['run_script_input'], 'env':env, 'script_name':'detect'})
if r['return'] > 0 and str(env.get('CM_GENERIC_SYS_UTIL_IGNORE_VERSION_DETECTION_FAILURE', '')).lower() not in [ "1", "yes", "true" ]:
return {'return': 1, 'error': 'Version detection failed after installation. Please check the provided version command or use env.CM_GENERIC_SYS_UTIL_IGNORE_VERSION_DETECTION_FAILURE=yes to ignore the error.'}
Expand Down
File renamed without changes.

0 comments on commit 695897b

Please sign in to comment.