Skip to content

revert: restore line printing in tracer #1304

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

Merged
merged 3 commits into from
Mar 7, 2025
Merged

revert: restore line printing in tracer #1304

merged 3 commits into from
Mar 7, 2025

Conversation

guillett
Copy link
Member

@guillett guillett commented Nov 20, 2024

Fixes #1310
Depends on #1321

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

@bonjourmauko bonjourmauko changed the title Restore line printing in tracer revert: restore line printing in tracer Nov 21, 2024
@benjello
Copy link
Member

benjello commented Mar 5, 2025

@guillett : I modified the changlog so the linter passes but we still have a problem with a conda build.
@benoit-cty: didn't we got this error already ? Any hint ?

@benoit-cty
Copy link
Contributor

benoit-cty commented Mar 6, 2025

@guillett : I modified the changlog so the linter passes but we still have a problem with a conda build. @benoit-cty: didn't we got this error already ? Any hint ?

Well, the error in Conda complains about Numpy :

If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).

Because despite the np1.6.24 in the name of the test, it is a Numpy 2 version that has been installed:

+ numpy 2.2.3 py310hefbff90_0 conda-forge 8MB

@bonjourmauko
Copy link
Member

There is definitely a problem with the conda's config.

@bonjourmauko
Copy link
Member

poke @sylvainipp it looks like the problem you were having could come from inadvertently using a numpy > 2.2 version, that could be unrelated to your proposed changes in #1319

@bonjourmauko bonjourmauko changed the base branch from master to fix/conda-build-bad-numpy March 6, 2025 18:15
Base automatically changed from fix/conda-build-bad-numpy to master March 7, 2025 09:40
@bonjourmauko bonjourmauko merged commit 892cebf into master Mar 7, 2025
29 checks passed
@bonjourmauko bonjourmauko deleted the fix-tracer branch March 7, 2025 10:52
@github-project-automation github-project-automation bot moved this from Ready for shipping to Shipped in OpenFisca International Mar 7, 2025
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
Development

Successfully merging this pull request may close these issues.

Restore line printing in tracer
4 participants