Skip to content

Implement a new loop-based approach to parametrizations. #229

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 23 commits into from
Mar 7, 2022

Conversation

tobiasraabe
Copy link
Member

@tobiasraabe tobiasraabe commented Feb 28, 2022

Closes #206, resolves #132.

Changes

This PR implements a new loop-based approach to parametrizations.

Todo

  • Add better typing for functions with pytask_meta attribute.
  • Document the new approach to parametrizations.

Maybes interesting for typing: https://github.com/python/mypy/issues/2087#issuecomment-432963659.

@tobiasraabe tobiasraabe added this to the v0.2.0 milestone Feb 28, 2022
@codecov
Copy link

codecov bot commented Mar 1, 2022

Codecov Report

Merging #229 (caaaa91) into main (8c0b2cf) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #229      +/-   ##
==========================================
+ Coverage   94.30%   94.37%   +0.07%     
==========================================
  Files          77       79       +2     
  Lines        6843     6956     +113     
==========================================
+ Hits         6453     6565     +112     
- Misses        390      391       +1     
Flag Coverage Δ
end_to_end 80.18% <97.91%> (+0.31%) ⬆️
integration 41.76% <36.11%> (-0.21%) ⬇️
unit 69.39% <43.75%> (-0.61%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/_pytask/__init__.py 66.66% <ø> (ø)
tests/test_parametrize.py 98.23% <ø> (-0.07%) ⬇️
src/_pytask/collect.py 94.47% <100.00%> (+0.06%) ⬆️
src/_pytask/hookspecs.py 100.00% <100.00%> (ø)
src/_pytask/mark/structures.py 93.84% <100.00%> (+0.29%) ⬆️
src/_pytask/models.py 100.00% <100.00%> (ø)
src/_pytask/parametrize.py 100.00% <100.00%> (ø)
src/_pytask/parametrize_utils.py 100.00% <100.00%> (ø)
src/_pytask/task.py 100.00% <100.00%> (ø)
src/_pytask/task_utils.py 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c0b2cf...caaaa91. Read the comment docs.

@tobiasraabe
Copy link
Member Author

Hi @janosg, @hmgaudecker,

I ping you for some intermediate feedback on the implementation before I start polishing it and writing some documentation. You can review the new interface in the test module test_task.py and also add comments elsewhere.

@hmgaudecker
Copy link
Contributor

hmgaudecker commented Mar 1, 2022

Thanks, just on my way to trying things out... Needed to add tabulate to get anything going, but tests are still failing on my machine.

Any ideas?

@tobiasraabe
Copy link
Member Author

tobiasraabe commented Mar 1, 2022

Yes, platforms have different limits on how many file handlers can be opened. Every tmp_path fixture is a new file handle Here is more info.

Increase the limit with something like ulimit -n 4048?

@hmgaudecker
Copy link
Contributor

Spot on, as always! Thanks!

@hmgaudecker
Copy link
Contributor

hmgaudecker commented Mar 1, 2022

a.m.a.z.i.n.g.

Nothing else to add.

Other than, perhaps, you'll need to be careful in the documentation not to publish all the different ways how to use that. I'd be all for the kwargs version, of course 😉. I am not sure I want to explain the from_signature version to many people. (though I agree it is beautiful)

Re kwargs: Adding tests for irregular dicts would be good (different keys in round 1 compared to round 2, subset / superset of task function args). And are name and id valid keys?

@hmgaudecker
Copy link
Contributor

hmgaudecker commented Mar 1, 2022

Other than, perhaps, you'll need to be careful in the documentation not to publish all the different ways how to use that.

What I mean is:

There should be one-- and preferably only one --obvious way to do it.

In general, I am a little scared of a (large) proliferation of ways how you can specify tasks. At least tutorials should focus on one sensible way that scales well IMHO, if power users want to do something else for whatever reason, fine.

@janosg
Copy link

janosg commented Mar 1, 2022

That was quick! Very nice test cases and very nice new interface!

Copy link
Contributor

@hmgaudecker hmgaudecker left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

One semantic thing: Assuming you want to continue supporting "old" parametrizations, I would call it "the pytest way". Just briefly mention that for experienced pytest users, that may be the most natural approach. But don't add it as the very first thing in the tutorial, or only for a transition period while trying to make the current user base switch.

@tobiasraabe
Copy link
Member Author

Looks great, thanks!

One semantic thing: Assuming you want to continue supporting "old" parametrizations, I would call it "the pytest way". Just briefly mention that for experienced pytest users, that may be the most natural approach. But don't add it as the very first thing in the tutorial, or only for a transition period while trying to make the current user base switch.

Thanks for your comments. Yes, it was meant for people who are looking for the previous docs and are confused. So, I think it makes sense to have it close to the top of the file for some time.

I think about deprecating pytest's way in the next minor or major version change. Whatever comes first. Removing it now would just annoy everyone. I think I will add a deprecation warning in v0.2.0 saying either to fix pytask<=0.2 or refactor the syntax. And I will add a flag to the configuration which disables the warning for v0.2.

@hmgaudecker
Copy link
Contributor

hmgaudecker commented Mar 3, 2022 via email

@tobiasraabe
Copy link
Member Author

@hmgaudecker and @janosg, this PR is ready for a final review if you like. No need to do it actually.

@hmgaudecker
Copy link
Contributor

hmgaudecker commented Mar 3, 2022 via email

Copy link

@janosg janosg left a comment

Choose a reason for hiding this comment

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

This is an amazing change and a very clean implementation!

When you remove "the pytest way" I think it would be good to leave in an error message that tells you the last version of pytask supporting the pytest way. Otherwise people who do not follow pytask closely and need to re-run an old project for a revision might be lost.

With these and some other changes, pytask has stopped being a pytest clone for tasks. You might want to adjust the documentation, readme and short descriptions in that direction.

@tobiasraabe tobiasraabe merged commit 3e41ebd into main Mar 7, 2022
@tobiasraabe tobiasraabe deleted the implement-new-parametrizations branch March 7, 2022 12:07
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.

ENH: Using named arguments in an iteration of a parametrization.
3 participants