mlcommons / GaNDLF

A generalizable application framework for segmentation, regression, and classification using PyTorch
https://gandlf.org
Apache License 2.0
150 stars 78 forks source link

Add logging final version #893

Open benmalef opened 2 weeks ago

benmalef commented 2 weeks ago

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.

image

Proposed Changes

Checklist

github-actions[bot] commented 2 weeks ago

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

VukW commented 2 weeks ago

@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}")

print("Hi GaNDLF user!") # don't use prints please.

```

What and where is logged

GaNDLF logs are splitted into multiple parts:

sarthakpati commented 2 weeks ago

Sounds good, @VukW! Thank you for the explanation. 😄

benmalef commented 2 weeks ago

Hi guys @VukW, @sarthakpati, Thanks for the detailed review. I agree with it. I will do it.

benmalef commented 2 weeks ago

@sarthakpati @VukW I added a Logging section in the documentation for extending GaNDLF

benmalef commented 6 days ago

@VukW @sarthakpati I have tried to implement this.

As mentioned, a new separated PR will be created for CLI commands ref.

benmalef commented 1 day ago

@sarthakpati I made the proposed changes...!! Thanks a lot for the suggestions.!!

codecov[bot] commented 21 hours ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.46%. Comparing base (b6dfe2d) to head (f425289).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## new-apis_v0.1.0-dev #893 +/- ## ======================================================= + Coverage 94.41% 94.46% +0.04% ======================================================= Files 159 160 +1 Lines 9387 9482 +95 ======================================================= + Hits 8863 8957 +94 - Misses 524 525 +1 ``` | [Flag](https://app.codecov.io/gh/mlcommons/GaNDLF/pull/893/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mlcommons) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/mlcommons/GaNDLF/pull/893/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mlcommons) | `94.46% <100.00%> (+0.04%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mlcommons#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.