Try sharing common parts of workflow compute to make tests run faster#182
Try sharing common parts of workflow compute to make tests run faster#182SimonHeybrock wants to merge 1 commit intomainfrom
Conversation
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.
| ) | ||
| def test_pipeline_can_compute_IofQ_in_event_mode(uncertainties, target): | ||
| pipeline = make_workflow() | ||
| def test_pipeline_can_compute_IofQ_in_event_mode( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
@SimonHeybrock I think we should come back to this. Test runtimes are also becoming an issue in |
|
Can we make the files smaller instead? And write more unit tests, instead of testing the full pipeline, where possible? |
See an implementation in scipp/essdiffraction#133 |
|
I had made an attempt a while ago to create small files fo tests: https://github.com/scipp/esssans/tree/smaller-test-files |
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.