Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set python container version explicitly #776

Merged
merged 5 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched this test to use the return method for more variety


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())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this line lower so if something above fails the results assert will fail


job = decorator_job_submodule()
assert job.result()["status"] == "SUCCESS"