hi-ml
hi-ml copied to clipboard
Simplify test discovery in VSCode
When opening the repository in VSCode and starting test discovery, it will break with the first attempt to import from health_ml. Similarly, running pytest in either of the package folders will break at the same place.
What should work:
- Running
pyteston the commandline at repository root should run all tests in the 3 core folders correctly - Running
pyteston the commandline inhi-ml,hi-ml-azureand histo should run tests in the respective folder - Running test discovery in VSCode should pick up at least the tests in
hi-mlandhi-ml-azure
Possible solutions:
- Require everyone to run
pip install -e .in thehi-mlandhi-ml-azurefolders before doing any work. This must be done before doing any work on the repository. Downside: Repo is not fully workable without this manual step, and there are chances people forget to do it. - Modify VSCode settings such that PYTHONPATH is modified before running pytest.
- Problem: Did not get that to work, example below
- Downside: This will not help on the commandline.
- Modify
conftest.pyto add the required source folders tosys.path.- Downside: This will then also run in the cloud builds. There, we do NOT want to use
hi-mlfrom source because we install it via a wheel intosite-packages. Could disable the path hacking via an environment variable.
- Downside: This will then also run in the cloud builds. There, we do NOT want to use
- Modify
pytest.inito contain thepythonpathfield, see doc.- Problem: I did not get that to work at all.
- Downside: Again, this should not be run in cloud builds because of the use of wheels.
For modifying VSCode to set PYTHONPATH when running pytest, I tried this in settings.json:
"terminal.integrated.env.windows": {
"PYTHONPATH":"${workspaceFolder}/hi-ml/src:${workspaceFolder}/hi-ml-azure/src"
},
"terminal.integrated.env.linux": {
"PYTHONPATH":"${workspaceFolder}/hi-ml/src:${workspaceFolder}/hi-ml-azure/src"
}
This could be tackled together with #192
Just to make sure, does this assume that VS Code's interpreter is pointing to a conda environment created with environment.yml?