oxfordcontrol/osqp-wheels

Error in code-generation tests

bstellato opened this issue · 5 comments

Scripts seem to run and the tests pass except the code generation ones.
During code generation we create a custom python module

https://github.com/oxfordcontrol/osqp-python/blob/adf566681a4b34bfaf1a7f09cea47fed8742eb13/module/codegen/code_generator.py#L163-L182

and then we import it as in

https://github.com/oxfordcontrol/osqp-python/blob/adf566681a4b34bfaf1a7f09cea47fed8742eb13/tests/unittests/codegen_matrices_tests.py#L44

However the import command seem to fail (see here) giving the error

>       import vec_emosqp
E       ImportError: No module named vec_emosqp

I believe the docker image does not work well when importing .so files in python. From the basic debugging I did, it seems that the 'vec_emosqp.so' file is created in the docker image.

@matthew-brett I would appreciate any suggestions on this.

This would fix https://github.com/cvxgrp/cvxpy/issues/503

Is it possible that you usually test in-place builds? If so, could it be that you're expecting the .so file to be in the source tree?

One of the things that multibuild automates, is testing the wheel in a container other than the one in which it was built - just to make sure you're not depending on residual artifacts in the container.

The idea of code generation is that it is a function that creates a customized "embedded" version of this software that does not require memory allocations. It is useful for embedded applications. To make the user's life easier, we provide a small python wrapper around that code so that it can be imported as a python module.

The generated module (e.g., 'vec_emosqp') is just used in the testing. We do not include it as an artifact of the package.

However, it looks like Python does not want to import it within the Docker image. The strange thing is that if I list the files in the current directory with print(os.listdir(os.getcwd()) just before the import command, I clearly see the module file.

Note that the generated module is always copied to the current directory. This happens here:

https://github.com/oxfordcontrol/osqp-python/blob/adf566681a4b34bfaf1a7f09cea47fed8742eb13/module/codegen/code_generator.py#L180

I have also fixed the Appveyor scripts in the meanwhile. If we fix this problem, the osqp wheels are ready to go.

I get the same effect from:

pip install .
pytest

I think that's because the working directory from which you run the tests is not, by default, on the pytest Python path - see : https://docs.pytest.org/en/latest/pythonpath.html

It looks like the easiest way to fix that is:

python -m pytest

Thanks a lot! Apparently it started giving this issue with a more recent version of pytest. Now it seems all working. I have uploaded the manylinux wheels on pypi.

Nice - thanks very much for doing that.