Closed sfmig closed 11 months ago
Attention: 21 lines
in your changes are missing coverage. Please review.
Comparison is base (
afba965
) 80.85% compared to head (466667c
) 81.31%. Report is 5 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
These two questions relate to our live discussion of where the workflow data should live, and to a further thought of mine that feels that a lot of the test code is still a bit complicated.
- I think I went down a parametrisations 🐰 🕳️ , maybe some are redundant? Any feedback on this is welcome!
I think the parametrisations you've done are fine, but I'd say the if
statement distinguishing two tests is a minor code smell. Maybe split the default case off into a separate test that doesn't require parametrisation?
- The tests are a bit slow to run, mainly because often I download the data from GIN. Should I look into caching this? Right now I don't because I download the data to a pytest temp dir, which is different for each test run.
Yes, I think caching is worth it long-term to improve the development experience. If we move to using paths relative to $HOME
as discussed, I would mock Path.home()
as done in brainrender-napari
instead of using tmp_path
which would simplify both the test code and the caching..
The test code would then be something like:
def test_main(
):
"""Test main function for setting up and running cellfinder workflow (default case)
"""
# mocking of $HOME in conftest.py takes care that test data and user data are separate
cfg = main()
# check output files exist
assert (cfg.detected_cells_path).is_file()
@pytest.mark.parametrize(
"input_config",
[
"input_config_fetch_GIN",
"input_config_fetch_local",
],
)
def test_main_non_default(
):
"""Test main function for setting up and running cellfinder workflow
Parameters
----------
input_config : Optional[str]
Path to input config json file
"""
# mocking of $HOME in conftest.py takes care that test data and user data are separate
cfg = main(str(Path.home()/".brainglobe/cellfinder/workflows"/input_config))
# check output files exist
assert (cfg.detected_cells_path).is_file()
This can also be part of a separate PR
A PR for refactoring the cellfinder workflow tests, following the feedback collected on issue #26.
Main features
They address the points from issue #26:
utils.py
moduleconftest.py
for the fixtures that are shared between unit and integration tests. I also use an additionalconftest.py
for the fixtures shared between utils unit tests and cellfinder-specific unit tests.make_config
helper functions by config files that are part of the test dataOther additions
brainglobe_workflows/configs
)benchmarks
directory tobrainglobe_benchmarks
cellfinder
subdirectory underbrainglobe_workflows
cellfinder-workflow
Comments / questions
arparse
by typer, and the code look cleaner and more readable, but at the cost of adding an extra dependency. Chatting to Adam he mentioned in brainglobe we try to keep dependencies lists short, so I reverted back toargparse
but let me know if you have any thoughts about it.