From 343f2be46fc76d0e973555ddc2a252b8fa142447 Mon Sep 17 00:00:00 2001 From: Abe Coull <85974725+math411@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:36:54 -0800 Subject: [PATCH 1/5] fix: add force flag for import testing (#864) --- doc/conf.py | 1 + src/braket/aws/aws_device.py | 8 +++++--- src/braket/aws/aws_quantum_job.py | 8 +++++--- src/braket/aws/aws_quantum_task.py | 6 +++--- src/braket/circuits/gate.py | 8 +++++--- src/braket/pulse/pulse_sequence.py | 8 ++++---- src/braket/quantum_information/pauli_string.py | 8 +++++--- test/unit_tests/braket/aws/common_test_utils.py | 14 ++++++++------ test/unit_tests/braket/test_imports.py | 2 +- 9 files changed, 37 insertions(+), 26 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 23e9abdcf..2a8193e55 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,4 +1,5 @@ """Sphinx configuration.""" + import datetime import pkg_resources diff --git a/src/braket/aws/aws_device.py b/src/braket/aws/aws_device.py index 503834dd8..14adacb3a 100644 --- a/src/braket/aws/aws_device.py +++ b/src/braket/aws/aws_device.py @@ -332,9 +332,11 @@ def _get_regional_device_session(self, session: AwsSession) -> AwsSession: self._populate_properties(region_session) return region_session except ClientError as e: - raise ValueError(f"'{self._arn}' not found") if e.response["Error"][ - "Code" - ] == "ResourceNotFoundException" else e + raise ( + ValueError(f"'{self._arn}' not found") + if e.response["Error"]["Code"] == "ResourceNotFoundException" + else e + ) def _get_non_regional_device_session(self, session: AwsSession) -> AwsSession: current_region = session.region diff --git a/src/braket/aws/aws_quantum_job.py b/src/braket/aws/aws_quantum_job.py index 562c61ba8..31347311e 100644 --- a/src/braket/aws/aws_quantum_job.py +++ b/src/braket/aws/aws_quantum_job.py @@ -609,9 +609,11 @@ def _initialize_regional_device_session( aws_session.get_device(device) return aws_session except ClientError as e: - raise ValueError(f"'{device}' not found.") if e.response["Error"][ - "Code" - ] == "ResourceNotFoundException" else e + raise ( + ValueError(f"'{device}' not found.") + if e.response["Error"]["Code"] == "ResourceNotFoundException" + else e + ) @staticmethod def _initialize_non_regional_device_session( diff --git a/src/braket/aws/aws_quantum_task.py b/src/braket/aws/aws_quantum_task.py index 0785c03c5..7b349310b 100644 --- a/src/braket/aws/aws_quantum_task.py +++ b/src/braket/aws/aws_quantum_task.py @@ -534,9 +534,9 @@ def _download_result( "has_reservation_arn": self._has_reservation_arn_from_metadata(current_metadata), } try: - task_event[ - "execution_duration" - ] = self._result.additional_metadata.simulatorMetadata.executionDuration + task_event["execution_duration"] = ( + self._result.additional_metadata.simulatorMetadata.executionDuration + ) except AttributeError: pass broadcast_event(_TaskCompletionEvent(**task_event)) diff --git a/src/braket/circuits/gate.py b/src/braket/circuits/gate.py index 2183a2329..907c495ce 100644 --- a/src/braket/circuits/gate.py +++ b/src/braket/circuits/gate.py @@ -180,9 +180,11 @@ def _to_openqasm( for state, group in groupby(control_basis_state.as_tuple): modifier_name = "neg" * (not state) + "ctrl" control_modifiers += [ - f"{modifier_name}" - if (num_control := len(list(group))) == 1 - else f"{modifier_name}({num_control})" + ( + f"{modifier_name}" + if (num_control := len(list(group))) == 1 + else f"{modifier_name}({num_control})" + ) ] control_modifiers.append("") qubits = control_qubits + target_qubits diff --git a/src/braket/pulse/pulse_sequence.py b/src/braket/pulse/pulse_sequence.py index bb783c69b..98ea3c381 100644 --- a/src/braket/pulse/pulse_sequence.py +++ b/src/braket/pulse/pulse_sequence.py @@ -387,10 +387,10 @@ def _parse_from_calibration_schema( argument_value.update(QubitSet(int(argument["value"]))) instr_args["qubits_or_frames"] = argument_value elif argument["name"] in instr_args_keys: - instr_args[ - argument["name"] - ] = calibration_sequence._parse_arg_from_calibration_schema( - argument, waveforms, frames + instr_args[argument["name"]] = ( + calibration_sequence._parse_arg_from_calibration_schema( + argument, waveforms, frames + ) ) else: instr_args["qubits_or_frames"] = [] diff --git a/src/braket/quantum_information/pauli_string.py b/src/braket/quantum_information/pauli_string.py index 8dca06625..f1ca55406 100644 --- a/src/braket/quantum_information/pauli_string.py +++ b/src/braket/quantum_information/pauli_string.py @@ -101,9 +101,11 @@ def weight_n_substrings(self, weight: int) -> tuple[PauliString, ...]: substrings = [] for indices in itertools.combinations(self._nontrivial, weight): factors = [ - self._nontrivial[qubit] - if qubit in set(indices).intersection(self._nontrivial) - else "I" + ( + self._nontrivial[qubit] + if qubit in set(indices).intersection(self._nontrivial) + else "I" + ) for qubit in range(self._qubit_count) ] substrings.append( diff --git a/test/unit_tests/braket/aws/common_test_utils.py b/test/unit_tests/braket/aws/common_test_utils.py index 2975912f1..f1d6d96df 100644 --- a/test/unit_tests/braket/aws/common_test_utils.py +++ b/test/unit_tests/braket/aws/common_test_utils.py @@ -353,12 +353,14 @@ def _create_task_args_and_kwargs( create_kwargs = extra_kwargs or {} create_kwargs.update( { - "poll_timeout_seconds": poll_timeout_seconds - if poll_timeout_seconds is not None - else default_poll_timeout, - "poll_interval_seconds": poll_interval_seconds - if poll_interval_seconds is not None - else default_poll_interval, + "poll_timeout_seconds": ( + poll_timeout_seconds if poll_timeout_seconds is not None else default_poll_timeout + ), + "poll_interval_seconds": ( + poll_interval_seconds + if poll_interval_seconds is not None + else default_poll_interval + ), "inputs": inputs, "gate_definitions": gate_definitions, "reservation_arn": reservation_arn, diff --git a/test/unit_tests/braket/test_imports.py b/test/unit_tests/braket/test_imports.py index bd545d943..728c6311f 100644 --- a/test/unit_tests/braket/test_imports.py +++ b/test/unit_tests/braket/test_imports.py @@ -13,7 +13,7 @@ def test_for_import_cycles(): # parameterized version wasn't able to correctly detect some circular imports when running tox. modules = get_modules_to_test() processes = [] - multiprocessing.set_start_method("spawn") + multiprocessing.set_start_method("spawn", force=True) for module in modules: # We create a separate process to make sure the imports do not interfere with each-other. process = multiprocessing.Process(target=import_module, args=(module,)) From 6d1d7fc206364302ad652e323ead864dc6242344 Mon Sep 17 00:00:00 2001 From: ci Date: Mon, 29 Jan 2024 22:39:35 +0000 Subject: [PATCH 2/5] prepare release v1.68.1 --- CHANGELOG.md | 6 ++++++ src/braket/_sdk/_version.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bafd45c3..6b587ce19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v1.68.1 (2024-01-29) + +### Bug Fixes and Other Changes + + * add force flag for import testing + ## v1.68.0 (2024-01-25) ### Features diff --git a/src/braket/_sdk/_version.py b/src/braket/_sdk/_version.py index 051177529..9dd7e0203 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.68.1.dev0" +__version__ = "1.68.1" From db0f1f26f400bff211442b3d291e9c173cf2da93 Mon Sep 17 00:00:00 2001 From: ci Date: Mon, 29 Jan 2024 22:39:35 +0000 Subject: [PATCH 3/5] update development version to v1.68.2.dev0 --- src/braket/_sdk/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/braket/_sdk/_version.py b/src/braket/_sdk/_version.py index 9dd7e0203..36ac7a1eb 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.68.1" +__version__ = "1.68.2.dev0" From 6f20c328b91e17ff6f1268174e66756eb2d88c1d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:27:42 -0800 Subject: [PATCH 4/5] infra: bump codecov/codecov-action from 3.1.4 to 3.1.5 (#863) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.4 to 3.1.5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/eaaf4bedf32dbdc6b720b63067d99c4d77d6047d...4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0) --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 42dda2020..74b49db9e 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -36,5 +36,5 @@ jobs: run: | tox -e unit-tests - name: Upload coverage report to Codecov - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5 if: ${{ strategy.job-index }} == 0 From 058108c52c50f751080dc32de17c5fb4ed13d046 Mon Sep 17 00:00:00 2001 From: Abe Coull <85974725+math411@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:55:23 -0800 Subject: [PATCH 5/5] fix: update batch circuit to limit repeat calls (#865) --- src/braket/aws/aws_quantum_task_batch.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/braket/aws/aws_quantum_task_batch.py b/src/braket/aws/aws_quantum_task_batch.py index 24ff15530..6c505e6ef 100644 --- a/src/braket/aws/aws_quantum_task_batch.py +++ b/src/braket/aws/aws_quantum_task_batch.py @@ -150,27 +150,36 @@ def _tasks_and_inputs( ]: inputs = inputs or {} + max_inputs_tasks = 1 single_task = isinstance( task_specifications, (Circuit, Problem, OpenQasmProgram, BlackbirdProgram, AnalogHamiltonianSimulation), ) single_input = isinstance(inputs, dict) + max_inputs_tasks = ( + max(max_inputs_tasks, len(task_specifications)) if not single_task else max_inputs_tasks + ) + max_inputs_tasks = ( + max(max_inputs_tasks, len(inputs)) if not single_input else max_inputs_tasks + ) + if not single_task and not single_input: if len(task_specifications) != len(inputs): raise ValueError( "Multiple inputs and task specifications must " "be equal in number." ) + if single_task: - task_specifications = repeat(task_specifications) + task_specifications = repeat(task_specifications, times=max_inputs_tasks) if single_input: - inputs = repeat(inputs) + inputs = repeat(inputs, times=max_inputs_tasks) tasks_and_inputs = zip(task_specifications, inputs) if single_task and single_input: - tasks_and_inputs = [next(tasks_and_inputs)] + tasks_and_inputs = list(tasks_and_inputs) tasks_and_inputs = list(tasks_and_inputs)