Skip to content

Commit

Permalink
Merge branch 'main' into feature/autoqasm
Browse files Browse the repository at this point in the history
  • Loading branch information
rmshaffer authored Oct 17, 2023
2 parents d2e4635 + 4cc0eba commit f51964f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/braket/_sdk/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "1.58.1.dev0"
__version__ = "1.59.1.dev0"
2 changes: 1 addition & 1 deletion src/braket/aws/aws_quantum_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/braket/jobs/hybrid_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions test/unit_tests/braket/aws/test_aws_quantum_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
]
)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit f51964f

Please sign in to comment.