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

revert: restore line printing in tracer #1304

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

revert: restore line printing in tracer #1304

wants to merge 3 commits into from

Conversation

guillett
Copy link
Member

@guillett guillett commented Nov 20, 2024

Fixes #1310

Technical changes

  • Fix computation_log.

@bonjourmauko
Copy link
Member

Hi! Was this a bug introduced recently? I'd love to add a failing test for this. If you could point me out at how to reproduce the error and the expected behaviour, I could help with the test.

@bonjourmauko bonjourmauko added the kind:fix Bugs are defects and failure demand. label Nov 21, 2024
@bonjourmauko bonjourmauko self-assigned this Nov 21, 2024
Copy link
Member

@bonjourmauko bonjourmauko left a comment

Choose a reason for hiding this comment

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

Ok I understood now: printing/logging has nothing to do in the computation log, which is just a log accumulator —like a writer monad transformer, sort of.

In test_runner.py, you could either:

  1. Get the log buffer and log it to stdout there.
  2. Pass down a function to the tracer with how you want to print/log the log buffer.

Something like this should give you what you want (just an idea):

# task_runner.py
@staticmethod
def print_computation_log(tracer, aggregate, max_depth) -> None:
    buffer = tracer.computation_log.lines(aggregate, max_depth)
    for line in buffer:
        print(line)

Also, using print is making the linter fail in CI, you have to use a logger for that:
https://docs.python.org/3/library/logging.html

Hope it helps :)

BTW, I have no idea how to test test_runner.py, so I won't be picky with that.

(Also, if this wasn't working before, I'd do a minor bump and label it as a new feature. It it was working before, then you can just safely ignore this comment and keep it as a patch.)

@bonjourmauko bonjourmauko mentioned this pull request Nov 21, 2024
6 tasks
@guillett
Copy link
Member Author

Thanks @bonjourmauko , I don't have much time to follow up. To me, this is a regression and I need this fix to work locally.

@bonjourmauko
Copy link
Member

bonjourmauko commented Nov 21, 2024

@guillett If you give me the command you normally use I can propose you a stacked PR with the proposed fix.

Concerning print, even if I accept it, you won't be able to merge this PR because of the linter.

@bonjourmauko
Copy link
Member

bonjourmauko commented Nov 21, 2024

Oh nevermind, I see the regression was introduced here 2f8072f#diff-fc2477fbba8037857fb9287895920ee5a1015c5eda4edb50832af14232fdd10b

for _ in self.lines(aggregate, max_depth):
pass
for line in self.lines(aggregate, max_depth):
print(line)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
print(line)
print(line) # noqa: T201

@bonjourmauko bonjourmauko changed the title Restore line printing in tracer revert: restore line printing in tracer Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:fix Bugs are defects and failure demand.
Projects
Status: Ready for shipping
Development

Successfully merging this pull request may close these issues.

Restore line printing in tracer
2 participants