man-group / notebooker

Productionise & schedule your Jupyter Notebooks as easily as you wrote them.
GNU Affero General Public License v3.0
860 stars 82 forks source link

docker, AttributeError: module 'pytest' has no attribute 'StashKey' #193

Open duterhappy opened 1 week ago

duterhappy commented 1 week ago

when I run docker-compose up, I met error: 251.2 251.2 The HTML pages are in build/sphinx/html. 251.4 + py.test tests 253.0 Traceback (most recent call last): 253.0 File "/opt/conda/bin//py.test", line 11, in 253.0 sys.exit(main()) 253.0 File "/opt/conda/lib/python3.8/site-packages/_pytest/config/init.py", line 105, in main 253.0 config = _prepareconfig(args, plugins) 253.0 File "/opt/conda/lib/python3.8/site-packages/_pytest/config/init.py", line 257, in _prepareconfig 253.0 return pluginmanager.hook.pytest_cmdline_parse( 253.0 File "/opt/conda/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in call 253.0 return self._hookexec(self, self.get_hookimpls(), kwargs) 253.0 File "/opt/conda/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec 253.0 return self._inner_hookexec(hook, methods, kwargs) 253.0 File "/opt/conda/lib/python3.8/site-packages/pluggy/manager.py", line 84, in 253.0 self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( 253.0 File "/opt/conda/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall 253.0 gen.send(outcome) 253.0 File "/opt/conda/lib/python3.8/site-packages/_pytest/helpconfig.py", line 90, in pytest_cmdline_parse 253.0 config = outcome.get_result() 253.0 File "/opt/conda/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result 253.0 raise ex[1].with_traceback(ex[2]) 253.0 File "/opt/conda/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall 253.0 res = hook_impl.function(*args) 253.0 File "/opt/conda/lib/python3.8/site-packages/_pytest/config/init.py", line 836, in pytest_cmdline_parse 253.0 self.parse(args) 253.0 File "/opt/conda/lib/python3.8/site-packages/_pytest/config/init.py", line 1044, in parse 253.0 self._preparse(args, addopts=addopts) 253.0 File "/opt/conda/lib/python3.8/site-packages/_pytest/config/init.py", line 992, in _preparse 253.0 self.pluginmanager.load_setuptools_entrypoints("pytest11") 253.0 File "/opt/conda/lib/python3.8/site-packages/pluggy/manager.py", line 299, in load_setuptools_entrypoints 253.0 plugin = ep.load() 253.0 File "/opt/conda/lib/python3.8/importlib/metadata.py", line 77, in load 253.0 module = import_module(match.group('module')) 253.0 File "/opt/conda/lib/python3.8/importlib/init.py", line 127, in import_module 253.0 return _bootstrap._gcd_import(name[level:], package, level) 253.0 File "", line 1014, in _gcd_import 253.0 File "", line 991, in _find_and_load 253.0 File "", line 975, in _find_and_load_unlocked 253.0 File "", line 671, in _load_unlocked 253.0 File "/opt/conda/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 152, in exec_module 253.0 exec(co, module.dict) 253.0 File "/opt/conda/lib/python3.8/site-packages/pytest_timeout.py", line 22, in 253.0 SESSION_TIMEOUT_KEY = pytest.StashKey[float]() 253.0 AttributeError: module 'pytest' has no attribute 'StashKey'

failed to solve: process "/bin/sh -c set -eux ; pip install -e \".[prometheus, test, docs]\" ; python -m ipykernel install --user --name=notebooker_kernel ; pip install nbformat jupyter-core jupyter-client Pandoc --upgrade ; pip install -r ./notebooker/notebook_templates_example/notebook_requirements.txt ; python setup.py develop ; python setup.py build_sphinx ; py.test tests ; python setup.py bdist_wheel --universal" did not complete successfully: exit code: 1

dudwe commented 2 days ago

Hey - I think this is due to the docker build test step failing due to the docker container using a very old version of pytest.

(base) b811078a6d0a:/workspace# conda  list | grep pytest
pytest                    5.4.3                    py38_0  
pytest-cov                5.0.0                    pypi_0    pypi
pytest-fixture-config     1.8.0                    pypi_0    pypi
pytest-server-fixtures    1.8.0                    pypi_0    pypi
pytest-shutil             1.8.0                    pypi_0    pypi
pytest-timeout            2.3.1                    pypi_0    pypi
pytest-xdist              3.6.1                    pypi_0    pypi

This version of pytest seems incompatible with pytest-timeout. To fix you can change the version in the setup.cfg.

test = openpyxl; pytest==7.0.0; mock; pytest-cov; pytest-timeout; pytest-xdist; pytest-server-fixtures; freezegun; hypothesis>=3.83.2

I used 7.0.0 as it is the latest version which continues to have support for py36, py37 and py38. https://docs.pytest.org/en/stable/backwards-compatibility.html

This resolves the error you are getting, but there are a large amount of tests which are failing.

-- Docs: https://docs.pytest.org/en/latest/warnings.html
============================================================================================================================== short test summary info ==============================================================================================================================ERROR tests/integration/test_e2e.py::test_run_report[fake/py_report] - TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
ERROR tests/integration/test_e2e.py::test_run_report[fake/ipynb_report] - TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
ERROR tests/integration/test_e2e.py::test_run_failing_report - TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
ERROR tests/integration/test_e2e.py::test_run_report_and_rerun[fake/py_report] - TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
ERROR tests/integration/test_e2e.py::test_run_report_and_rerun[fake/ipynb_report] - TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
ERROR tests/integration/test_e2e.py::test_run_report_hide_code[fake/py_report] - TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
ERROR tests/integration/test_e2e.py::test_run_report_hide_code[fake/ipynb_report] - TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
=========================================================================================================================== 1 warning, 7 errors in 5.94s ============================================================================================================================(base) e46d7415f00b:/workspa

I think these need to be individually fixed to resolve the docker compose.