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

DM-31722: Migrate utility code from other packages #100

Merged
merged 81 commits into from Oct 8, 2021
Merged

Conversation

timj
Copy link
Member

@timj timj commented Sep 28, 2021

Code is coming from pipe_base and daf_butler.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

Merging #100 (d266763) into master (e754672) will increase coverage by 2.28%.
The diff coverage is 95.91%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
python/lsst/utils/tests.py 74.68% <ø> (ø)
python/lsst/utils/logging.py 80.43% <80.43%> (ø)
python/lsst/utils/iteration.py 96.77% <96.77%> (ø)
python/lsst/utils/timer.py 96.87% <96.87%> (ø)
tests/test_logging.py 97.29% <97.29%> (ø)
tests/test_iteration.py 97.50% <97.50%> (ø)
tests/test_classes.py 97.67% <97.67%> (ø)
tests/test_introspection.py 98.36% <98.36%> (ø)
tests/test_timer.py 99.21% <99.21%> (ø)
python/lsst/utils/classes.py 100.00% <100.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e754672...d266763. Read the comment docs.

python/lsst/utils/timer.py Outdated Show resolved Hide resolved
@timj timj marked this pull request as ready for review October 5, 2021 20:07
tgoldina and others added 23 commits October 5, 2021 13:08
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.
Copy link
Member

@TallJimbo TallJimbo left a 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.

python/lsst/utils/iteration.py Outdated Show resolved Hide resolved
python/lsst/utils/classes.py Outdated Show resolved Hide resolved
python/lsst/utils/classes.py Outdated Show resolved Hide resolved
python/lsst/utils/logging.py Outdated Show resolved Hide resolved
python/lsst/utils/timer.py Outdated Show resolved Hide resolved
python/lsst/utils/timer.py Show resolved Hide resolved
tests/test_introspection.py Outdated Show resolved Hide resolved
This makes its purpose more obvious.
"""
stacklevel = 1 # the default for `Logger.log`
stack = traceback.extract_stack()
for i, s in enumerate(reversed(stack)):
Copy link
Member Author

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.

timj and others added 2 commits October 7, 2021 16:18
Co-authored-by: Jim Bosch <jbosch@astro.princeton.edu>
@timj timj merged commit 25fdfb9 into master Oct 8, 2021
@timj timj deleted the tickets/DM-31722 branch October 8, 2021 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants