Skip to content

Conversation

@vkarak
Copy link
Contributor

@vkarak vkarak commented Jul 11, 2020

This function replaces the older debug.repr() and uses util.ppretty() for nicely printing the object attributes. util.ppretty() is also extended in order to recursively call the new repr() function. Objects are printed only once by this new repr() avoiding infinite recursions.

Finally, we use that function to print the whole ReFrame runtime state in case #1369 appears.

This function does not take into account the __slots__ for the moment. In cases, where an object does not have a __dict__ attribute, the builtin repr() will be used.

An example output for a list of objects with self references is the following (see also the corresponding unit test):

[
    _Y({
        'x': 1,
        'y': 'foo',
        'z': _Y(...)@0x102463550,
        'a': None
    })@0x102463550,
    _Y({
        'x': 2,
        'y': 'foo',
        'z': _Y(...)@0x102463510,
        'a': _X({
            '_a': False
        })@0x102463290
    })@0x102463510
]

This function replaces the older `debug.repr()` and uses `util.ppretty()` for
nicely printing the object attributes. `util.ppretty()` is also extended in
order to recursively call the new `repr()` function. Objects are printed only
once by this new `repr()` avoiding infinite recursions.

Finally, we use that function to print the whole ReFrame runtime state in case
issue reframe-hpc#1369 appears.

This function does not take into account the `__slots__` for the moment.
In cases, where an object does not have a `__dict__` attribute, the builtin
`repr()` will be used.
@vkarak
Copy link
Contributor Author

vkarak commented Jul 11, 2020

Check comment in issue #1369 as a proof that this PR works wonderfully :-) It served its purpose already!

Copy link
Contributor

@ekouts ekouts left a comment

Choose a reason for hiding this comment

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

lgtm

@codecov-commenter
Copy link

codecov-commenter commented Jul 13, 2020

Codecov Report

Merging #1410 into master will increase coverage by 0.00%.
The diff coverage is 93.33%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1410   +/-   ##
=======================================
  Coverage   91.79%   91.79%           
=======================================
  Files          83       82    -1     
  Lines       12743    12712   -31     
=======================================
- Hits        11697    11669   -28     
+ Misses       1046     1043    -3     
Impacted Files Coverage Δ
reframe/core/config.py 88.62% <ø> (-0.04%) ⬇️
reframe/core/logging.py 82.91% <ø> (+0.35%) ⬆️
reframe/frontend/executors/__init__.py 99.02% <ø> (+0.62%) ⬆️
reframe/frontend/loader.py 91.39% <ø> (+0.77%) ⬆️
reframe/frontend/statistics.py 91.60% <ø> (+0.51%) ⬆️
unittests/test_policies.py 98.66% <25.00%> (-0.80%) ⬇️
reframe/utility/__init__.py 92.56% <100.00%> (+0.52%) ⬆️
unittests/test_utility.py 99.71% <100.00%> (-0.01%) ⬇️

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 1e0f3ee...fb367bf. Read the comment docs.

@vkarak vkarak changed the title [refactor] Add a powerful repr() function for debugging [refactor] Add a powerful repr() function for debugging Jul 13, 2020
@vkarak vkarak merged commit 6f77b29 into reframe-hpc:master Jul 13, 2020
@vkarak vkarak deleted the refactor/replace-debug-repr branch July 13, 2020 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants