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
DM-31722: Migrate utility code from other packages #100
Conversation
Codecov Report
@@ Coverage Diff @@
## master #100 +/- ##
==========================================
+ Coverage 88.59% 90.87% +2.28%
==========================================
Files 24 36 +12
Lines 1420 2083 +663
==========================================
+ Hits 1258 1893 +635
- Misses 162 190 +28
Continue to review full report at Codecov.
|
8ca6dd6
to
851eb71
Compare
Uses a special subclass of logging.Logger to allow some period of migration for usage in existing Tasks.
LoggingAdapter can apply to the root logger so allows for more consistency in usage.
We may end up always using this special logger.
Caller code should be fixed to configure logging or lsst.log as needed.
* verbose and trace are generally useful and may indicate we should always be using this log adapter. * Trap large log levels and assume they are lsst.log constants. * Add more Logger compatibility forwarding.
Python does not provide fatal() method on LoggingAdapter even though it does provide warn().
For verbose/trace/infof etc the messages were being reported from the wrong line. Setting stacklevel allows the log to report the correct line.
For now, we attach these constants to the log adapter so that it is easier to access the VERBOSE and TRACE constants. Do not deprecated any of them since python logging does not deprecated any (including WARN or FATAL). Getting the constants directly from the logger ensures self consistency for the Task user and hides the specific logging system from the Task.
For now assume that the log adapter for Task is going to exist as more than a transition class for the migration from lsst.log.
Since python itself does not deprecate it.
This makes the intent more explicit.
* iterable * chunk_iterable * isplit
This is a better fit. A deprecated version remains in the original location.
doImport can return Module or Type and this leads to mypy insisting on many additional checks in any code that uses doImport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments are 100% minor, >90% preexisting, I suspect.
This makes its purpose more obvious.
""" | ||
stacklevel = 1 # the default for `Logger.log` | ||
stack = traceback.extract_stack() | ||
for i, s in enumerate(reversed(stack)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ktlim this is what I did to ensure that the log message is reported from the caller code. Simple testing demonstrates that it works.
Co-authored-by: Jim Bosch <jbosch@astro.princeton.edu>
Code is coming from pipe_base and daf_butler.
Checklist
doc/changes