Open benmalef opened 2 weeks ago
MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅
@sarthakpati I agree it would be nice to mention logging in extension guide. However, the whole PR is created in the way that we hide all configuration from the developer - so developer almost doesn't need to bother about it. So, I believe there is not a big need to describe how to create loggers in new or modified code, but instead it would be useful to describe how logging is configured right now and how to log stuff sustainably
### Logging
#### Use loggers instead of print
We use native Python `logging` library for logs management. It is already configured, so if you are extending the code, please use loggers instead of `print` calls.
def my_new_cool_function(df: pd.DataFrame): logger = logging.getLogger(name) # you can use any your own logger name or just pass a current file name logger.debug("Message for debug file only") logger.info("Hi GaNDLF user, I greet you in the CLI output") logger.error(f"A detailed message about any error if needed. Exception: {str(e)}, params: {params}, df shape: {df.shape}")
```
GaNDLF logs are splitted into multiple parts:
info
messages are shown here
Sounds good, @VukW! Thank you for the explanation. 😄
Hi guys @VukW, @sarthakpati, Thanks for the detailed review. I agree with it. I will do it.
@sarthakpati @VukW I added a Logging section in the documentation for extending GaNDLF
@sarthakpati I made the proposed changes...!! Thanks a lot for the suggestions.!!
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 94.46%. Comparing base (
b6dfe2d
) to head (f425289
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Fixes #755
Brief Description
This PR fixes the issues from this PR
I have tried to implement this ref
I have NOT implemented the tqdm ref. I will create a separate PR.
Screenshots
This screenshot shows how logging messages are in the file.
Proposed Changes
Checklist
CONTRIBUTING
guide has been followed.typing
is used to provide type hints, including and not limited to usingOptional
if a variable has a pre-defined value).pip install
step is needed for PR to be functional), please ensure it is reflected in all the files that control the CI, namely: python-test.yml, and all docker files [1,2,3].