Skip to content

Commit

Permalink
Use mlc logger in scripts instead of print statements 1.0
Browse files Browse the repository at this point in the history
Fix mlcommons#165, Replacement in the initial three files
  • Loading branch information
sujik18 committed Feb 2, 2025
1 parent 2ff9354 commit 8969942
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions script/app-image-classification-onnx-py/customize.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from mlc import utils
import os
import shutil
import logging

# Configure the logger
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def preprocess(i):

Expand Down Expand Up @@ -45,14 +49,14 @@ def postprocess(i):
with open(fjson, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=4)
except Exception as e:
print('CM warning: {}'.format(e))
logger.warning('CM warning: {}'.format(e))

try:
import yaml
with open(fyaml, 'w', encoding='utf-8') as f:
yaml.dump(data, f)
except Exception as e:
print('CM warning: {}'.format(e))
logger.warning('CM warning: {}'.format(e))

top_classification = data.get('top_classification', '')

Expand Down
6 changes: 5 additions & 1 deletion script/app-image-corner-detection/customize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from mlc import utils
import os
import logging

# Configure the logger
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def preprocess(i):
os_info = i['os_info']
Expand Down Expand Up @@ -38,6 +42,6 @@ def preprocess(i):
def postprocess(i):

env = i['env']
print(env['MLC_OUTPUT'] + " generated in " + env['MLC_RUN_DIR'])
logger.info(env['MLC_OUTPUT'] + " generated in " + env['MLC_RUN_DIR'])

return {'return': 0}
6 changes: 5 additions & 1 deletion script/app-mlperf-automotive-mlcommons-python/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import json
import shutil
import subprocess
import logging

# Configure the logger
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def preprocess(i):

Expand Down Expand Up @@ -72,7 +76,7 @@ def preprocess(i):
env['MLC_MLPERF_LOADGEN_EXTRA_OPTIONS'] += " --count " + \
env['MLC_MLPERF_LOADGEN_QUERY_COUNT']

print("Using MLCommons Inference source from '" +
logger.info("Using MLCommons Inference source from '" +
env['MLC_MLPERF_INFERENCE_SOURCE'] + "'")

if 'MLC_MLPERF_CONF' not in env:
Expand Down

0 comments on commit 8969942

Please sign in to comment.