Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mlc logger in scripts instead of print statements #165

Open
arjunsuresh opened this issue Jan 28, 2025 · 4 comments
Open

Use mlc logger in scripts instead of print statements #165

arjunsuresh opened this issue Jan 28, 2025 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@arjunsuresh
Copy link
Collaborator

We now have a global logger from MLC being used in Script automation. We need to modify the individual scripts also to use this logger instead of print statements.

@arjunsuresh arjunsuresh added the enhancement New feature or request label Jan 28, 2025
@arjunsuresh arjunsuresh added the good first issue Good for newcomers label Jan 28, 2025
sujik18 added a commit to sujik18/mlperf-automations that referenced this issue Feb 2, 2025
@sujik18
Copy link
Member

sujik18 commented Feb 2, 2025

@arjunsuresh, do we need to similarly modify all the scripts present inside the script folder individually to replace the print statements with the usage of logger?

@arjunsuresh
Copy link
Collaborator Author

@sujik18 That's correct but a small change is needed. If we initialise logging in each file, they'll log independently which is not desirable. We do have an option to get the global logger in customize.py by doing the following

logger = i['automation'].logger

and then we can do

logger.warning('CM warning: {}'.format(e))

which uses the global logger.

@sujik18
Copy link
Member

sujik18 commented Feb 6, 2025


print("")
print("Data layout: {}".format(data_layout))
print("Input layers: {}".format([str(x) for x in sess.get_inputs()]))
print("Output layers: {}".format([str(x) for x in sess.get_outputs()]))
print("Input layer name: " + input_layer_name)
print("Expected input shape: {}".format(model_input_shape))
print("Output layer name: " + output_layer_name)
print("Data normalization: {}".format(normalize_data_bool))
print("Subtract mean: {}".format(subtract_mean_bool))
print('Per-channel means to subtract: {}'.format(given_channel_means))
print("Background/unlabelled classes to skip: {}".format(bg_class_offset))
print("")


@arjunsuresh if there are print statements which might be useful for both user and debugging purpose like the above, in such case is it better to implement both by initializing these messages in an array and then executing using a loop to implement both print and logger statements.


info_messages = [
"",
"Data layout: {}".format(data_layout),
"Input layers: {}".format([str(x) for x in sess.get_inputs()]),
"Output layers: {}".format([str(x) for x in sess.get_outputs()]),
"Input layer name: " + input_layer_name,
"Expected input shape: {}".format(model_input_shape),
"Output layer name: " + output_layer_name,
"Data normalization: {}".format(normalize_data_bool),
"Subtract mean: {}".format(subtract_mean_bool),
'Per-channel means to subtract: {}'.format(given_channel_means),
"Background/unlabelled classes to skip: {}".format(bg_class_offset),
""
]

for message in info_messages:
print(message)
logger.info(message)


Or else, is it the case that we have to strictly replace all the print statements with logger in the scripts and have to remove the print statements entirely?

@arjunsuresh
Copy link
Collaborator Author

@sujik18 These messages are in custom python files right? I think we need not change them to logger functions. We only need to change them in customize.py file which is the only python file directly run by MLC.

arjunsuresh added a commit that referenced this issue Feb 7, 2025
* Better naming for github action runs

Fix for #134

* Use mlc logger in scripts instead of print statements 1.0

Fix #165, Replacement in the initial three files

* Update test-mlperf-inference-rgat.yml

test name update

Co-authored-by: Arjun Suresh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

2 participants