Add requests to requirements?
Issue: A new install of stone-soup into a venv, followed by pytest stonesoup raises an import error:
ImportError: Usage of opensky requires the dependency 'requests' is installed.
Suggested solution: add requests to the requirements in setup.py
Procedure to recreate:
git clone https://github.com/dstl/Stone-Soup.git
cd Stone-Soup
python -m venv venv
source venv/Scripts/activate
pip install -e .
pip install pytest
pytest stonesoup
Full Error message:
============================= test session starts =============================
platform win32 -- Python 3.9.4, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: C:\Users\edward\code\Stone-Soup2
collected 1175 items / 1 error / 2 skipped / 1172 selected
=================================== ERRORS ====================================
___________ ERROR collecting stonesoup/reader/tests/test_opensky.py ___________
ImportError while importing test module 'C:\Users\edward\code\Stone-Soup2\stonesoup\reader\tests\test_opensky.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
stonesoup\reader\opensky.py:7: in <module>
import requests
E ModuleNotFoundError: No module named 'requests'
The above exception was the direct cause of the following exception:
C:\Program Files\Python39\lib\importlib\__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
stonesoup\reader\tests\test_opensky.py:3: in <module>
from ..opensky import OpenSkyNetworkDetectionReader, OpenSkyNetworkGroundTruthReader
stonesoup\reader\opensky.py:10: in <module>
raise ImportError(
E ImportError: Usage of opensky requires the dependency 'requests' is installed.
=========================== short test summary info ===========================
ERROR stonesoup/reader/tests/test_opensky.py
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
========================= 2 skipped, 1 error in 8.25s =========================
For tests to run, you need to also install development requirements.
pip install -e .[dev]
Maybe we could document this better somewhere.
I did consider this, but thought (wrongly) it wouldn't help as requests isn't in extras_require, but of course, it is a requirement of Sphinx, so implicitly included. As it is required independently of Sphinx, should it be added explicitly?
Come to think of it: it is a requirement for stonesoup.reader.opensky to import, not just to run the tests, so maybe requests should be a (non-dev) dependency (as ordered-set is, for example).
I did consider this, but thought (wrongly) it wouldn't help as requests isn't in
extras_require, but of course, it is a requirement of Sphinx, so implicitly included. As it is required independently of Sphinx, should it be added explicitly?
Yeah, it probably should.
Come to think of it: it is a requirement for
stonesoup.reader.openskyto import, not just to run the tests, so mayberequestsshould be a (non-dev) dependency (asordered-setis, for example).
I think as it's only required for one reader we can leave it optional, but we could add extra requires for it. Note that if someone does try to use it currently, at least the error message explains they have to install requests, rather than being non-obvious error.