Skip to content

tests/test_integration_cli.py::test_external_provider fails without activating virtual environment #58

@TimothyWillard

Description

@TimothyWillard

Might require upstreaming a fix of some kind to https://github.com/ACCIDDA/flepimop2. Not sure why this is a problem though, because I thought uv run modified the $PATH environment variable before running. Activating the virtual environment to run the tests is not required for https://github.com/ACCIDDA/flepimop2.

~/D/G/A/op_engine (empty, p, 4e, ⬇ main) > just clean
rm -rf site
rm -f uv.lock
rm -rf .venv
rm -rf .*_cache
rm -f flepimop2-op_engine/uv.lock
rm -rf flepimop2-op_engine/.venv
rm -rf flepimop2-op_engine/.*_cache
~/D/G/A/op_engine (empty, p, 4e, ⬇ main) > just
uv run ruff format --preview
Using CPython 3.11.12
Creating virtual environment at: .venv
      Built op-engine @ file:///Users/twillard/Desktop/GitHub/ACCIDDA/op_engine
Installed 51 packages in 366ms
25 files left unchanged
uv run ruff check --preview --fix
All checks passed!
uv run pytest --doctest-modules
================================================================================================ test session starts =================================================================================================
platform darwin -- Python 3.11.12, pytest-9.0.3, pluggy-1.6.0
rootdir: /Users/twillard/Desktop/GitHub/ACCIDDA/op_engine
configfile: pyproject.toml
testpaths: docs/, src/op_engine/, tests/
collected 95 items

tests/op_engine/test__version__.py .                                                                                                                                                                           [  1%]
tests/op_engine/test_core_solver_accuracy.py ..............                                                                                                                                                    [ 15%]
tests/op_engine/test_core_solver_plumbing.py ..................                                                                                                                                                [ 34%]
tests/op_engine/test_matrix_ops.py ....................................                                                                                                                                        [ 72%]
tests/op_engine/test_model_core.py ..........................                                                                                                                                                  [100%]

================================================================================================= 95 passed in 6.30s =================================================================================================
cd flepimop2-op_engine && uv venv --clear
Using CPython 3.11.12
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate.fish
cd flepimop2-op_engine && uv sync --dev
Resolved 23 packages in 351ms
      Built flepimop2-op-engine @ file:///Users/twillard/Desktop/GitHub/ACCIDDA/op_engine/flepimop2-op_engine
Prepared 1 package in 182ms
Installed 22 packages in 77ms
 + annotated-types==0.7.0
 + click==8.3.2
 + flepimop2==0.1.0 (from git+https://github.com/ACCIDDA/flepimop2.git@ba7f5e874ba418fc4e083347b117925a745a78fc)
 + flepimop2-op-engine==0.1.0 (from file:///Users/twillard/Desktop/GitHub/ACCIDDA/op_engine/flepimop2-op_engine)
 + iniconfig==2.3.0
 + librt==0.9.0
 + mypy==1.20.1
 + mypy-extensions==1.1.0
 + numpy==2.4.4
 + op-engine==0.1.0 (from git+https://github.com/ACCIDDA/op_engine.git@304545fb1bf2af32ffd26dd427d93063215f2f6f)
 + packaging==26.0
 + pathspec==1.0.4
 + pluggy==1.6.0
 + pydantic==2.13.0
 + pydantic-core==2.46.0
 + pygments==2.20.0
 + pytest==9.0.3
 + pyyaml==6.0.3
 + ruff==0.15.10
 + scipy==1.17.1
 + typing-extensions==4.15.0
 + typing-inspection==0.4.2
cd flepimop2-op_engine && .venv/bin/python -m pytest --doctest-modules
............................F                                                                                                                                                                                  [100%]
====================================================================================================== FAILURES ======================================================================================================
_______________________________________________________________________________________________ test_external_provider _______________________________________________________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10b64de90>, tmp_path = PosixPath('/private/var/folders/2z/h3pc0p7s3ng1tvxrgsw5kr680000gp/T/pytest-of-twillard/pytest-83/test_external_provider0')

    def test_external_provider(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
        """Run a simulation with an installed external op_engine provider package."""
        cwd = Path(__file__).parent.resolve()
>       external_provider_package(
            tmp_path,
            copy_files={
                cwd / "data" / "config.yaml": Path("config.yaml"),
                cwd / "data" / "sir.py": Path("external_provider")
                / "src"
                / "flepimop2"
                / "system"
                / "sir.py",
            },
            dependencies=["op-engine"],
        )

tests/test_integration_cli.py:14:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.11/site-packages/flepimop2/testing.py:206: in external_provider_package
    python = _which_python()
             ^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def _which_python() -> str:
        """
        Find the 'python' executable in the system PATH.

        Returns:
            The absolute path to the 'python' executable as a string.

        Raises:
            RuntimeError: If the 'python' executable is not found in PATH.

        """
        result = which("python")
        if result is None:
            msg = "python executable not found in PATH"
>           raise RuntimeError(msg)
E           RuntimeError: python executable not found in PATH

.venv/lib/python3.11/site-packages/flepimop2/testing.py:24: RuntimeError
============================================================================================== short test summary info ===============================================================================================
FAILED tests/test_integration_cli.py::test_external_provider - RuntimeError: python executable not found in PATH
1 failed, 28 passed in 5.49s
error: Recipe `pytest-provider` failed on line 36 with exit code 1
~/D/G/A/op_engine (empty, p, 4e, ⬇ main) [1] > a
Activated virtual environment from .venv
(op-engine) ~/D/G/A/op_engine (empty, p, 4e, ⬇ main) > just
...
(op-engine) ~/D/G/A/op_engine (empty, p, 4e, ⬇ main) >

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingproviderflepimop2 provider/connector packagetestingTest infrastructure and accuracy benchmarks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions