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

feat: session.eval_with_hooks #1580

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

hugocaillard
Copy link
Collaborator

@hugocaillard hugocaillard commented Oct 9, 2024

wip - exploring an other interface for session hooks

With this approach:

  • the Session is more aware of it's hooks
    • instead of passing eval_hooks to every functions (eval, deploy_contract , call_contract), the caller only enable an hook once
    • in the future we could have session.enable_debug_print_hook, session.enable_tracer_hook, etc
  • I added .eval_with_hooks that keeps the same behaviour and is backward compatible with exisintg implementation. It allows to evaluated snippets with arbitrary hooks
    • Should we choose to use the implemation, I should add some documentation in the comments for the eval_with_hooks method

Concerns:

  • is the Session supposed to be that aware of the hooks, or is it better to keep them as parameters, so that the Sessionis mor versatile

Comment on lines +725 to +739
"TN:",
"SF:/contract-0.clar",
"FN:1,add",
"FNF:1",
"FNH:0",
"BRF:0",
"BRH:0",
"end_of_record",
"SF:/contract-1.clar",
"FN:1,add",
"FNF:1",
"FNH:0",
"BRF:0",
"BRH:0",
"end_of_record",
Copy link
Collaborator Author

@hugocaillard hugocaillard Oct 9, 2024

Choose a reason for hiding this comment

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

As a side effect, this is the wanted behaviour for code coverage.
Because session.deploy_contract uses the session coverage hook.
This is therefore the initial analysis of the contracts.
If we wanted to pass the eval_hooks to update_session_with_deployment_plan (here) instead, this would make pass eval_hooks args in a whole lot more of functions (and it comes with some difficulties down the line)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So this a wanted behavior for better coverage handling; It doesn't really impact code coverage % though

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 93.04348% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
components/clarity-repl/src/repl/session.rs 94.93% 4 Missing ⚠️
components/clarinet-deployments/src/onchain/mod.rs 0.00% 2 Missing ⚠️
components/clarinet-cli/src/frontend/dap.rs 0.00% 1 Missing ⚠️
components/clarity-events/src/bin.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In Review
Development

Successfully merging this pull request may close these issues.

1 participant