You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/11/08 04:35:26 UTC
[GitHub] [incubator-mxnet] leezu opened a new pull request #16760:
[Estimator] Improve usability and fix logging inconsistencies
leezu opened a new pull request #16760: [Estimator] Improve usability and fix logging inconsistencies
URL: https://github.com/apache/incubator-mxnet/pull/16760
## Description ##
gluon.contrib.estimator uses a Logger shared between all event handlers that is
obtained via logging.getLogger(gluon.contrib.estimator.event_handlers). This
logger used to be configured when creating a
gluon.contrib.estimator.LoggingHandler. This configuration was inconsistent,
because each time a LoggingHandler was created, the global Logger was modified.
Instead, this commit clearly separates the LoggingHandler (responsible for
logging to the Logger during estimator.fit) from the configuration of the
Logger (which users can do via the introduced getLogger API).
Further, there was previously no way for user-defined EventHandlers to log to
the correct Logger instance.
We also disable log handler propagation by default and change the default log
stream for gluon estimator to sys.stdout.
## Checklist ##
### Essentials ###
Please feel free to remove inapplicable items for your PR.
- [X] Changes are complete (i.e. I finished coding on this PR)
- [ ] All changes have test coverage:
- Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
- Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
- Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
- [X] Code is well-documented:
- For user-facing API changes, API doc string has been updated.
- For new C++ functions in header files, their functionalities and arguments are documented.
- For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
- Check the API doc at https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
- [X] To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
### Changes ###
- [X] Introduce `gluon.contrib.estimator.getLogger` API for users to configure and obtain the logger class used by gluon estimator. This supersedes configuring the logger by adding constructor arguments to `gluon.contrib.estimator.LoggingHandler`, as the logger is a global object and it does not make sense to configure it as part of a class constructor (of which we can expect some users to create multiple objects during a sessione.)
## Comments ##
- This change is backward incompatible, but is important to make. It only changes experimental APIs. The reason is that the previous API design is inconsistent and not user friendly. It is inconsistent, because a global object is modified whenever a `LoggingHandler` object is created; this leads to buggy behaviour if the user creates multiple `LoggingHandler`s, as all of them will share the same underlying Python Logger. Instead, we must make it explictit that the same Logger is used.
- This change improves usability, by switching the default log stream from `sys.stderr` to `sys.stdout`. The following screenshot highlights the need for this. Users can change this default by modifying the logger returned by the `getLogger` API, if needed.

Compare this to

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services