Skip to content

Conversation

@ericphanson
Copy link
Contributor

@ericphanson ericphanson commented Mar 7, 2025

addresses #164 (comment)

This PR adds tests for code-coverage from @timeit functions (c68902f), and for #77 (92fa0fb) and fixes them by removing line nums then re-inserting the __source__ as mentioned in #164 (comment).

I did the commits incrementally with failing tests first to demonstrate the issues, so this PR should be squash-merged if it is to be merged.

@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.60%. Comparing base (ada4b6c) to head (394f57c).
Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
src/TimerOutput.jl 96.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
+ Coverage   84.82%   94.60%   +9.77%     
==========================================
  Files           5        6       +1     
  Lines         323      482     +159     
==========================================
+ Hits          274      456     +182     
+ Misses         49       26      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ericphanson ericphanson changed the title demonstrate that @timeit-defined functions no longer have code coverage fix missing codecov for @timeit-defined functions, and add tests for issue 77 Mar 8, 2025
@ericphanson ericphanson marked this pull request as ready for review March 8, 2025 00:28
@ericphanson
Copy link
Contributor Author

Bump :)

@IanButterworth
Copy link
Collaborator

With neither this nor master do I see --track-allocation=user counts within @timeit blocks

    42768             @timeit to "processing outputs" @views for out in yolo.out
        -                 outnr += 1
        -                 w, h, a, bo, ba = out[:size]
        -                 weights = reshape(yolo.W[out[:idx]], w, h, a, bo, ba)
        -                 sxy = out[:scale_x_y]
        -                 # adjust the predicted box coordinates into pixel values
        -                 if yolo.cfg[:output][outnr][:new_coords] == 1
        -                     if haskey(yolo.cfg[:output][outnr], :max_delta)
        -                         delta = Float32(yolo.cfg[:output][outnr][:max_delta])
        -                         clamp!(weights[:, :, 1:2, :, :], -delta, delta)
        -                     end
        -                     weights[:, :, 1:2, :, :] = (weights[:, :, 1:2, :, :] .* sxy .- (sxy - 1)/2 .+ out[:offset]) .* out[:scale]
        -                     weights[:, :, 3:4, :, :] = (weights[:, :, 3:4, :, :] .* sxy).^2 .* out[:anchor]
        -                 else

@ericphanson
Copy link
Contributor Author

hm, I only tested the case of a function definition annotated with the macro, can you check that case?

@IanButterworth
Copy link
Collaborator

IanButterworth commented Apr 19, 2025

Sorry, I meant that there appears to be another issue ontop of the one this evidently fixes (from the tests).

I'm looking into whether we can just do something other than remove_linenums! as an alternative to #154 and this PR.

@IanButterworth
Copy link
Collaborator

IanButterworth commented Apr 19, 2025

I think the only way would be to lift the Expr(:tryfinally to the macro level.

Something like this perhaps, returning the setup and cleanup blocks separately to feed into the tryfinally at the macro level.

macro timeit(args...)
    expr_or_exprs = timer_expr(__module__, false, args...)
    if expr_or_exprs isa Expr
        expr_or_exprs
    elseif length(expr_or_exprs) == 2
        expr_or_exprs[1]
        Expr(:tryfinally,
            :($(esc(args[end]))),
            :($(esc(expr_or_exprs[2])))
        )
    else
        only(expr_or_exprs)
    end
end

@IanButterworth
Copy link
Collaborator

This appears to work. #196

Would it make sense to bring your tests over to that?

@IanButterworth IanButterworth merged commit 02aaa21 into KristofferC:master May 3, 2025
9 checks passed
@IanButterworth
Copy link
Collaborator

Thanks for the merge from master. I'll leave it a few days to cut a release.

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.

3 participants