Skip to content

Commit

Permalink
fixes for Python 3.12+ (#1152)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsuresh authored Mar 3, 2024
2 parents 68bf6b9 + 8ad5582 commit cdd7669
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 277 deletions.
4 changes: 2 additions & 2 deletions cm-mlops/automation/script/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4167,7 +4167,7 @@ def prepare_and_run_script_with_postprocessing(i, postprocess="postprocess"):
print ('')

print (recursion_spaces + ' ! cd {}'.format(cur_dir))
print (recursion_spaces + ' ! call {} from {}'.format(run_script, path_to_run_script))
print (recursion_spaces + ' ! call {} from {}'.format(path_to_run_script, run_script))


# Prepare env variables
Expand Down Expand Up @@ -4258,7 +4258,7 @@ def prepare_and_run_script_with_postprocessing(i, postprocess="postprocess"):
utils.merge_dicts({'dict1':env, 'dict2':updated_env, 'append_lists':True, 'append_unique':True})


if customize_code is not None:
if postprocess != '' and customize_code is not None:
print (recursion_spaces+' ! call "{}" from {}'.format(postprocess, customize_code.__file__))

if len(posthook_deps)>0 and (postprocess == "postprocess"):
Expand Down
2 changes: 1 addition & 1 deletion cm-mlops/script/app-image-classification-onnx-py/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export CK_BATCH_COUNT=${CM_BATCH_COUNT}

if [[ "${CM_INPUT}" != "" ]]; then export CM_IMAGE=${CM_INPUT}; fi

PIP_EXTRA=`${CM_PYTHON_BIN} -c "import pkg_resources; print(' --break-system-packages ' if int(pkg_resources.get_distribution('pip').version.split('.')[0]) >= 23 else '')"`
PIP_EXTRA=`${CM_PYTHON_BIN} -c "import importlib.metadata; print(' --break-system-packages ' if int(importlib.metadata.version('pip').split('.')[0]) >= 23 else '')"`

echo ""
${CM_PYTHON_BIN} -m pip install -r ${CM_TMP_CURRENT_SCRIPT_PATH}/requirements.txt ${PIP_EXTRA}
Expand Down
5 changes: 0 additions & 5 deletions cm-mlops/script/get-axs/README-extra.md

This file was deleted.

145 changes: 0 additions & 145 deletions cm-mlops/script/get-axs/README.md

This file was deleted.

38 changes: 0 additions & 38 deletions cm-mlops/script/get-axs/_cm.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions cm-mlops/script/get-axs/customize.py

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion cm-mlops/script/get-axs/run.bat

This file was deleted.

27 changes: 0 additions & 27 deletions cm-mlops/script/get-axs/run.sh

This file was deleted.

33 changes: 28 additions & 5 deletions cm-mlops/script/get-generic-python-lib/detect-version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
import pkg_resources
import os

package_name = os.environ.get('CM_GENERIC_PYTHON_PACKAGE_NAME','')

filename = 'tmp-ver.out'

if os.path.isfile(filename):
os.remove(filename)

if package_name != '':

version = ''
error = ''

try:
version = pkg_resources.get_distribution(package_name).version
print (version)
except:
pass
import importlib.metadata
version = importlib.metadata.version(package_name)
except Exception as e:
error = format(e)

if error != '':
try:
import pkg_resources
version = pkg_resources.get_distribution(package_name).version
error = ''
except Exception as e:
if error!='': error += '\n'
error += format(e)

# We generally skip error since it usually means that
# package is not installed

with open(filename, 'w') as file:
file.write(str(version)+'\n')
2 changes: 1 addition & 1 deletion cm-mlops/script/get-generic-python-lib/run.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IF NOT DEFINED CM_TMP_CURRENT_SCRIPT_PATH SET CM_TMP_CURRENT_SCRIPT_PATH=%CD%

%CM_PYTHON_BIN_WITH_PATH% %CM_TMP_CURRENT_SCRIPT_PATH%\detect-version.py > tmp-ver.out
%CM_PYTHON_BIN_WITH_PATH% %CM_TMP_CURRENT_SCRIPT_PATH%\detect-version.py
IF %ERRORLEVEL% NEQ 0 EXIT 1
6 changes: 3 additions & 3 deletions cm-mlops/script/get-generic-python-lib/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

CM_TMP_CURRENT_SCRIPT_PATH=${CM_TMP_CURRENT_SCRIPT_PATH:-$PWD}

cmd="${CM_PYTHON_BIN_WITH_PATH} ${CM_TMP_CURRENT_SCRIPT_PATH}/detect-version.py > tmp-ver.out 2> tmp-ver.err"
#echo $cmd
eval $cmd
${CM_PYTHON_BIN_WITH_PATH} ${CM_TMP_CURRENT_SCRIPT_PATH}/detect-version.py
test $? -eq 0 || exit $?
exit 0
6 changes: 6 additions & 0 deletions cm-mlops/script/get-mlperf-inference-loadgen/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
"pip-package", "pybind11"
],
"tags": "get,generic-python-lib,_package.pybind11"
},
{
"names": [
"pip-package", "setuputils"
],
"tags": "get,generic-python-lib,_package.setuptools"
}
],
"default_env": {
Expand Down
2 changes: 1 addition & 1 deletion cm-mlops/script/get-sys-utils-cm/do_pip_installs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

PIP_EXTRA=`python3 -c "import pkg_resources; print(' --break-system-packages ' if int(pkg_resources.get_distribution('pip').version.split('.')[0]) >= 23 else '')"`
PIP_EXTRA=`python3 -c "import importlib.metadata; print(' --break-system-packages ' if int(importlib.metadata.version('pip').split('.')[0]) >= 23 else '')"`
cmd="python3 -m pip install -r ${CM_TMP_CURRENT_SCRIPT_PATH}/requirements.txt ${CM_PYTHON_PIP_USER} ${CM_PYTHON_PIP_COMMON_EXTRA} ${PIP_EXTRA}"
echo $cmd
eval $cmd
6 changes: 6 additions & 0 deletions cm-mlops/script/get-sys-utils-cm/do_pip_installs.sh.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

PIP_EXTRA=`python3 -c "import pkg_resources; print(' --break-system-packages ' if int(pkg_resources.get_distribution('pip').version.split('.')[0]) >= 23 else '')"`
cmd="python3 -m pip install -r ${CM_TMP_CURRENT_SCRIPT_PATH}/requirements.txt ${CM_PYTHON_PIP_USER} ${CM_PYTHON_PIP_COMMON_EXTRA} ${PIP_EXTRA}"
echo $cmd
eval $cmd
2 changes: 1 addition & 1 deletion cm-mlops/script/get-tensorrt/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [[ ${CM_TENSORRT_VERSION} == 'vdetected' ]]; then
exit 0;
fi

PIP_EXTRA=`python3 -c "import pkg_resources; print(' --break-system-packages ' if int(pkg_resources.get_distribution('pip').version.split('.')[0]) >= 23 else '')"`
PIP_EXTRA=`python3 -c "import importlib.metadata; print(' --break-system-packages ' if int(importlib.metadata.version('pip').split('.')[0]) >= 23 else '')"`

version=${CM_TENSORRT_VERSION}
install_dir=${CM_TENSORRT_INSTALL_PATH}
Expand Down
2 changes: 1 addition & 1 deletion cm-mlops/script/gui/playground_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def page(st, params, extra):
else:
cm_repo = 'mlcommons@ck'

x = '{} -m pip install cmind -U{}\n\n'.format(python, need_user)
x = '{} -m pip install cmind -U {}\n\n'.format(python, need_user)
x += 'cm pull repo {}\n\n'.format(cm_repo)

clean_cm_cache = st.toggle('Clean CM cache', value=True, key = 'install_clean_cm_cache')
Expand Down
Loading

0 comments on commit cdd7669

Please sign in to comment.