I'm using scipy.loadmat to load a Matlab .mat file inside my Python unit tests. This arrangement works just fine on my desktop, and inside a Docker container running on my servers. However, I'm getting an error when I try to run the unit tests inside a Github action (my CI flow):
model_dict_tmp = loadmat(model_path)
File "/usr/local/lib/python3.6/dist-packages/scipy/io/matlab/mio.py", line 223, in loadmat
MR, _ = mat_reader_factory(f, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/scipy/io/matlab/mio.py", line 72, in mat_reader_factory
mjv, mnv = get_matfile_version(byte_stream)
File "/usr/local/lib/python3.6/dist-packages/scipy/io/matlab/miobase.py", line 231, in get_matfile_version
raise ValueError('Unknown mat file type, version %s, %s' % ret)
ValueError: Unknown mat file type, version 50, 52
The .mat file is stored inside a Github submodule (as an LFS object) and should be cloned along with the code. So I'm expecting a well-known location for the file:
mainproject/
submodule/
path/to/matfile.mat
tests/
test_matrix_loading.py # unit test that attempts to load the matrix
I cannot reproduce this error when spinning the same Docker image manually and running the CI as:
python -m unittest discover -s tests/
Which is the same instruction I use inside my action script.
- Why is this happening? This error is very recent and this arrangement used to work previously.
- How can I debug this?
CodePudding user response:
This ended up being due to a git lfs problem. The scipy.loadmat
error was just the manifestation.
See: Github Action: How to pull LFS files in submodule
For the solution.