Skip to content

Commit

Permalink
fix: set python container version explicitly (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajberdy authored Nov 1, 2023
1 parent e7bbc8a commit 524b1a1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/integ_tests/test_create_quantum_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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",
)
Expand All @@ -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:
Expand All @@ -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"

Expand All @@ -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",
)
Expand All @@ -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:
Expand All @@ -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"

0 comments on commit 524b1a1

Please sign in to comment.