arup-group/pam

pytest failure at example notebooks,

fredshone opened this issue · 1 comments

fresh pull, env and install (using latest mamba instructions):

running pytest fails at smoke tests, due to not finding kernels, eg:

____________________________________________________________________________________________________ /Users/fred.shone/Projects/pam/examples/01_PAM_Getting_Started.ipynb ____________________________________________________________________________________________________
[gw1] darwin -- Python 3.9.16 /Users/fred.shone/mambaforge/envs/pam/bin/python3.9
Error - No such kernel: 'pam'
----------------------------------------------------------------------------------------------------------------------------- Captured log call ------------------------------------------------------------------------------------------------------------------------------
WARNING  traitlets:kernelspec.py:286 Kernelspec name pam cannot be found!
ERROR    traitlets:manager.py:92 No such kernel named pam
Traceback (most recent call last):
  File "/Users/fred.shone/mambaforge/envs/pam/lib/python3.9/site-packages/jupyter_client/manager.py", line 85, in wrapper
    out = await method(self, *args, **kwargs)
  File "/Users/fred.shone/mambaforge/envs/pam/lib/python3.9/site-packages/jupyter_client/manager.py", line 397, in _async_start_kernel
    kernel_cmd, kw = await self._async_pre_start_kernel(**kw)
  File "/Users/fred.shone/mambaforge/envs/pam/lib/python3.9/site-packages/jupyter_client/manager.py", line 359, in _async_pre_start_kernel
    self.kernel_spec,
  File "/Users/fred.shone/mambaforge/envs/pam/lib/python3.9/site-packages/jupyter_client/manager.py", line 182, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/Users/fred.shone/mambaforge/envs/pam/lib/python3.9/site-packages/jupyter_client/kernelspec.py", line 287, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named pam

I can run notebooks fine after identifying the correct kernel. But pytest error persists.

I can fix by explictly installing kernel within env: python3 -m ipykernel install --user --name pam. This command is also used in the github build pipeline. But not sure how to include in local install? maybe this.


Separate complaint. I would rather not run the smoke tests on pytest - they are relatively slow which is annoying during dev.

Running a single module, eg pytest tests/test_17_vehicles.py, addresses this but then coverage reports as failing. 🤷🏻 . No biggy - just a niggle. Also just discover no coverage option: pytest tests/test_17_vehicles.py --no-cov.

The notebook tests are effectively integration tests, so I can understand why you would want to avoid them.

You can just run pytests tests/ to run the unit test suite.

As you noted, --no-cov will ignore coverage.

Adding the kernel is the same as you would expect, just stop using python3: python -m ipykernel install --user --name pam or ipython kernel install --user --name=pam.

I'll add this info to the dev docs.