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

Add snoop as potential run option #3

Merged
merged 12 commits into from
Apr 13, 2022
Merged

Add snoop as potential run option #3

merged 12 commits into from
Apr 13, 2022

Conversation

winniederidder
Copy link
Collaborator

@winniederidder winniederidder commented Apr 12, 2022

Adds features discussed in dodona-edu/papyros#109 (comment)
Extra:
run and run_async accept arbitrary kwargs which are passed to execute, which can then be passed to e.g. exec_snoop to set Snoop config values.

I wasn't entirely sure what to do with the internal directory updates you did in futurecoder. Is this something we want in general, to also trace our inner workings? I don't see how I would want that for example in Papyros, or is that needed to be able to trace the methods in the user's file?

@coveralls
Copy link

coveralls commented Apr 12, 2022

Pull Request Test Coverage Report for Build 2157877032

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2090472257: 0.0%
Covered Lines: 212
Relevant Lines: 212

💛 - Coveralls

Copy link
Owner

@alexmojaki alexmojaki left a comment

Choose a reason for hiding this comment

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

Thanks. Instead of just passing through kwargs, I think there should be an optional snoop_config argument, and that should be used to populate the snoop Config so that things other than color can be changed.

.github/workflows/pytest.yml Outdated Show resolved Hide resolved
python_runner/runner.py Outdated Show resolved Hide resolved
python_runner/snoop.py Outdated Show resolved Hide resolved
tests/test_runner.py Show resolved Hide resolved
@winniederidder
Copy link
Collaborator Author

Thanks. Instead of just passing through kwargs, I think there should be an optional snoop_config argument, and that should be used to populate the snoop Config so that things other than color can be changed.

I added a method snoop_config for this in the runner, which hopefully provides this flexibility then.

setup.cfg Outdated Show resolved Hide resolved
@alexmojaki
Copy link
Owner

How is snoop_config meant to be used? By overriding it in a subclass? Are users expected to call it? When does the default in exec_snoop get used?

@winniederidder
Copy link
Collaborator Author

How is snoop_config meant to be used? By overriding it in a subclass? Are users expected to call it? When does the default in exec_snoop get used?

Subclasses can indeed override snoop_config to tune it to their needs. They shouldn't need to call it themselves unless they also override execute in this case. The default in exec_snoop is currently not used, so that could be removed I suppose.

tests/test_runner.py Outdated Show resolved Hide resolved
@alexmojaki
Copy link
Owner

How is snoop_config meant to be used? By overriding it in a subclass? Are users expected to call it? When does the default in exec_snoop get used?

Subclasses can indeed override snoop_config to tune it to their needs. They shouldn't need to call it themselves unless they also override execute in this case. The default in exec_snoop is currently not used, so that could be removed I suppose.

One problem with this API is that it's not easy to extend the default behaviour with a small tweak. You pretty much have to copy the code from the original method. Snoop's Config doesn't support copying or incremental changes.

@winniederidder
Copy link
Collaborator Author

How is snoop_config meant to be used? By overriding it in a subclass? Are users expected to call it? When does the default in exec_snoop get used?

Subclasses can indeed override snoop_config to tune it to their needs. They shouldn't need to call it themselves unless they also override execute in this case. The default in exec_snoop is currently not used, so that could be removed I suppose.

One problem with this API is that it's not easy to extend the default behaviour with a small tweak. You pretty much have to copy the code from the original method. Snoop's Config doesn't support copying or incremental changes.

What do you propose then? Something similar to the original approach using kwargs?

@alexmojaki
Copy link
Owner

Thanks. Instead of just passing through kwargs, I think there should be an optional snoop_config argument, and that should be used to populate the snoop Config so that things other than color can be changed.

To clarify, I meant that you'd call run(..., mode="snoop", snoop_config=dict(color=True)).

(color should be False by default, it uses ANSI codes)

tests/test_runner.py Outdated Show resolved Hide resolved
tests/test_runner.py Outdated Show resolved Hide resolved
python_runner/runner.py Outdated Show resolved Hide resolved
tests/test_runner.py Outdated Show resolved Hide resolved
python_runner/runner.py Outdated Show resolved Hide resolved
@alexmojaki alexmojaki self-requested a review April 12, 2022 22:26
@alexmojaki
Copy link
Owner

I wasn't entirely sure what to do with the internal directory updates you did in futurecoder. Is this something we want in general, to also trace our inner workings? I don't see how I would want that for example in Papyros, or is that needed to be able to trace the methods in the user's file?

On the contrary, it means that those internal directories shouldn't be traced. If you remove those lines, you can see a test failure with extra output from snoop tracing code from python_runner.

Thanks for the PR. I'm happy to merge, are you?

@winniederidder
Copy link
Collaborator Author

I wasn't entirely sure what to do with the internal directory updates you did in futurecoder. Is this something we want in general, to also trace our inner workings? I don't see how I would want that for example in Papyros, or is that needed to be able to trace the methods in the user's file?

On the contrary, it means that those internal directories shouldn't be traced. If you remove those lines, you can see a test failure with extra output from snoop tracing code from python_runner.

Thanks for the PR. I'm happy to merge, are you?

Good to know. Then I believe this is good to go! Could you then also create a new release?

@alexmojaki alexmojaki merged commit c6fbb43 into master Apr 13, 2022
@alexmojaki
Copy link
Owner

Released 0.6.0

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2157877032

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 43 of 43 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2090472257: 0.0%
Covered Lines: 212
Relevant Lines: 212

💛 - Coveralls

@coveralls
Copy link

coveralls commented Nov 28, 2024

Pull Request Test Coverage Report for Build 2157104796

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 38 of 42 (90.48%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.9%) to 98.148%

Changes Missing Coverage Covered Lines Changed/Added Lines %
python_runner/snoop.py 29 33 87.88%
Totals Coverage Status
Change from base Build 2090472257: -1.9%
Covered Lines: 212
Relevant Lines: 216

💛 - Coveralls

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