diff --git a/CHANGELOG.md b/CHANGELOG.md index 419259878..0d5b70c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## v1.59.0 (2023-10-17) + +### Features + + * use region property + +## v1.58.1 (2023-10-16) + +### Bug Fixes and Other Changes + + * use separate aws session for python validation + ## v1.58.0 (2023-10-16) ### Features diff --git a/src/braket/_sdk/_version.py b/src/braket/_sdk/_version.py index 4c7bbd320..ee48017dc 100644 --- a/src/braket/_sdk/_version.py +++ b/src/braket/_sdk/_version.py @@ -15,4 +15,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "1.58.1.dev0" +__version__ = "1.59.1.dev0" diff --git a/src/braket/aws/aws_quantum_job.py b/src/braket/aws/aws_quantum_job.py index 7f6fdfd05..76ff0648c 100644 --- a/src/braket/aws/aws_quantum_job.py +++ b/src/braket/aws/aws_quantum_job.py @@ -235,7 +235,7 @@ def _is_valid_aws_session_region_for_job_arn(aws_session: AwsSession, job_arn: s bool: `True` when the aws_session region matches the job_arn region; otherwise `False`. """ job_region = job_arn.split(":")[3] - return job_region == aws_session.braket_client.meta.region_name + return job_region == aws_session.region @staticmethod def _default_session_for_job_arn(job_arn: str) -> AwsSession: diff --git a/src/braket/jobs/hybrid_job.py b/src/braket/jobs/hybrid_job.py index 83ba9a9f0..521da7fe8 100644 --- a/src/braket/jobs/hybrid_job.py +++ b/src/braket/jobs/hybrid_job.py @@ -150,8 +150,7 @@ def hybrid_job( logger (Logger): Logger object with which to write logs, such as task statuses while waiting for task to be in a terminal state. Default is `getLogger(__name__)` """ - aws_session = aws_session or AwsSession() - _validate_python_version(aws_session, image_uri) + _validate_python_version(image_uri, aws_session) def _hybrid_job(entry_point): @functools.wraps(entry_point) @@ -209,8 +208,9 @@ def job_wrapper(*args, **kwargs): return _hybrid_job -def _validate_python_version(aws_session: AwsSession, image_uri: str | None): +def _validate_python_version(image_uri: str | None, aws_session: AwsSession | None = None): """Validate python version at job definition time""" + aws_session = aws_session or AwsSession() # user provides a custom image_uri if image_uri and image_uri not in built_in_images(aws_session.region): print( diff --git a/test/unit_tests/braket/aws/test_aws_quantum_job.py b/test/unit_tests/braket/aws/test_aws_quantum_job.py index ffc9bdb39..19b46d72b 100644 --- a/test/unit_tests/braket/aws/test_aws_quantum_job.py +++ b/test/unit_tests/braket/aws/test_aws_quantum_job.py @@ -43,7 +43,7 @@ def fake_copy_session(region): _aws_session.copy_session.side_effect = fake_copy_session _aws_session.list_keys.return_value = ["job-path/output/model.tar.gz"] - _aws_session.region = "us-test-1" + _aws_session.region = job_region _braket_client_mock = Mock(meta=Mock(region_name=job_region)) _aws_session.braket_client = _braket_client_mock @@ -142,7 +142,7 @@ def quantum_job(quantum_job_arn, aws_session): def test_equality(quantum_job_arn, aws_session, job_region): - new_aws_session = Mock(braket_client=Mock(meta=Mock(region_name=job_region))) + new_aws_session = Mock(region=job_region) quantum_job_1 = AwsQuantumJob(quantum_job_arn, aws_session) quantum_job_2 = AwsQuantumJob(quantum_job_arn, aws_session) quantum_job_3 = AwsQuantumJob(quantum_job_arn, new_aws_session) @@ -195,7 +195,7 @@ def test_quantum_job_constructor_invalid_region(aws_session): @patch("braket.aws.aws_quantum_job.boto3.Session") def test_quantum_job_constructor_explicit_session(mock_session, quantum_job_arn, job_region): - aws_session_mock = Mock(braket_client=Mock(meta=Mock(region_name=job_region))) + aws_session_mock = Mock(region=job_region) job = AwsQuantumJob(quantum_job_arn, aws_session_mock) assert job._aws_session == aws_session_mock assert job.arn == quantum_job_arn @@ -507,7 +507,7 @@ def role_arn(): @pytest.fixture( params=[ - "arn:aws:braket:us-test-1::device/qpu/test/device-name", + "arn:aws:braket:us-west-2::device/qpu/test/device-name", "arn:aws:braket:::device/qpu/test/device-name", ] ) @@ -961,7 +961,7 @@ def test_no_region_routing_simulator(aws_session): ) device_arn = "arn:aws:braket:::device/simulator/test/device-name" - device_not_found = f"Simulator '{device_arn}' not found in 'us-test-1'" + device_not_found = f"Simulator '{device_arn}' not found in 'us-west-2'" with pytest.raises(ValueError, match=device_not_found): AwsQuantumJob._initialize_session(aws_session, device_arn, logger)