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

Try sharing common parts of workflow compute to make tests run faster #182

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

Conversation

SimonHeybrock
Copy link
Member

This is demonstrating an approach that could save some test runtime. In this example a parametrized test is running a nearly identical workflow 8 times, each time loading data from scratch, etc.

The change here moves some of the common parts into a module-scope fixture. On my machine this reduces the test runtime from 50 seconds to 22 seconds.

I do not know if this is a great solution. If we want to go with this, a helper utility could be made: Given a sciline.Pipeline and a set of keys, compute all intermediate results that to not depend on those keys and set the results as "static" data in the workflow. This would avoid error-prone manual authoring of fixtures like the one I added here.

This is demonstrating an approach that could save some test runtime. In
this example a parametrized test is running a nearly identical workflow
8 times, each time loading data from scratch, etc.

The change here moves some of the common parts into a module-scope
fixture. On my machine this reduces the test runtime from 50 seconds to
22 seconds.

I do not know if this is a great solution. If we want to go with this, a
helper utility could be made: Given a sciline.Pipeline and a set of
keys, compute all intermediate results that to not depend on those keys
and set the results as "static" data in the workflow. This would avoid
error-prone manual authoring of fixtures like the one I added here.
@@ -98,10 +121,11 @@ def test_pipeline_can_compute_IofQ(uncertainties, qxy: bool):
BackgroundSubtractedIofQxy,
],
)
def test_pipeline_can_compute_IofQ_in_event_mode(uncertainties, target):
pipeline = make_workflow()
def test_pipeline_can_compute_IofQ_in_event_mode(
Copy link
Member

Choose a reason for hiding this comment

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

I think the approach is fine. The test looks almost identical to before, it just has a fixture which has some pre-computed stuff in it. It's not making some tests depend on others or anything like that.

How does it change the overall time it takes to run all tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

How does it change the overall time it takes to run all tests?

You would have to do something similar for quite a few more tests. But the worse offender is currently the beam-center finder, but I don't feel it is worth playing with that.

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.

2 participants