Skip to content

Commit 616b70e

Browse files
committed
Use the python path from virtualenv in end to end tests
1 parent e11dd6b commit 616b70e

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

end-to-end-test/end_to_end_test/test_checkout.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import subprocess
77
import pytest # type: ignore
88

9+
from .utils import PYTHON_PATH
10+
911

1012
@pytest.mark.parametrize(
1113
"repository_backend,use_root",
@@ -17,7 +19,9 @@
1719
pytest.param("s3", True, marks=pytest.mark.external),
1820
],
1921
)
20-
def test_checkout(repository_backend, use_root, tmpdir, temp_bucket_factory, tmpdir_factory):
22+
def test_checkout(
23+
repository_backend, use_root, tmpdir, temp_bucket_factory, tmpdir_factory
24+
):
2125
tmpdir = str(tmpdir)
2226
if repository_backend == "s3":
2327
repository = "s3://" + temp_bucket_factory.s3()
@@ -68,7 +72,7 @@ def main():
6872
env = os.environ
6973
env["PATH"] = "/usr/local/bin:" + os.environ["PATH"]
7074

71-
cmd = ["python", "train.py"]
75+
cmd = [PYTHON_PATH, "train.py"]
7276
subprocess.run(cmd, cwd=tmpdir, env=env, check=True)
7377

7478
experiments = json.loads(

end-to-end-test/end_to_end_test/test_delete.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
import pytest # type: ignore
66

7-
from .utils import path_exists
7+
from .utils import path_exists, PYTHON_PATH
88

99

1010
@pytest.mark.parametrize(
@@ -17,7 +17,9 @@
1717
pytest.param("s3", True, marks=pytest.mark.external),
1818
],
1919
)
20-
def test_delete(repository_backend, use_root, tmpdir, temp_bucket_factory, tmpdir_factory):
20+
def test_delete(
21+
repository_backend, use_root, tmpdir, temp_bucket_factory, tmpdir_factory
22+
):
2123
tmpdir = str(tmpdir)
2224
if repository_backend == "s3":
2325
repository = "s3://" + temp_bucket_factory.s3()
@@ -57,7 +59,7 @@ def main():
5759
env = os.environ
5860
env["PATH"] = "/usr/local/bin:" + os.environ["PATH"]
5961

60-
cmd = ["python", "train.py", "--foo"]
62+
cmd = [PYTHON_PATH, "train.py", "--foo"]
6163
subprocess.run(cmd, cwd=tmpdir, env=env, check=True)
6264

6365
experiments = json.loads(
@@ -77,7 +79,10 @@ def main():
7779
assert path_exists(repository, checkpoint_storage_path)
7880

7981
subprocess.run(
80-
["replicate", "delete", "--force", checkpoint_id], cwd=tmpdir, env=env, check=True
82+
["replicate", "delete", "--force", checkpoint_id],
83+
cwd=tmpdir,
84+
env=env,
85+
check=True,
8186
)
8287

8388
experiments = json.loads(
@@ -100,7 +105,10 @@ def main():
100105
assert path_exists(repository, experiment_storage_path)
101106

102107
subprocess.run(
103-
["replicate", "delete", "--force", experiment_id], cwd=tmpdir, env=env, check=True
108+
["replicate", "delete", "--force", experiment_id],
109+
cwd=tmpdir,
110+
env=env,
111+
check=True,
104112
)
105113

106114
experiments = json.loads(

end-to-end-test/end_to_end_test/test_list.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest # type: ignore
55
from dateutil.parser import parse as parse_date
66

7-
from .utils import get_env
7+
from .utils import get_env, PYTHON_PATH
88

99

1010
@pytest.mark.parametrize(
@@ -58,7 +58,7 @@ def main():
5858

5959
env = get_env()
6060

61-
subprocess.run(["python", "train.py", "--foo"], cwd=tmpdir, env=env, check=True)
61+
subprocess.run([PYTHON_PATH, "train.py", "--foo"], cwd=tmpdir, env=env, check=True)
6262

6363
experiments = json.loads(
6464
subprocess.run(
@@ -106,7 +106,9 @@ def main():
106106
experiment.checkpoint(path=".", step=3)
107107
"""
108108
)
109-
subprocess.run(["python", "train2.py", exp["id"]], cwd=tmpdir, env=env, check=True)
109+
subprocess.run(
110+
[PYTHON_PATH, "train2.py", exp["id"]], cwd=tmpdir, env=env, check=True
111+
)
110112
experiments = json.loads(
111113
subprocess.run(
112114
["replicate", "--verbose", "list", "--json"],

end-to-end-test/end_to_end_test/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from google.cloud import storage as google_storage
66

77
ROOT_DIRECTORY = Path(__file__).parent.parent.parent
8+
PYTHON_PATH = os.path.abspath(os.path.join(ROOT_DIRECTORY, "venv/bin/python"))
89

910

1011
def get_env():
@@ -41,7 +42,7 @@ def path_exists(repository, path):
4142
s3.Object(root, str(path)).load()
4243
return True
4344
except botocore.exceptions.ClientError as e:
44-
if e.response['Error']['Code'] == "404":
45+
if e.response["Error"]["Code"] == "404":
4546
return False
4647
else:
4748
# Something else has gone wrong.

0 commit comments

Comments
 (0)