nox icon indicating copy to clipboard operation
nox copied to clipboard

"WARNING: No metadata found in ..." when trying to re-install a package from git in existing environment

Open alexmelekhin opened this issue 1 year ago • 0 comments

I want to run tests that require package MinkowskiEngine that should be build and installed from git with the command pip install git+https://github.com/NVIDIA/MinkowskiEngine --no-deps. I do it with a command session.install("git+https://github.com/NVIDIA/MinkowskiEngine", "--no-deps", silent=False).

If run session with command nox -s "tests(python='3.8', pytorch='1.12.1')" everything works fine, but if I add -r flag to save time, the session.install of MinkowskiEngine works in a strange way: every odd (first, third, and so on) attempt is successful, but every even (second, fourth, and so on) does not even start an installation of the package with a WARNING: No metadata found in ./.nox/tests-python-3-8-pytorch-1-12-1/lib/python3.8/site-packages.

The session code:

ef install_cpu_torch(session: Session, pytorch: str = "1.12.1") -> None:
    """Install the CPU version of PyTorch."""
    session.install(
        f"torch=={pytorch}+cpu",
        f"torchvision=={TORCHVISION_VERSIONS_DICT[pytorch]}+cpu",
        "--extra-index-url",
        "https://download.pytorch.org/whl/cpu",
    )


def install_minkowskiengine(session: Session) -> None:
    """Install the MinkowskiEngine."""
    session.install("setuptools==68.0.0")
    session.install("git+https://github.com/NVIDIA/MinkowskiEngine", "--no-deps", silent=False)


@nox.session
@nox.parametrize(
    "python,pytorch",
    [
        (python, pytorch)
        for python in PYTHON_VERSIONS
        for pytorch in PYTORCH_VERSIONS
        if (python, pytorch) not in (("3.11", "1.12.1"), ("3.11", "1.13.1"))
    ],
)
def tests(session: Session, pytorch: str) -> None:
    """Run the test suite."""
    args = session.posargs or ["--cov"]
    install_cpu_torch(session, pytorch)
    install_minkowskiengine(session)
    session.install("-e", ".")
    session.install("-r", "requirements-dev.txt")
    session.run("pytest", *args)

First time I run the session with the command nox -rs "tests(python='3.8', pytorch='1.12.1')":

docker_opr@cdsmelekhin:~/OpenPlaceRecognition$ nox -rs "tests(python='3.8', pytorch='1.12.1')"                                                                                                                     
nox > Running session tests(python='3.8', pytorch='1.12.1')                                                                                                                                                        
nox > Re-using existing virtual environment at .nox/tests-python-3-8-pytorch-1-12-1.                                                                                                                               
nox > python -m pip install torch==1.12.1+cpu torchvision==0.13.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu                                                                                       
nox > python -m pip install setuptools==68.0.0                                                                                                                                                                     
nox > python -m pip install git+https://github.com/NVIDIA/MinkowskiEngine --no-deps                                                                                                                                
Collecting git+https://github.com/NVIDIA/MinkowskiEngine                                                                                                                                                           
  Cloning https://github.com/NVIDIA/MinkowskiEngine to /tmp/pip-req-build-dj0k6vhz                                                                                                                                 
  Running command git clone --filter=blob:none --quiet https://github.com/NVIDIA/MinkowskiEngine /tmp/pip-req-build-dj0k6vhz                                                                                       
  Resolved https://github.com/NVIDIA/MinkowskiEngine to commit 02fc608bea4c0549b0a7b00ca1bf15dee4a0b228                                                                                                            
  Preparing metadata (setup.py) ... done                                                                                                                                                                           
Building wheels for collected packages: MinkowskiEngine                                                                                                                                                            
  Building wheel for MinkowskiEngine (setup.py) ... done                                                                                                                                                           
  Created wheel for MinkowskiEngine: filename=MinkowskiEngine-0.5.4-cp38-cp38-linux_x86_64.whl size=19579787 sha256=800bb113237973130ae7f88b9a9f0aa43e7a09a055c4b77dcc492c12cabb6230                               
  Stored in directory: /tmp/pip-ephem-wheel-cache-bxsqg_tx/wheels/38/a5/f0/d4be769dc2bfcfc6e424c1d797548f033ad742d891a2365a17                                                                                      
Successfully built MinkowskiEngine                                                                                                                                                                                 
Installing collected packages: MinkowskiEngine                                                                                                                                                                     
Successfully installed MinkowskiEngine-0.5.4                                                                                                                                                                       
nox > python -m pip install -e .                                                                                                                                                                                   
nox > python -m pip install -r requirements-dev.txt                                                                                                                                                                
nox > pytest --cov                                                                                                                                                                                                 
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.8.10, pytest-7.4.0, pluggy-1.2.0                                                                                                                                                        
rootdir: /home/docker_opr/OpenPlaceRecognition                                                                                                                                                                     
plugins: cov-4.1.0, hydra-core-1.3.2, typeguard-3.0.2
collected 3 items                                                                                                                                                                                                 

tests/test_const.py .                                                                                                                                                                                       [ 33%]
tests/test_utils.py .                                                                                                                                                                                       [ 66%]
tests/models/place_recognition/test_minkloc3d.py .                                                                                                                                                          [100%]

================================================================================================ warnings summary =================================================================================================

<some warnings unrelated to the problem>

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform linux, python 3.8.10-final-0 -----------
Name                                               Stmts   Miss  Cover
----------------------------------------------------------------------
src/opr/__init__.py                                    5      2    60%
src/opr/const.py                                      17      0   100%
src/opr/layers/eca.py                                 37     26    30%
src/opr/layers/gem.py                                 34     13    62%
src/opr/models/__init__.py                             0      0   100%
src/opr/models/place_recognition/__init__.py           1      0   100%
src/opr/models/place_recognition/minkloc3d.py        147     63    57%
src/opr/utils.py                                      73     52    29%
tests/__init__.py                                      0      0   100%
tests/models/place_recognition/test_minkloc3d.py      12      0   100%
tests/test_const.py                                   17      0   100%
tests/test_utils.py                                   16      0   100%
----------------------------------------------------------------------
TOTAL                                                359    156    57%

========================================================================================= 3 passed, 16 warnings in 0.78s ==========================================================================================
nox > Session tests(python='3.8', pytorch='1.12.1') was successful.

The next time with the same nox -rs "tests(python='3.8', pytorch='1.12.1')":

docker_opr@cdsmelekhin:~/OpenPlaceRecognition$ nox -rs "tests(python='3.8', pytorch='1.12.1')"                                                                                                                     
nox > Running session tests(python='3.8', pytorch='1.12.1')                                                                                                                                                        
nox > Re-using existing virtual environment at .nox/tests-python-3-8-pytorch-1-12-1.                                                                                                                               
nox > python -m pip install torch==1.12.1+cpu torchvision==0.13.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu                                                                                       
nox > python -m pip install setuptools==68.0.0                                                                                                                                                                     
nox > python -m pip install git+https://github.com/NVIDIA/MinkowskiEngine --no-deps                                                                                                                                
Collecting git+https://github.com/NVIDIA/MinkowskiEngine                                                                                                                                                           
  Cloning https://github.com/NVIDIA/MinkowskiEngine to /tmp/pip-req-build-vs_8qkay
  Running command git clone --filter=blob:none --quiet https://github.com/NVIDIA/MinkowskiEngine /tmp/pip-req-build-vs_8qkay
  Resolved https://github.com/NVIDIA/MinkowskiEngine to commit 02fc608bea4c0549b0a7b00ca1bf15dee4a0b228
  Preparing metadata (setup.py) ... done
WARNING: No metadata found in ./.nox/tests-python-3-8-pytorch-1-12-1/lib/python3.8/site-packages
nox > python -m pip install -e .
nox > python -m pip install -r requirements-dev.txt
nox > pytest --cov
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.8.10, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/docker_opr/OpenPlaceRecognition
plugins: cov-4.1.0, hydra-core-1.3.2, typeguard-3.0.2
collected 2 items / 1 error                                                                                                                                                                                       

===================================================================================================== ERRORS ======================================================================================================
________________________________________________________________________ ERROR collecting tests/models/place_recognition/test_minkloc3d.py ________________________________________________________________________
ImportError while importing test module '/home/docker_opr/OpenPlaceRecognition/tests/models/place_recognition/test_minkloc3d.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/models/place_recognition/test_minkloc3d.py:8: in <module>
    from opr.models.place_recognition.minkloc3d import MinkLoc3D
src/opr/models/place_recognition/__init__.py:2: in <module>
    from .minkloc3d import MinkLoc3D
src/opr/models/place_recognition/minkloc3d.py:11: in <module>
    import MinkowskiEngine as ME
E   ModuleNotFoundError: No module named 'MinkowskiEngine'

---------- coverage: platform linux, python 3.8.10-final-0 -----------
Name                                               Stmts   Miss  Cover
----------------------------------------------------------------------
src/opr/__init__.py                                    5      2    60%
src/opr/const.py                                      17      5    71%
src/opr/models/__init__.py                             0      0   100%
src/opr/models/place_recognition/__init__.py           1      0   100%
src/opr/models/place_recognition/minkloc3d.py        147    145     1%
src/opr/utils.py                                      73     62    15%
tests/__init__.py                                      0      0   100%
tests/models/place_recognition/test_minkloc3d.py      12      7    42%
tests/test_const.py                                   17     11    35%
tests/test_utils.py                                   16     12    25%
----------------------------------------------------------------------
TOTAL                                                288    244    15%

============================================================================================= short test summary info =============================================================================================
ERROR tests/models/place_recognition/test_minkloc3d.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================================ 1 error in 0.75s =================================================================================================
nox > Command pytest --cov failed with exit code 2
nox > Session tests(python='3.8', pytorch='1.12.1') failed.

And if I run the same command in the third time it will complete successfully like in the first attempt. So, every odd attempt is successful, and every even is not.

How can I fix it and make session behaviour stable?

alexmelekhin avatar Jul 13 '23 12:07 alexmelekhin