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

Prefix logger.warning messages with "WARNING:" #1050

Merged
merged 6 commits into from
Dec 16, 2019
Merged

Conversation

dagewa
Copy link
Member

@dagewa dagewa commented Dec 1, 2019

This is a way of prefixing warning messages and thus make them stand out from general information messages in a consistent way. Draft for comments whether we want this kind of behaviour. This is for #1034.

@dagewa
Copy link
Member Author

dagewa commented Dec 4, 2019

Preference is for coloured output to stdout. There is something for this in dlstbx But what about the log file - should we still do this in order to make warning messages stand out from general info?

Do not change formatting of console messages. Colours are preferable.
@dagewa dagewa marked this pull request as ready for review December 16, 2019 15:00
@dagewa
Copy link
Member Author

dagewa commented Dec 16, 2019

Following merge of #1057, this has been updated to only change the log file formatting. I agree with previous comments that colouring is preferable for console output. To that end, @Anthchirp can we get ColorStreamHandler in DIALS rather than locked up in dlstbx?

Copy link
Member

@Anthchirp Anthchirp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative suggestion:

If level >= warning then
   print "WARN: log message"
         "WARN: continuation"
else
   print "time: log message"
         "      continuation"

util/log.py Outdated Show resolved Hide resolved
util/log.py Outdated
@@ -13,6 +13,9 @@

# https://stackoverflow.com/questions/25194864/python-logging-time-since-start-of-program/25196134#25196134
class ElapsedFormatter:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ElapsedFormatter still an appropriate name then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really... any ideas?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DialsLogfileFormatter?

Co-Authored-By: Markus Gerstel <2102431+Anthchirp@users.noreply.github.com>
@dagewa
Copy link
Member Author

dagewa commented Dec 16, 2019

Alternative suggestion:

If level >= warning then
   print "WARN: log message"
         "WARN: continuation"
else
   print "time: log message"
         "      continuation"

Yes, that would highlight the warnings even better

- Use the margin for the "WARN:" message
- Rename formatter
@dagewa
Copy link
Member Author

dagewa commented Dec 16, 2019

Example dials.index.log looks like this

  15.1: Using d_min_step 0.0
        
        Indexed crystal models:
        model 1 (19129 reflections):
        Crystal:
            Unit cell: (39.133, 41.884, 42.125, 90.132, 90.331, 90.320)
            Space group: P 1
            U matrix:  {{-0.1301,  0.5373,  0.8333},
                        {-0.9831,  0.0395, -0.1789},
                        {-0.1290, -0.8425,  0.5231}}
            B matrix:  {{ 0.0256,  0.0000,  0.0000},
                        { 0.0001,  0.0239,  0.0000},
                        { 0.0001,  0.0001,  0.0237}}
            A = UB:    {{-0.0031,  0.0129,  0.0198},
                        {-0.0251,  0.0009, -0.0042},
                        {-0.0033, -0.0201,  0.0124}}
        +------------+-------------+---------------+-------------+
        |   Imageset |   # indexed |   # unindexed | % indexed   |
        |------------+-------------+---------------+-------------|
        |          0 |       19129 |          6120 | 75.8%       |
        +------------+-------------+---------------+-------------+
        
        ################################################################################
        Starting refinement (macro-cycle 1)
        ################################################################################
        
  WARN: scan_varying=True not supported in indexing: setting scan_varying=False
  15.2: 
        Summary statistics for 19079 observations matched to predictions:
        +-------------------+--------+----------+---------+---------+--------+
        |                   |    Min |       Q1 |     Med |      Q3 |    Max |
        |-------------------+--------+----------+---------+---------+--------|
        | Xc - Xo (mm)      | -2.275 |   -0.396 | -0.2784 | -0.1821 | 0.5358 |
        | Yc - Yo (mm)      | -8.963 |  -0.1303 | 0.08766 |  0.2477 |  5.783 |
        | Phic - Phio (deg) | -15.38 | -0.05332 |  0.1556 |  0.3972 |  18.92 |
        | X weights         |  290.2 |    386.3 |   397.7 |   403.7 |  405.6 |
        | Y weights         |  296.6 |    386.6 |   396.9 |   403.3 |  405.6 |
        | Phi weights       |  11.11 |    11.97 |      12 |      12 |     12 |
        +-------------------+--------+----------+---------+---------+--------+
        
        Detecting centroid outliers using the Tukey algorithm
        2872 reflections have been flagged as outliers
        16207 reflections remain in the manager
        
        Summary statistics for 16207 observations matched to predictions:
        +-------------------+---------+----------+---------+---------+--------+
        |                   |     Min |       Q1 |     Med |      Q3 |    Max |
        |-------------------+---------+----------+---------+---------+--------|
        | Xc - Xo (mm)      |  -0.811 |  -0.3524 | -0.2596 | -0.1738 | 0.1512 |
        | Yc - Yo (mm)      |  -1.347 | -0.06906 | 0.09531 |  0.2317 |  1.436 |
        | Phic - Phio (deg) | -0.8908 | -0.02024 |    0.16 |  0.3807 |   1.24 |
        | X weights         |   290.2 |    389.3 |   399.4 |   404.1 |  405.6 |
        | Y weights         |   302.8 |    389.2 |   398.8 |   403.8 |  405.6 |
        | Phi weights       |   11.11 |    11.97 |   11.99 |      12 |     12 |
        +-------------------+---------+----------+---------+---------+--------+
        
  15.3: There are 16 parameters to refine against 9000 reflections in 3 dimensions

Completes another checkpoint for #1034
@dagewa dagewa merged commit 775d69b into master Dec 16, 2019
dagewa added a commit that referenced this pull request Dec 16, 2019
dagewa added a commit that referenced this pull request Dec 17, 2019
Use the colorlog (https://github.com/borntyping/python-colorlog) package to colour messages written to the log console. Currently blue for DEBUG, yellow for WARNING, red for ERROR. This complements #1050, which marks up warning messages in the log _file_ with an automatic prefix. Now that warnings are highlighted in some way either on the console or the log file, remove extraneous parts of various warning messages throughout the codebase. Closes #1034
@Anthchirp Anthchirp deleted the warning-prefix-log branch May 1, 2020 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants