From 524b1a13e481c7bb931eda6cc4886cc6c0e6546c Mon Sep 17 00:00:00 2001 From: Aaron Berdy Date: Tue, 31 Oct 2023 18:11:37 -0700 Subject: [PATCH] fix: set python container version explicitly (#776) --- test/integ_tests/test_create_quantum_job.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/integ_tests/test_create_quantum_job.py b/test/integ_tests/test_create_quantum_job.py index 122fd8a69..3b1b8ae95 100644 --- a/test/integ_tests/test_create_quantum_job.py +++ b/test/integ_tests/test_create_quantum_job.py @@ -22,17 +22,18 @@ import pytest from job_test_module.job_test_submodule.job_test_submodule_file import submodule_helper +from braket.aws import AwsSession from braket.aws.aws_quantum_job import AwsQuantumJob from braket.devices import Devices from braket.jobs import Framework, get_input_data_dir, hybrid_job, retrieve_image, save_job_result -@pytest.fixture -def decorator_python_version(aws_session): +def decorator_python_version(): + aws_session = AwsSession() image_uri = retrieve_image(Framework.BASE, aws_session.region) tag = aws_session.get_full_image_tag(image_uri) major_version, minor_version = re.search(r"-py(\d)(\d+)-", tag).groups() - return major_version, minor_version + return int(major_version), int(minor_version) def test_failed_quantum_job(aws_session, capsys): @@ -200,7 +201,7 @@ def test_completed_quantum_job(aws_session, capsys): @pytest.mark.xfail( - (sys.version_info.major, sys.version_info.minor) != decorator_python_version, + (sys.version_info.major, sys.version_info.minor) != decorator_python_version(), raises=RuntimeError, reason="Python version mismatch", ) @@ -218,7 +219,6 @@ def __str__(self): input_data=str(Path("test", "integ_tests", "requirements")), ) def decorator_job(a, b: int, c=0, d: float = 1.0, **extras): - save_job_result(job_test_script.job_helper()) with open(Path(get_input_data_dir()) / "requirements.txt", "r") as f: assert f.readlines() == ["pytest\n"] with open(Path("test", "integ_tests", "requirements.txt"), "r") as f: @@ -244,6 +244,8 @@ def decorator_job(a, b: int, c=0, d: float = 1.0, **extras): with open("test/output_file.txt", "w") as f: f.write("hello") + return job_test_script.job_helper() + job = decorator_job(MyClass(), 2, d=5, extra_arg="extra_value") assert job.result()["status"] == "SUCCESS" @@ -264,7 +266,7 @@ def decorator_job(a, b: int, c=0, d: float = 1.0, **extras): @pytest.mark.xfail( - (sys.version_info.major, sys.version_info.minor) != decorator_python_version, + (sys.version_info.major, sys.version_info.minor) != decorator_python_version(), raises=RuntimeError, reason="Python version mismatch", ) @@ -283,7 +285,6 @@ def test_decorator_job_submodule(): }, ) def decorator_job_submodule(): - save_job_result(submodule_helper()) with open(Path(get_input_data_dir("my_input")) / "requirements.txt", "r") as f: assert f.readlines() == ["pytest\n"] with open(Path("test", "integ_tests", "requirements.txt"), "r") as f: @@ -304,6 +305,7 @@ def decorator_job_submodule(): ) as f: assert f.readlines() == ["pytest\n"] assert dir(pytest) + save_job_result(submodule_helper()) job = decorator_job_submodule() assert job.result()["status"] == "SUCCESS"