From 32b5a0f0e33a2173d54a9c9c9c42342a8e4ac835 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 20 Mar 2024 11:57:49 -0700 Subject: [PATCH] Format all files with black-24.3.0 (#6513) Executed check/format-incremental --all --apply No change in code function. --- cirq-aqt/cirq_aqt/aqt_sampler.py | 6 +- cirq-core/cirq/_compat.py | 6 +- cirq-core/cirq/circuits/moment.py | 16 +- cirq-core/cirq/circuits/qasm_output_test.py | 22 +- .../contrib/qcircuit/qcircuit_diagram_info.py | 16 +- ...superconducting_qubits_noise_properties.py | 6 +- .../experiments/qubit_characterizations.py | 12 +- .../single_qubit_readout_calibration.py | 16 +- cirq-core/cirq/linalg/decompositions.py | 16 +- cirq-core/cirq/linalg/decompositions_test.py | 4 +- cirq-core/cirq/linalg/transformations_test.py | 2 +- cirq-core/cirq/ops/common_gates_test.py | 3 +- cirq-core/cirq/ops/controlled_gate_test.py | 4 +- cirq-core/cirq/ops/phased_iswap_gate_test.py | 4 +- cirq-core/cirq/ops/qid_util.py | 9 +- .../circuit_diagram_info_protocol.py | 8 +- cirq-core/cirq/protocols/commutes_protocol.py | 6 +- .../cirq/protocols/decompose_protocol.py | 3 +- .../cirq/protocols/decompose_protocol_test.py | 10 +- .../cirq/protocols/json_serialization.py | 3 +- cirq-core/cirq/protocols/pow_protocol_test.py | 4 +- cirq-core/cirq/sim/mux.py | 8 +- .../cirq/sim/simulation_product_state.py | 4 +- cirq-core/cirq/sim/simulator_base.py | 6 +- .../two_qubit_gate_tabulation.py | 1 + .../optimize_for_target_gateset_test.py | 4 +- .../cirq/transformers/transformer_api.py | 3 +- .../transformers/transformer_primitives.py | 20 +- .../transformer_primitives_test.py | 10 +- cirq-core/cirq/value/classical_data.py | 12 +- .../cirq_ft/algos/apply_gate_to_lth_target.py | 1 + cirq-ft/cirq_ft/algos/generic_select.py | 1 + cirq-ft/cirq_ft/algos/hubbard_model.py | 4 +- .../algos/qubitization_walk_operator.py | 1 + cirq-ft/cirq_ft/algos/select_and_prepare.py | 12 +- cirq-ft/cirq_ft/algos/state_preparation.py | 1 + cirq-ft/cirq_ft/infra/gate_with_registers.py | 11 +- .../cirq_ft/infra/t_complexity_protocol.py | 6 +- .../infra/t_complexity_protocol_test.py | 6 +- cirq-google/cirq_google/cloud/__init__.py | 2 +- .../cirq_google/cloud/quantum/__init__.py | 11 +- .../cloud/quantum_v1alpha1/__init__.py | 114 +-- .../quantum_engine_service/__init__.py | 5 +- .../quantum_engine_service/async_client.py | 839 +++++++--------- .../services/quantum_engine_service/client.py | 943 +++++++----------- .../services/quantum_engine_service/pagers.py | 279 ++++-- .../quantum_engine_service/transports/base.py | 511 +++++----- .../quantum_engine_service/transports/grpc.py | 221 ++-- .../transports/grpc_asyncio.py | 243 +++-- .../cloud/quantum_v1alpha1/types/engine.py | 544 ++-------- .../cloud/quantum_v1alpha1/types/quantum.py | 548 ++-------- .../engine/abstract_local_processor.py | 6 +- .../cirq_google/line/placement/greedy_test.py | 7 +- .../target_gatesets/sycamore_gateset.py | 8 +- cirq-ionq/cirq_ionq/ionq_gateset.py | 8 +- examples/direct_fidelity_estimation.py | 2 +- 56 files changed, 1795 insertions(+), 2783 deletions(-) diff --git a/cirq-aqt/cirq_aqt/aqt_sampler.py b/cirq-aqt/cirq_aqt/aqt_sampler.py index 861667c8eb9..10c0d214181 100644 --- a/cirq-aqt/cirq_aqt/aqt_sampler.py +++ b/cirq-aqt/cirq_aqt/aqt_sampler.py @@ -77,9 +77,9 @@ def _generate_json( RuntimeError: If the circuit is empty. """ - seq_list: List[ - Union[Tuple[str, float, List[int]], Tuple[str, float, float, List[int]]] - ] = [] + seq_list: List[Union[Tuple[str, float, List[int]], Tuple[str, float, float, List[int]]]] = ( + [] + ) circuit = cirq.resolve_parameters(circuit, param_resolver) for op in circuit.all_operations(): line_qubit = cast(Tuple[cirq.LineQubit], op.qubits) diff --git a/cirq-core/cirq/_compat.py b/cirq-core/cirq/_compat.py index 9792d5845d3..3cc1cdb1e5e 100644 --- a/cirq-core/cirq/_compat.py +++ b/cirq-core/cirq/_compat.py @@ -69,13 +69,11 @@ def with_debug(value: bool) -> Iterator[None]: @overload -def cached_method(__func: TFunc) -> TFunc: - ... +def cached_method(__func: TFunc) -> TFunc: ... @overload -def cached_method(*, maxsize: int = 128) -> Callable[[TFunc], TFunc]: - ... +def cached_method(*, maxsize: int = 128) -> Callable[[TFunc], TFunc]: ... def cached_method(method: Optional[TFunc] = None, *, maxsize: int = 128) -> Any: diff --git a/cirq-core/cirq/circuits/moment.py b/cirq-core/cirq/circuits/moment.py index 9153f14307d..5128021bcb6 100644 --- a/cirq-core/cirq/circuits/moment.py +++ b/cirq-core/cirq/circuits/moment.py @@ -283,9 +283,11 @@ def _resolve_parameters_( def _with_measurement_key_mapping_(self, key_map: Mapping[str, str]): return Moment( - protocols.with_measurement_key_mapping(op, key_map) - if protocols.measurement_keys_touched(op) - else op + ( + protocols.with_measurement_key_mapping(op, key_map) + if protocols.measurement_keys_touched(op) + else op + ) for op in self.operations ) @@ -320,9 +322,11 @@ def _with_key_path_(self, path: Tuple[str, ...]): def _with_key_path_prefix_(self, prefix: Tuple[str, ...]): return Moment( - protocols.with_key_path_prefix(op, prefix) - if protocols.measurement_keys_touched(op) - else op + ( + protocols.with_key_path_prefix(op, prefix) + if protocols.measurement_keys_touched(op) + else op + ) for op in self.operations ) diff --git a/cirq-core/cirq/circuits/qasm_output_test.py b/cirq-core/cirq/circuits/qasm_output_test.py index d9083ee183a..ad4e0d44528 100644 --- a/cirq-core/cirq/circuits/qasm_output_test.py +++ b/cirq-core/cirq/circuits/qasm_output_test.py @@ -331,16 +331,18 @@ def __repr__(self): cirq.PhasedXPowGate(phase_exponent=0.333, exponent=0.5).on(q1), cirq.PhasedXPowGate(phase_exponent=0.777, exponent=-0.5).on(q1), ( - cirq.measure(q0, key='xX'), - cirq.measure(q2, key='x_a'), - cirq.measure(q1, key='x?'), - cirq.measure(q3, key='X'), - cirq.measure(q4, key='_x'), - cirq.measure(q2, key='x_a'), - cirq.measure(q1, q2, q3, key='multi', invert_mask=(False, True)), - ) - if include_measurements - else (), + ( + cirq.measure(q0, key='xX'), + cirq.measure(q2, key='x_a'), + cirq.measure(q1, key='x?'), + cirq.measure(q3, key='X'), + cirq.measure(q4, key='_x'), + cirq.measure(q2, key='x_a'), + cirq.measure(q1, q2, q3, key='multi', invert_mask=(False, True)), + ) + if include_measurements + else () + ), ExampleOperation(), ExampleCompositeOperation(), ) diff --git a/cirq-core/cirq/contrib/qcircuit/qcircuit_diagram_info.py b/cirq-core/cirq/contrib/qcircuit/qcircuit_diagram_info.py index 45feaeeb7fd..0f6cae2c68f 100644 --- a/cirq-core/cirq/contrib/qcircuit/qcircuit_diagram_info.py +++ b/cirq-core/cirq/contrib/qcircuit/qcircuit_diagram_info.py @@ -51,13 +51,15 @@ def hardcoded_qcircuit_diagram_info(op: ops.Operation) -> Optional[protocols.Cir symbols = ( (r'\targ',) if op.gate == ops.X - else (r'\control', r'\control') - if op.gate == ops.CZ - else (r'\control', r'\targ') - if op.gate == ops.CNOT - else (r'\meter',) - if isinstance(op.gate, ops.MeasurementGate) - else () + else ( + (r'\control', r'\control') + if op.gate == ops.CZ + else ( + (r'\control', r'\targ') + if op.gate == ops.CNOT + else (r'\meter',) if isinstance(op.gate, ops.MeasurementGate) else () + ) + ) ) return protocols.CircuitDiagramInfo(symbols) if symbols else None diff --git a/cirq-core/cirq/devices/superconducting_qubits_noise_properties.py b/cirq-core/cirq/devices/superconducting_qubits_noise_properties.py index 9a387162f48..5612191c403 100644 --- a/cirq-core/cirq/devices/superconducting_qubits_noise_properties.py +++ b/cirq-core/cirq/devices/superconducting_qubits_noise_properties.py @@ -180,9 +180,9 @@ def build_noise_models(self) -> List['cirq.NoiseModel']: p_00, p_11 = self.readout_errors[qubit] p = p_11 / (p_00 + p_11) gamma = p_11 / p - added_measure_errors[ - noise_utils.OpIdentifier(ops.MeasurementGate, qubit) - ] = ops.generalized_amplitude_damp(p, gamma).on(qubit) + added_measure_errors[noise_utils.OpIdentifier(ops.MeasurementGate, qubit)] = ( + ops.generalized_amplitude_damp(p, gamma).on(qubit) + ) noise_models.append( devices.InsertionNoiseModel(ops_added=added_measure_errors, prepend=True) diff --git a/cirq-core/cirq/experiments/qubit_characterizations.py b/cirq-core/cirq/experiments/qubit_characterizations.py index 0eb5f6a4951..9ba7928b81c 100644 --- a/cirq-core/cirq/experiments/qubit_characterizations.py +++ b/cirq-core/cirq/experiments/qubit_characterizations.py @@ -953,16 +953,8 @@ def _single_qubit_cliffords() -> Cliffords: for z0, x, z1 in phi_xz: c1_in_xz.append([Z**z0, X**x, Z**z1]) - s1: List[List[ops.SingleQubitCliffordGate]] = [ - [X**0.0], - [Y**0.5, X**0.5], - [X**-0.5, Y**-0.5], - ] - s1_x: List[List[ops.SingleQubitCliffordGate]] = [ - [X**0.5], - [X**0.5, Y**0.5, X**0.5], - [Y**-0.5], - ] + s1: List[List[ops.SingleQubitCliffordGate]] = [[X**0.0], [Y**0.5, X**0.5], [X**-0.5, Y**-0.5]] + s1_x: List[List[ops.SingleQubitCliffordGate]] = [[X**0.5], [X**0.5, Y**0.5, X**0.5], [Y**-0.5]] s1_y: List[List[ops.SingleQubitCliffordGate]] = [ [Y**0.5], [X**-0.5, Y**-0.5, X**0.5], diff --git a/cirq-core/cirq/experiments/single_qubit_readout_calibration.py b/cirq-core/cirq/experiments/single_qubit_readout_calibration.py index 34c18fcbdb6..cad1c27a36c 100644 --- a/cirq-core/cirq/experiments/single_qubit_readout_calibration.py +++ b/cirq-core/cirq/experiments/single_qubit_readout_calibration.py @@ -343,15 +343,19 @@ def estimate_parallel_single_qubit_readout_errors( trial_idx += 1 zero_state_errors = { - q: zero_state_trials[0][qubit_idx] / zero_state_totals[0][qubit_idx] - if zero_state_totals[0][qubit_idx] > 0 - else np.nan + q: ( + zero_state_trials[0][qubit_idx] / zero_state_totals[0][qubit_idx] + if zero_state_totals[0][qubit_idx] > 0 + else np.nan + ) for qubit_idx, q in enumerate(qubits) } one_state_errors = { - q: one_state_trials[0][qubit_idx] / one_state_totals[0][qubit_idx] - if one_state_totals[0][qubit_idx] > 0 - else np.nan + q: ( + one_state_trials[0][qubit_idx] / one_state_totals[0][qubit_idx] + if one_state_totals[0][qubit_idx] > 0 + else np.nan + ) for qubit_idx, q in enumerate(qubits) } diff --git a/cirq-core/cirq/linalg/decompositions.py b/cirq-core/cirq/linalg/decompositions.py index 43434ff4d1b..82bc5e3b876 100644 --- a/cirq-core/cirq/linalg/decompositions.py +++ b/cirq-core/cirq/linalg/decompositions.py @@ -451,18 +451,14 @@ def __init__( single_qubit_operations_after: a0, a1 from the above equation. """ self.global_phase: complex = global_phase - self.single_qubit_operations_before: Tuple[ - np.ndarray, np.ndarray - ] = single_qubit_operations_before or ( - np.eye(2, dtype=np.complex64), - np.eye(2, dtype=np.complex64), + self.single_qubit_operations_before: Tuple[np.ndarray, np.ndarray] = ( + single_qubit_operations_before + or (np.eye(2, dtype=np.complex64), np.eye(2, dtype=np.complex64)) ) self.interaction_coefficients = interaction_coefficients - self.single_qubit_operations_after: Tuple[ - np.ndarray, np.ndarray - ] = single_qubit_operations_after or ( - np.eye(2, dtype=np.complex64), - np.eye(2, dtype=np.complex64), + self.single_qubit_operations_after: Tuple[np.ndarray, np.ndarray] = ( + single_qubit_operations_after + or (np.eye(2, dtype=np.complex64), np.eye(2, dtype=np.complex64)) ) def _value_equality_values_(self) -> Any: diff --git a/cirq-core/cirq/linalg/decompositions_test.py b/cirq-core/cirq/linalg/decompositions_test.py index dbbd34efa89..c94a70d6f79 100644 --- a/cirq-core/cirq/linalg/decompositions_test.py +++ b/cirq-core/cirq/linalg/decompositions_test.py @@ -422,9 +422,7 @@ def test_axis_angle_decomposition_str(): assert ( str( cirq.axis_angle( - cirq.unitary(cirq.X**0.25) - @ cirq.unitary(cirq.Y**0.25) - @ cirq.unitary(cirq.Z**0.25) + cirq.unitary(cirq.X**0.25) @ cirq.unitary(cirq.Y**0.25) @ cirq.unitary(cirq.Z**0.25) ) ) == '0.477*π around 0.679*X+0.281*Y+0.679*Z' diff --git a/cirq-core/cirq/linalg/transformations_test.py b/cirq-core/cirq/linalg/transformations_test.py index bf30ad60089..aba860729ea 100644 --- a/cirq-core/cirq/linalg/transformations_test.py +++ b/cirq-core/cirq/linalg/transformations_test.py @@ -584,7 +584,7 @@ def test_partial_trace_of_state_vector_as_mixture_mixed_result(): (0.5, np.array([1, 0, 0, 0]).reshape((2, 2))), (0.5, np.array([0, 0, 0, 1]).reshape((2, 2))), ) - for (q1, q2) in [(0, 1), (0, 2), (1, 2)]: + for q1, q2 in [(0, 1), (0, 2), (1, 2)]: mixture = cirq.partial_trace_of_state_vector_as_mixture(state, [q1, q2], atol=1e-8) assert mixtures_equal(mixture, truth) diff --git a/cirq-core/cirq/ops/common_gates_test.py b/cirq-core/cirq/ops/common_gates_test.py index ea9e1c78e0e..fb878d5e508 100644 --- a/cirq-core/cirq/ops/common_gates_test.py +++ b/cirq-core/cirq/ops/common_gates_test.py @@ -87,8 +87,7 @@ def test_cz_unitary(): ) assert np.allclose( - cirq.unitary(cirq.CZ**0), - np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]), + cirq.unitary(cirq.CZ**0), np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) ) assert np.allclose( diff --git a/cirq-core/cirq/ops/controlled_gate_test.py b/cirq-core/cirq/ops/controlled_gate_test.py index 351d42ff8c6..b9e09c5a6e1 100644 --- a/cirq-core/cirq/ops/controlled_gate_test.py +++ b/cirq-core/cirq/ops/controlled_gate_test.py @@ -452,9 +452,7 @@ def test_extrapolatable_effect(): assert cirq.ControlledGate(cirq.Z) ** 0.5 == cirq.ControlledGate(cirq.Z**0.5) - assert cirq.ControlledGate(cirq.Z).on(a, b) ** 0.5 == cirq.ControlledGate(cirq.Z**0.5).on( - a, b - ) + assert cirq.ControlledGate(cirq.Z).on(a, b) ** 0.5 == cirq.ControlledGate(cirq.Z**0.5).on(a, b) assert cirq.ControlledGate(cirq.Z) ** 0.5 == cirq.ControlledGate(cirq.Z**0.5) diff --git a/cirq-core/cirq/ops/phased_iswap_gate_test.py b/cirq-core/cirq/ops/phased_iswap_gate_test.py index 9ee390c12cc..39920592454 100644 --- a/cirq-core/cirq/ops/phased_iswap_gate_test.py +++ b/cirq-core/cirq/ops/phased_iswap_gate_test.py @@ -34,9 +34,7 @@ def test_phased_iswap_init(): def test_phased_iswap_equality(): eq = cirq.testing.EqualsTester() - eq.add_equality_group( - cirq.PhasedISwapPowGate(phase_exponent=0, exponent=0.4), cirq.ISWAP**0.4 - ) + eq.add_equality_group(cirq.PhasedISwapPowGate(phase_exponent=0, exponent=0.4), cirq.ISWAP**0.4) eq.add_equality_group( cirq.PhasedISwapPowGate(phase_exponent=0, exponent=0.4, global_shift=0.3), cirq.ISwapPowGate(global_shift=0.3) ** 0.4, diff --git a/cirq-core/cirq/ops/qid_util.py b/cirq-core/cirq/ops/qid_util.py index dc0b1e8f74c..79f13e59762 100644 --- a/cirq-core/cirq/ops/qid_util.py +++ b/cirq-core/cirq/ops/qid_util.py @@ -19,18 +19,15 @@ @overload -def q(__x: int) -> 'cirq.LineQubit': - ... +def q(__x: int) -> 'cirq.LineQubit': ... @overload -def q(__row: int, __col: int) -> 'cirq.GridQubit': - ... +def q(__row: int, __col: int) -> 'cirq.GridQubit': ... @overload -def q(__name: str) -> 'cirq.NamedQubit': - ... +def q(__name: str) -> 'cirq.NamedQubit': ... def q(*args: Union[int, str]) -> Union['cirq.LineQubit', 'cirq.GridQubit', 'cirq.NamedQubit']: diff --git a/cirq-core/cirq/protocols/circuit_diagram_info_protocol.py b/cirq-core/cirq/protocols/circuit_diagram_info_protocol.py index e54f0e8d2db..3ab34414faa 100644 --- a/cirq-core/cirq/protocols/circuit_diagram_info_protocol.py +++ b/cirq-core/cirq/protocols/circuit_diagram_info_protocol.py @@ -221,9 +221,11 @@ def _value_equality_values_(self) -> Any: self.known_qubit_count, self.use_unicode_characters, self.precision, - None - if self.label_map is None - else tuple(sorted(self.label_map.items(), key=lambda e: e[0])), + ( + None + if self.label_map is None + else tuple(sorted(self.label_map.items(), key=lambda e: e[0])) + ), self.include_tags, self.transpose, ) diff --git a/cirq-core/cirq/protocols/commutes_protocol.py b/cirq-core/cirq/protocols/commutes_protocol.py index d67e970d817..41d97764930 100644 --- a/cirq-core/cirq/protocols/commutes_protocol.py +++ b/cirq-core/cirq/protocols/commutes_protocol.py @@ -74,15 +74,13 @@ def _commutes_(self, other: Any, *, atol: float) -> Union[None, bool, NotImpleme @overload -def commutes(v1: Any, v2: Any, *, atol: Union[int, float] = 1e-8) -> bool: - ... +def commutes(v1: Any, v2: Any, *, atol: Union[int, float] = 1e-8) -> bool: ... @overload def commutes( v1: Any, v2: Any, *, atol: Union[int, float] = 1e-8, default: TDefault -) -> Union[bool, TDefault]: - ... +) -> Union[bool, TDefault]: ... def commutes( diff --git a/cirq-core/cirq/protocols/decompose_protocol.py b/cirq-core/cirq/protocols/decompose_protocol.py index 18f759e2380..5410f06c848 100644 --- a/cirq-core/cirq/protocols/decompose_protocol.py +++ b/cirq-core/cirq/protocols/decompose_protocol.py @@ -57,8 +57,7 @@ class OpDecomposerWithContext(Protocol): def __call__( self, __op: 'cirq.Operation', *, context: Optional['cirq.DecompositionContext'] = None - ) -> DecomposeResult: - ... + ) -> DecomposeResult: ... OpDecomposer = Union[Callable[['cirq.Operation'], DecomposeResult], OpDecomposerWithContext] diff --git a/cirq-core/cirq/protocols/decompose_protocol_test.py b/cirq-core/cirq/protocols/decompose_protocol_test.py index f8e4b2452b8..07668a02553 100644 --- a/cirq-core/cirq/protocols/decompose_protocol_test.py +++ b/cirq-core/cirq/protocols/decompose_protocol_test.py @@ -346,9 +346,13 @@ def _num_qubits_(self) -> int: def _decompose_impl(self, qubits, mock_qm: mock.Mock): mock_qm.qalloc(self.recurse) - yield RecursiveDecompose( - recurse=False, mock_qm=self.mock_qm, with_context=self.with_context - ).on(*qubits) if self.recurse else cirq.Z.on_each(*qubits) + yield ( + RecursiveDecompose( + recurse=False, mock_qm=self.mock_qm, with_context=self.with_context + ).on(*qubits) + if self.recurse + else cirq.Z.on_each(*qubits) + ) mock_qm.qfree(self.recurse) def _decompose_(self, qubits): diff --git a/cirq-core/cirq/protocols/json_serialization.py b/cirq-core/cirq/protocols/json_serialization.py index 45ac308d32f..070b4818ba0 100644 --- a/cirq-core/cirq/protocols/json_serialization.py +++ b/cirq-core/cirq/protocols/json_serialization.py @@ -47,8 +47,7 @@ class JsonResolver(Protocol): """Protocol for json resolver functions passed to read_json.""" - def __call__(self, cirq_type: str) -> Optional[ObjectFactory]: - ... + def __call__(self, cirq_type: str) -> Optional[ObjectFactory]: ... def _lazy_resolver(dict_factory: Callable[[], Dict[str, ObjectFactory]]) -> JsonResolver: diff --git a/cirq-core/cirq/protocols/pow_protocol_test.py b/cirq-core/cirq/protocols/pow_protocol_test.py index 1cb862ee883..5847ae1abc7 100644 --- a/cirq-core/cirq/protocols/pow_protocol_test.py +++ b/cirq-core/cirq/protocols/pow_protocol_test.py @@ -49,6 +49,4 @@ def test_pow_error(): @pytest.mark.parametrize('val,exponent,out', ((ReturnsExponent(), 2, 2), (1, 2, 1), (2, 3, 8))) def test_pow_with_result(val, exponent, out): - assert ( - cirq.pow(val, exponent) == cirq.pow(val, exponent, default=None) == val**exponent == out - ) + assert cirq.pow(val, exponent) == cirq.pow(val, exponent, default=None) == val**exponent == out diff --git a/cirq-core/cirq/sim/mux.py b/cirq-core/cirq/sim/mux.py index 02c5ede8d2a..17e55390a3a 100644 --- a/cirq-core/cirq/sim/mux.py +++ b/cirq-core/cirq/sim/mux.py @@ -292,9 +292,11 @@ def final_density_matrix( density_result = density_matrix_simulator.DensityMatrixSimulator( dtype=dtype, noise=noise, seed=seed ).simulate( - program=measurement_transformers.dephase_measurements(circuit_like) - if ignore_measurement_results - else circuit_like, + program=( + measurement_transformers.dephase_measurements(circuit_like) + if ignore_measurement_results + else circuit_like + ), initial_state=initial_state, qubit_order=qubit_order, param_resolver=param_resolver, diff --git a/cirq-core/cirq/sim/simulation_product_state.py b/cirq-core/cirq/sim/simulation_product_state.py index 78ec5ceb60d..0849ec890a2 100644 --- a/cirq-core/cirq/sim/simulation_product_state.py +++ b/cirq-core/cirq/sim/simulation_product_state.py @@ -83,9 +83,7 @@ def _act_on_fallback_( gate_opt = ( action if isinstance(action, ops.Gate) - else action.gate - if isinstance(action, ops.Operation) - else None + else action.gate if isinstance(action, ops.Operation) else None ) if isinstance(gate_opt, ops.IdentityGate): diff --git a/cirq-core/cirq/sim/simulator_base.py b/cirq-core/cirq/sim/simulator_base.py index 7a26fc9a6dd..85db0cb4fcd 100644 --- a/cirq-core/cirq/sim/simulator_base.py +++ b/cirq-core/cirq/sim/simulator_base.py @@ -261,9 +261,9 @@ def _run( for i in range(repetitions): for step_result in self._core_iterator( general_suffix, - sim_state=sim_state.copy(deep_copy_buffers=False) - if i < repetitions - 1 - else sim_state, + sim_state=( + sim_state.copy(deep_copy_buffers=False) if i < repetitions - 1 else sim_state + ), ): pass for k, r in step_result._classical_data.records.items(): diff --git a/cirq-core/cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py b/cirq-core/cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py index 46e24017885..238c3f3c548 100644 --- a/cirq-core/cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py +++ b/cirq-core/cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py @@ -55,6 +55,7 @@ class TwoQubitGateTabulationResult(NamedTuple): equal to U_target. success: Whether actual_gate is expected to be close to U_target. """ + base_gate_unitary: np.ndarray target_gate: np.ndarray local_unitaries: Tuple[_SingleQubitGatePair, ...] diff --git a/cirq-core/cirq/transformers/optimize_for_target_gateset_test.py b/cirq-core/cirq/transformers/optimize_for_target_gateset_test.py index e813b8a45f3..e8baefebff0 100644 --- a/cirq-core/cirq/transformers/optimize_for_target_gateset_test.py +++ b/cirq-core/cirq/transformers/optimize_for_target_gateset_test.py @@ -87,8 +87,8 @@ def test_decompose_operations_to_target_gateset(): cirq.T.on_each(*q), ) gateset = cirq.Gateset(cirq.H, cirq.CNOT) - decomposer = ( - lambda op, _: cirq.H(op.qubits[0]) + decomposer = lambda op, _: ( + cirq.H(op.qubits[0]) if cirq.has_unitary(op) and cirq.num_qubits(op) == 1 else NotImplemented ) diff --git a/cirq-core/cirq/transformers/transformer_api.py b/cirq-core/cirq/transformers/transformer_api.py index 3567e566207..ee04c4a6967 100644 --- a/cirq-core/cirq/transformers/transformer_api.py +++ b/cirq-core/cirq/transformers/transformer_api.py @@ -262,8 +262,7 @@ class TRANSFORMER(Protocol): def __call__( self, circuit: 'cirq.AbstractCircuit', *, context: Optional[TransformerContext] = None - ) -> 'cirq.AbstractCircuit': - ... + ) -> 'cirq.AbstractCircuit': ... _TRANSFORMER_T = TypeVar('_TRANSFORMER_T', bound=TRANSFORMER) diff --git a/cirq-core/cirq/transformers/transformer_primitives.py b/cirq-core/cirq/transformers/transformer_primitives.py index 1c131927564..7d466720ef4 100644 --- a/cirq-core/cirq/transformers/transformer_primitives.py +++ b/cirq-core/cirq/transformers/transformer_primitives.py @@ -46,9 +46,11 @@ def _to_target_circuit_type( ) -> CIRCUIT_TYPE: return cast( CIRCUIT_TYPE, - circuit.unfreeze(copy=False) - if isinstance(target_circuit, circuits.Circuit) - else circuit.freeze(), + ( + circuit.unfreeze(copy=False) + if isinstance(target_circuit, circuits.Circuit) + else circuit.freeze() + ), ) @@ -637,11 +639,13 @@ def merge_moments( if deep: circuit = map_operations( circuit, - lambda op, _: op.untagged.replace( - circuit=merge_moments(op.untagged.circuit, merge_func, deep=deep) - ).with_tags(*op.tags) - if isinstance(op.untagged, circuits.CircuitOperation) - else op, + lambda op, _: ( + op.untagged.replace( + circuit=merge_moments(op.untagged.circuit, merge_func, deep=deep) + ).with_tags(*op.tags) + if isinstance(op.untagged, circuits.CircuitOperation) + else op + ), tags_to_ignore=tags_to_ignore, ) merged_moments: List[circuits.Moment] = [circuit[0]] diff --git a/cirq-core/cirq/transformers/transformer_primitives_test.py b/cirq-core/cirq/transformers/transformer_primitives_test.py index 93de23a8802..a2cd17628b7 100644 --- a/cirq-core/cirq/transformers/transformer_primitives_test.py +++ b/cirq-core/cirq/transformers/transformer_primitives_test.py @@ -131,11 +131,11 @@ def test_map_operations_deep_subcircuits(): ) def map_func(op: cirq.Operation, _: int) -> cirq.OP_TREE: - yield [ - cirq.Z.on_each(*op.qubits), - cirq.CX(*op.qubits), - cirq.Z.on_each(*op.qubits), - ] if op.gate == cirq.CX else op + yield ( + [cirq.Z.on_each(*op.qubits), cirq.CX(*op.qubits), cirq.Z.on_each(*op.qubits)] + if op.gate == cirq.CX + else op + ) cirq.testing.assert_has_diagram( c_orig_with_circuit_ops, diff --git a/cirq-core/cirq/value/classical_data.py b/cirq-core/cirq/value/classical_data.py index b203b1e0c61..77235c16282 100644 --- a/cirq-core/cirq/value/classical_data.py +++ b/cirq-core/cirq/value/classical_data.py @@ -165,13 +165,13 @@ def __init__( if _channel_records is None: _channel_records = {} self._records: Dict['cirq.MeasurementKey', List[Tuple[int, ...]]] = _records - self._measured_qubits: Dict[ - 'cirq.MeasurementKey', List[Tuple['cirq.Qid', ...]] - ] = _measured_qubits + self._measured_qubits: Dict['cirq.MeasurementKey', List[Tuple['cirq.Qid', ...]]] = ( + _measured_qubits + ) self._channel_records: Dict['cirq.MeasurementKey', List[int]] = _channel_records - self._measurement_types: Dict[ - 'cirq.MeasurementKey', 'cirq.MeasurementType' - ] = _measurement_types + self._measurement_types: Dict['cirq.MeasurementKey', 'cirq.MeasurementType'] = ( + _measurement_types + ) @property def records(self) -> Mapping['cirq.MeasurementKey', List[Tuple[int, ...]]]: diff --git a/cirq-ft/cirq_ft/algos/apply_gate_to_lth_target.py b/cirq-ft/cirq_ft/algos/apply_gate_to_lth_target.py index 6971b3711cb..86ce2b3f680 100644 --- a/cirq-ft/cirq_ft/algos/apply_gate_to_lth_target.py +++ b/cirq-ft/cirq_ft/algos/apply_gate_to_lth_target.py @@ -47,6 +47,7 @@ class ApplyGateToLthQubit(unary_iteration_gate.UnaryIterationGate): (https://arxiv.org/abs/1805.03662). Babbush et. al. (2018). Section III.A. and Figure 7. """ + selection_regs: Tuple[infra.SelectionRegister, ...] = attr.field( converter=lambda v: (v,) if isinstance(v, infra.SelectionRegister) else tuple(v) ) diff --git a/cirq-ft/cirq_ft/algos/generic_select.py b/cirq-ft/cirq_ft/algos/generic_select.py index 46654be4e26..6e86636960d 100644 --- a/cirq-ft/cirq_ft/algos/generic_select.py +++ b/cirq-ft/cirq_ft/algos/generic_select.py @@ -50,6 +50,7 @@ class GenericSelect(select_and_prepare.SelectOracle, unary_iteration_gate.UnaryI dense pauli string must contain `target_bitsize` terms. control_val: Optional control value. If specified, a singly controlled gate is constructed. """ + selection_bitsize: int target_bitsize: int select_unitaries: Tuple[cirq.DensePauliString, ...] = attr.field(converter=_to_tuple) diff --git a/cirq-ft/cirq_ft/algos/hubbard_model.py b/cirq-ft/cirq_ft/algos/hubbard_model.py index 943870cb5ba..18435bf265d 100644 --- a/cirq-ft/cirq_ft/algos/hubbard_model.py +++ b/cirq-ft/cirq_ft/algos/hubbard_model.py @@ -185,8 +185,8 @@ def decompose_from_registers( yield swap_network.MultiTargetCSwap.make_on(control=V, target_x=p_y, target_y=q_y) yield swap_network.MultiTargetCSwap.make_on(control=V, target_x=p_x, target_y=q_x) - yield cirq.S(*control) ** -1 if control else cirq.global_phase_operation( - -1j + yield ( + cirq.S(*control) ** -1 if control else cirq.global_phase_operation(-1j) ) # Fix errant i from XY=iZ yield cirq.Z(*U).controlled_by(*control) # Fix errant -1 from multiple pauli applications diff --git a/cirq-ft/cirq_ft/algos/qubitization_walk_operator.py b/cirq-ft/cirq_ft/algos/qubitization_walk_operator.py index 565842d6a51..2c59b238c2d 100644 --- a/cirq-ft/cirq_ft/algos/qubitization_walk_operator.py +++ b/cirq-ft/cirq_ft/algos/qubitization_walk_operator.py @@ -52,6 +52,7 @@ class QubitizationWalkOperator(infra.GateWithRegisters): (https://arxiv.org/abs/1805.03662). Babbush et. al. (2018). Figure 1. """ + select: select_and_prepare.SelectOracle prepare: select_and_prepare.PrepareOracle control_val: Optional[int] = None diff --git a/cirq-ft/cirq_ft/algos/select_and_prepare.py b/cirq-ft/cirq_ft/algos/select_and_prepare.py index b369e2c9f9b..3338aef2750 100644 --- a/cirq-ft/cirq_ft/algos/select_and_prepare.py +++ b/cirq-ft/cirq_ft/algos/select_and_prepare.py @@ -39,18 +39,15 @@ class SelectOracle(infra.GateWithRegisters): @property @abc.abstractmethod - def control_registers(self) -> Tuple[infra.Register, ...]: - ... + def control_registers(self) -> Tuple[infra.Register, ...]: ... @property @abc.abstractmethod - def selection_registers(self) -> Tuple[infra.SelectionRegister, ...]: - ... + def selection_registers(self) -> Tuple[infra.SelectionRegister, ...]: ... @property @abc.abstractmethod - def target_registers(self) -> Tuple[infra.Register, ...]: - ... + def target_registers(self) -> Tuple[infra.Register, ...]: ... @cached_property def signature(self) -> infra.Signature: @@ -76,8 +73,7 @@ class PrepareOracle(infra.GateWithRegisters): @property @abc.abstractmethod - def selection_registers(self) -> Tuple[infra.SelectionRegister, ...]: - ... + def selection_registers(self) -> Tuple[infra.SelectionRegister, ...]: ... @cached_property def junk_registers(self) -> Tuple[infra.Register, ...]: diff --git a/cirq-ft/cirq_ft/algos/state_preparation.py b/cirq-ft/cirq_ft/algos/state_preparation.py index 6237ae60159..6a0f5cec994 100644 --- a/cirq-ft/cirq_ft/algos/state_preparation.py +++ b/cirq-ft/cirq_ft/algos/state_preparation.py @@ -83,6 +83,7 @@ class StatePreparationAliasSampling(select_and_prepare.PrepareOracle): (https://arxiv.org/abs/1805.03662). Babbush et. al. (2018). Section III.D. and Figure 11. """ + selection_registers: Tuple[infra.SelectionRegister, ...] = attr.field( converter=lambda v: (v,) if isinstance(v, infra.SelectionRegister) else tuple(v) ) diff --git a/cirq-ft/cirq_ft/infra/gate_with_registers.py b/cirq-ft/cirq_ft/infra/gate_with_registers.py index 8d2122dce62..1e9129bdc6a 100644 --- a/cirq-ft/cirq_ft/infra/gate_with_registers.py +++ b/cirq-ft/cirq_ft/infra/gate_with_registers.py @@ -145,9 +145,11 @@ def _qubits_for_reg(reg: Register): return _qubit_array(reg) return np.array( - [cirq.NamedQubit(f"{reg.name}")] - if reg.total_bits() == 1 - else cirq.NamedQubit.range(reg.total_bits(), prefix=reg.name), + ( + [cirq.NamedQubit(f"{reg.name}")] + if reg.total_bits() == 1 + else cirq.NamedQubit.range(reg.total_bits(), prefix=reg.name) + ), dtype=object, ) @@ -336,8 +338,7 @@ class GateWithRegisters(cirq.Gate, metaclass=abc.ABCMeta): @property @abc.abstractmethod - def signature(self) -> Signature: - ... + def signature(self) -> Signature: ... def _num_qubits_(self) -> int: return total_bits(self.signature) diff --git a/cirq-ft/cirq_ft/infra/t_complexity_protocol.py b/cirq-ft/cirq_ft/infra/t_complexity_protocol.py index 33dc6eb4443..52ed7137d59 100644 --- a/cirq-ft/cirq_ft/infra/t_complexity_protocol.py +++ b/cirq-ft/cirq_ft/infra/t_complexity_protocol.py @@ -158,13 +158,11 @@ def _t_complexity_for_gate_or_op( @overload -def t_complexity(stc: Any, fail_quietly: Literal[False] = False) -> TComplexity: - ... +def t_complexity(stc: Any, fail_quietly: Literal[False] = False) -> TComplexity: ... @overload -def t_complexity(stc: Any, fail_quietly: bool) -> Optional[TComplexity]: - ... +def t_complexity(stc: Any, fail_quietly: bool) -> Optional[TComplexity]: ... @deprecated_cirq_ft_function() diff --git a/cirq-ft/cirq_ft/infra/t_complexity_protocol_test.py b/cirq-ft/cirq_ft/infra/t_complexity_protocol_test.py index 5b7e3f33404..6512d6e5e27 100644 --- a/cirq-ft/cirq_ft/infra/t_complexity_protocol_test.py +++ b/cirq-ft/cirq_ft/infra/t_complexity_protocol_test.py @@ -26,8 +26,7 @@ def _t_complexity_(self) -> cirq_ft.TComplexity: return cirq_ft.TComplexity(t=1) -class DoesNotSupportTComplexity: - ... +class DoesNotSupportTComplexity: ... class SupportsTComplexityGateWithRegisters(cirq_ft.GateWithRegisters): @@ -195,8 +194,7 @@ def _t_complexity_(self) -> cirq_ft.TComplexity: def qubits(self): return [cirq.LineQubit(3)] # pragma: no cover - def with_qubits(self, _): - ... + def with_qubits(self, _): ... @property def gate(self): diff --git a/cirq-google/cirq_google/cloud/__init__.py b/cirq-google/cirq_google/cloud/__init__.py index 27196ea4227..bce176ee1ee 100644 --- a/cirq-google/cirq_google/cloud/__init__.py +++ b/cirq-google/cirq_google/cloud/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Protocol buffers and generated client for Quantum Engine API.""" \ No newline at end of file +"""Protocol buffers and generated client for Quantum Engine API.""" diff --git a/cirq-google/cirq_google/cloud/quantum/__init__.py b/cirq-google/cirq_google/cloud/quantum/__init__.py index a75b5f16ca1..da13d072acf 100644 --- a/cirq-google/cirq_google/cloud/quantum/__init__.py +++ b/cirq-google/cirq_google/cloud/quantum/__init__.py @@ -14,8 +14,12 @@ # limitations under the License. # -from cirq_google.cloud.quantum_v1alpha1.services.quantum_engine_service.client import QuantumEngineServiceClient -from cirq_google.cloud.quantum_v1alpha1.services.quantum_engine_service.async_client import QuantumEngineServiceAsyncClient +from cirq_google.cloud.quantum_v1alpha1.services.quantum_engine_service.client import ( + QuantumEngineServiceClient, +) +from cirq_google.cloud.quantum_v1alpha1.services.quantum_engine_service.async_client import ( + QuantumEngineServiceAsyncClient, +) from cirq_google.cloud.quantum_v1alpha1.types.engine import CancelQuantumJobRequest from cirq_google.cloud.quantum_v1alpha1.types.engine import CancelQuantumReservationRequest @@ -74,7 +78,8 @@ from cirq_google.cloud.quantum_v1alpha1.types.quantum import QuantumTimeSlot from cirq_google.cloud.quantum_v1alpha1.types.quantum import SchedulingConfig -__all__ = ('QuantumEngineServiceClient', +__all__ = ( + 'QuantumEngineServiceClient', 'QuantumEngineServiceAsyncClient', 'CancelQuantumJobRequest', 'CancelQuantumReservationRequest', diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/__init__.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/__init__.py index fbc21ead0e4..fa5dd1140e9 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/__init__.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/__init__.py @@ -76,61 +76,61 @@ __all__ = ( 'QuantumEngineServiceAsyncClient', -'CancelQuantumJobRequest', -'CancelQuantumReservationRequest', -'CreateQuantumJobRequest', -'CreateQuantumProgramAndJobRequest', -'CreateQuantumProgramRequest', -'CreateQuantumReservationRequest', -'DeleteQuantumJobRequest', -'DeleteQuantumProgramRequest', -'DeleteQuantumReservationRequest', -'DeviceConfigKey', -'ExecutionStatus', -'GcsLocation', -'GetQuantumCalibrationRequest', -'GetQuantumJobRequest', -'GetQuantumProcessorRequest', -'GetQuantumProgramRequest', -'GetQuantumReservationRequest', -'GetQuantumResultRequest', -'InlineData', -'ListQuantumCalibrationsRequest', -'ListQuantumCalibrationsResponse', -'ListQuantumJobEventsRequest', -'ListQuantumJobEventsResponse', -'ListQuantumJobsRequest', -'ListQuantumJobsResponse', -'ListQuantumProcessorsRequest', -'ListQuantumProcessorsResponse', -'ListQuantumProgramsRequest', -'ListQuantumProgramsResponse', -'ListQuantumReservationBudgetsRequest', -'ListQuantumReservationBudgetsResponse', -'ListQuantumReservationGrantsRequest', -'ListQuantumReservationGrantsResponse', -'ListQuantumReservationsRequest', -'ListQuantumReservationsResponse', -'ListQuantumTimeSlotsRequest', -'ListQuantumTimeSlotsResponse', -'OutputConfig', -'QuantumCalibration', -'QuantumEngineServiceClient', -'QuantumJob', -'QuantumJobEvent', -'QuantumProcessor', -'QuantumProgram', -'QuantumReservation', -'QuantumReservationBudget', -'QuantumReservationGrant', -'QuantumResult', -'QuantumRunStreamRequest', -'QuantumRunStreamResponse', -'QuantumTimeSlot', -'ReallocateQuantumReservationGrantRequest', -'SchedulingConfig', -'StreamError', -'UpdateQuantumJobRequest', -'UpdateQuantumProgramRequest', -'UpdateQuantumReservationRequest', + 'CancelQuantumJobRequest', + 'CancelQuantumReservationRequest', + 'CreateQuantumJobRequest', + 'CreateQuantumProgramAndJobRequest', + 'CreateQuantumProgramRequest', + 'CreateQuantumReservationRequest', + 'DeleteQuantumJobRequest', + 'DeleteQuantumProgramRequest', + 'DeleteQuantumReservationRequest', + 'DeviceConfigKey', + 'ExecutionStatus', + 'GcsLocation', + 'GetQuantumCalibrationRequest', + 'GetQuantumJobRequest', + 'GetQuantumProcessorRequest', + 'GetQuantumProgramRequest', + 'GetQuantumReservationRequest', + 'GetQuantumResultRequest', + 'InlineData', + 'ListQuantumCalibrationsRequest', + 'ListQuantumCalibrationsResponse', + 'ListQuantumJobEventsRequest', + 'ListQuantumJobEventsResponse', + 'ListQuantumJobsRequest', + 'ListQuantumJobsResponse', + 'ListQuantumProcessorsRequest', + 'ListQuantumProcessorsResponse', + 'ListQuantumProgramsRequest', + 'ListQuantumProgramsResponse', + 'ListQuantumReservationBudgetsRequest', + 'ListQuantumReservationBudgetsResponse', + 'ListQuantumReservationGrantsRequest', + 'ListQuantumReservationGrantsResponse', + 'ListQuantumReservationsRequest', + 'ListQuantumReservationsResponse', + 'ListQuantumTimeSlotsRequest', + 'ListQuantumTimeSlotsResponse', + 'OutputConfig', + 'QuantumCalibration', + 'QuantumEngineServiceClient', + 'QuantumJob', + 'QuantumJobEvent', + 'QuantumProcessor', + 'QuantumProgram', + 'QuantumReservation', + 'QuantumReservationBudget', + 'QuantumReservationGrant', + 'QuantumResult', + 'QuantumRunStreamRequest', + 'QuantumRunStreamResponse', + 'QuantumTimeSlot', + 'ReallocateQuantumReservationGrantRequest', + 'SchedulingConfig', + 'StreamError', + 'UpdateQuantumJobRequest', + 'UpdateQuantumProgramRequest', + 'UpdateQuantumReservationRequest', ) diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/__init__.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/__init__.py index db7f301f9ee..5d1df2327fd 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/__init__.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/__init__.py @@ -16,7 +16,4 @@ from .client import QuantumEngineServiceClient from .async_client import QuantumEngineServiceAsyncClient -__all__ = ( - 'QuantumEngineServiceClient', - 'QuantumEngineServiceAsyncClient', -) +__all__ = ('QuantumEngineServiceClient', 'QuantumEngineServiceAsyncClient') diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/async_client.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/async_client.py index 353c66ec2f7..b7379df2024 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/async_client.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/async_client.py @@ -16,7 +16,17 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, AsyncIterable, Awaitable, AsyncIterator, Sequence, Tuple, Type, Union +from typing import ( + Dict, + Optional, + AsyncIterable, + Awaitable, + AsyncIterator, + Sequence, + Tuple, + Type, + Union, +) import pkg_resources from google.api_core.client_options import ClientOptions @@ -24,7 +34,7 @@ from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials -from google.oauth2 import service_account # type: ignore +from google.oauth2 import service_account # type: ignore try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -53,17 +63,27 @@ class QuantumEngineServiceAsyncClient: quantum_job_path = staticmethod(QuantumEngineServiceClient.quantum_job_path) parse_quantum_job_path = staticmethod(QuantumEngineServiceClient.parse_quantum_job_path) quantum_processor_path = staticmethod(QuantumEngineServiceClient.quantum_processor_path) - parse_quantum_processor_path = staticmethod(QuantumEngineServiceClient.parse_quantum_processor_path) + parse_quantum_processor_path = staticmethod( + QuantumEngineServiceClient.parse_quantum_processor_path + ) quantum_program_path = staticmethod(QuantumEngineServiceClient.quantum_program_path) parse_quantum_program_path = staticmethod(QuantumEngineServiceClient.parse_quantum_program_path) quantum_reservation_path = staticmethod(QuantumEngineServiceClient.quantum_reservation_path) - parse_quantum_reservation_path = staticmethod(QuantumEngineServiceClient.parse_quantum_reservation_path) - common_billing_account_path = staticmethod(QuantumEngineServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(QuantumEngineServiceClient.parse_common_billing_account_path) + parse_quantum_reservation_path = staticmethod( + QuantumEngineServiceClient.parse_quantum_reservation_path + ) + common_billing_account_path = staticmethod( + QuantumEngineServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + QuantumEngineServiceClient.parse_common_billing_account_path + ) common_folder_path = staticmethod(QuantumEngineServiceClient.common_folder_path) parse_common_folder_path = staticmethod(QuantumEngineServiceClient.parse_common_folder_path) common_organization_path = staticmethod(QuantumEngineServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(QuantumEngineServiceClient.parse_common_organization_path) + parse_common_organization_path = staticmethod( + QuantumEngineServiceClient.parse_common_organization_path + ) common_project_path = staticmethod(QuantumEngineServiceClient.common_project_path) parse_common_project_path = staticmethod(QuantumEngineServiceClient.parse_common_project_path) common_location_path = staticmethod(QuantumEngineServiceClient.common_location_path) @@ -145,14 +165,18 @@ def transport(self) -> QuantumEngineServiceTransport: """ return self._client.transport - get_transport_class = functools.partial(type(QuantumEngineServiceClient).get_transport_class, type(QuantumEngineServiceClient)) + get_transport_class = functools.partial( + type(QuantumEngineServiceClient).get_transport_class, type(QuantumEngineServiceClient) + ) - def __init__(self, *, - credentials: ga_credentials.Credentials = None, - transport: Union[str, QuantumEngineServiceTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, QuantumEngineServiceTransport] = "grpc_asyncio", + client_options: Optional[ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the quantum engine service client. Args: @@ -190,16 +214,16 @@ def __init__(self, *, transport=transport, client_options=client_options, client_info=client_info, - ) - async def create_quantum_program(self, - request: Union[engine.CreateQuantumProgramRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumProgram: + async def create_quantum_program( + self, + request: Union[engine.CreateQuantumProgramRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumProgram: r"""- .. code-block:: python @@ -247,29 +271,23 @@ def sample_create_quantum_program(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def get_quantum_program(self, - request: Union[engine.GetQuantumProgramRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumProgram: + async def get_quantum_program( + self, + request: Union[engine.GetQuantumProgramRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumProgram: r"""- .. code-block:: python @@ -317,29 +335,23 @@ def sample_get_quantum_program(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def list_quantum_programs(self, - request: Union[engine.ListQuantumProgramsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumProgramsAsyncPager: + async def list_quantum_programs( + self, + request: Union[engine.ListQuantumProgramsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumProgramsAsyncPager: r"""- .. code-block:: python @@ -392,38 +404,29 @@ def sample_list_quantum_programs(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumProgramsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - async def delete_quantum_program(self, - request: Union[engine.DeleteQuantumProgramRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + async def delete_quantum_program( + self, + request: Union[engine.DeleteQuantumProgramRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""- .. code-block:: python @@ -464,26 +467,20 @@ def sample_delete_quantum_program(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def update_quantum_program(self, - request: Union[engine.UpdateQuantumProgramRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumProgram: + await rpc(request, retry=retry, timeout=timeout, metadata=metadata) + + async def update_quantum_program( + self, + request: Union[engine.UpdateQuantumProgramRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumProgram: r"""- .. code-block:: python @@ -531,29 +528,23 @@ def sample_update_quantum_program(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def create_quantum_job(self, - request: Union[engine.CreateQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumJob: + async def create_quantum_job( + self, + request: Union[engine.CreateQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumJob: r"""- .. code-block:: python @@ -601,29 +592,23 @@ def sample_create_quantum_job(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def get_quantum_job(self, - request: Union[engine.GetQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumJob: + async def get_quantum_job( + self, + request: Union[engine.GetQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumJob: r"""- .. code-block:: python @@ -671,29 +656,23 @@ def sample_get_quantum_job(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def list_quantum_jobs(self, - request: Union[engine.ListQuantumJobsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumJobsAsyncPager: + async def list_quantum_jobs( + self, + request: Union[engine.ListQuantumJobsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumJobsAsyncPager: r"""- .. code-block:: python @@ -746,38 +725,29 @@ def sample_list_quantum_jobs(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumJobsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - async def delete_quantum_job(self, - request: Union[engine.DeleteQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + async def delete_quantum_job( + self, + request: Union[engine.DeleteQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""- .. code-block:: python @@ -818,26 +788,20 @@ def sample_delete_quantum_job(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def update_quantum_job(self, - request: Union[engine.UpdateQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumJob: + await rpc(request, retry=retry, timeout=timeout, metadata=metadata) + + async def update_quantum_job( + self, + request: Union[engine.UpdateQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumJob: r"""- .. code-block:: python @@ -885,29 +849,23 @@ def sample_update_quantum_job(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def cancel_quantum_job(self, - request: Union[engine.CancelQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + async def cancel_quantum_job( + self, + request: Union[engine.CancelQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""- .. code-block:: python @@ -948,26 +906,20 @@ def sample_cancel_quantum_job(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def list_quantum_job_events(self, - request: Union[engine.ListQuantumJobEventsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumJobEventsAsyncPager: + await rpc(request, retry=retry, timeout=timeout, metadata=metadata) + + async def list_quantum_job_events( + self, + request: Union[engine.ListQuantumJobEventsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumJobEventsAsyncPager: r"""- .. code-block:: python @@ -1020,38 +972,29 @@ def sample_list_quantum_job_events(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumJobEventsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - async def get_quantum_result(self, - request: Union[engine.GetQuantumResultRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumResult: + async def get_quantum_result( + self, + request: Union[engine.GetQuantumResultRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumResult: r"""- .. code-block:: python @@ -1099,29 +1042,23 @@ def sample_get_quantum_result(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def list_quantum_processors(self, - request: Union[engine.ListQuantumProcessorsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumProcessorsAsyncPager: + async def list_quantum_processors( + self, + request: Union[engine.ListQuantumProcessorsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumProcessorsAsyncPager: r"""- .. code-block:: python @@ -1174,38 +1111,29 @@ def sample_list_quantum_processors(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumProcessorsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - async def get_quantum_processor(self, - request: Union[engine.GetQuantumProcessorRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumProcessor: + async def get_quantum_processor( + self, + request: Union[engine.GetQuantumProcessorRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumProcessor: r"""- .. code-block:: python @@ -1253,29 +1181,23 @@ def sample_get_quantum_processor(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def list_quantum_calibrations(self, - request: Union[engine.ListQuantumCalibrationsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumCalibrationsAsyncPager: + async def list_quantum_calibrations( + self, + request: Union[engine.ListQuantumCalibrationsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumCalibrationsAsyncPager: r"""- .. code-block:: python @@ -1328,38 +1250,29 @@ def sample_list_quantum_calibrations(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumCalibrationsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - async def get_quantum_calibration(self, - request: Union[engine.GetQuantumCalibrationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumCalibration: + async def get_quantum_calibration( + self, + request: Union[engine.GetQuantumCalibrationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumCalibration: r"""- .. code-block:: python @@ -1407,29 +1320,23 @@ def sample_get_quantum_calibration(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def create_quantum_reservation(self, - request: Union[engine.CreateQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservation: + async def create_quantum_reservation( + self, + request: Union[engine.CreateQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservation: r"""- .. code-block:: python @@ -1477,29 +1384,23 @@ def sample_create_quantum_reservation(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def cancel_quantum_reservation(self, - request: Union[engine.CancelQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservation: + async def cancel_quantum_reservation( + self, + request: Union[engine.CancelQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservation: r"""- .. code-block:: python @@ -1547,29 +1448,23 @@ def sample_cancel_quantum_reservation(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def delete_quantum_reservation(self, - request: Union[engine.DeleteQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + async def delete_quantum_reservation( + self, + request: Union[engine.DeleteQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""- .. code-block:: python @@ -1610,26 +1505,20 @@ def sample_delete_quantum_reservation(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def get_quantum_reservation(self, - request: Union[engine.GetQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservation: + await rpc(request, retry=retry, timeout=timeout, metadata=metadata) + + async def get_quantum_reservation( + self, + request: Union[engine.GetQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservation: r"""- .. code-block:: python @@ -1677,29 +1566,23 @@ def sample_get_quantum_reservation(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def list_quantum_reservations(self, - request: Union[engine.ListQuantumReservationsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumReservationsAsyncPager: + async def list_quantum_reservations( + self, + request: Union[engine.ListQuantumReservationsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumReservationsAsyncPager: r"""- .. code-block:: python @@ -1752,38 +1635,29 @@ def sample_list_quantum_reservations(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumReservationsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - async def update_quantum_reservation(self, - request: Union[engine.UpdateQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservation: + async def update_quantum_reservation( + self, + request: Union[engine.UpdateQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservation: r"""- .. code-block:: python @@ -1831,29 +1705,23 @@ def sample_update_quantum_reservation(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def quantum_run_stream(self, - requests: Optional[AsyncIterator[engine.QuantumRunStreamRequest]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> Awaitable[AsyncIterable[engine.QuantumRunStreamResponse]]: + def quantum_run_stream( + self, + requests: Optional[AsyncIterator[engine.QuantumRunStreamRequest]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> Awaitable[AsyncIterable[engine.QuantumRunStreamResponse]]: r"""- .. code-block:: python @@ -1908,23 +1776,19 @@ def request_generator(): ) # Send the request. - response = rpc( - requests, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def list_quantum_reservation_grants(self, - request: Union[engine.ListQuantumReservationGrantsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumReservationGrantsAsyncPager: + async def list_quantum_reservation_grants( + self, + request: Union[engine.ListQuantumReservationGrantsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumReservationGrantsAsyncPager: r"""- .. code-block:: python @@ -1977,38 +1841,29 @@ def sample_list_quantum_reservation_grants(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumReservationGrantsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - async def reallocate_quantum_reservation_grant(self, - request: Union[engine.ReallocateQuantumReservationGrantRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservationGrant: + async def reallocate_quantum_reservation_grant( + self, + request: Union[engine.ReallocateQuantumReservationGrantRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservationGrant: r"""- .. code-block:: python @@ -2056,29 +1911,23 @@ def sample_reallocate_quantum_reservation_grant(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - async def list_quantum_reservation_budgets(self, - request: Union[engine.ListQuantumReservationBudgetsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumReservationBudgetsAsyncPager: + async def list_quantum_reservation_budgets( + self, + request: Union[engine.ListQuantumReservationBudgetsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumReservationBudgetsAsyncPager: r"""- .. code-block:: python @@ -2131,38 +1980,29 @@ def sample_list_quantum_reservation_budgets(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumReservationBudgetsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - async def list_quantum_time_slots(self, - request: Union[engine.ListQuantumTimeSlotsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumTimeSlotsAsyncPager: + async def list_quantum_time_slots( + self, + request: Union[engine.ListQuantumTimeSlotsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumTimeSlotsAsyncPager: r"""- .. code-block:: python @@ -2215,26 +2055,16 @@ def sample_list_quantum_time_slots(): # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQuantumTimeSlotsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. @@ -2246,16 +2076,13 @@ async def __aenter__(self): async def __aexit__(self, exc_type, exc, tb): await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-quantum", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-quantum").version ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "QuantumEngineServiceAsyncClient", -) +__all__ = ("QuantumEngineServiceAsyncClient",) diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/client.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/client.py index 8f5225e2d05..f71838a8f11 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/client.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/client.py @@ -27,7 +27,7 @@ from google.auth.transport import mtls from google.auth.transport.grpc import SslCredentials from google.auth.exceptions import MutualTLSChannelError -from google.oauth2 import service_account # type: ignore +from google.oauth2 import service_account # type: ignore try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -52,13 +52,14 @@ class QuantumEngineServiceClientMeta(type): support objects (e.g. transport) without polluting the client instance objects. """ + _transport_registry = OrderedDict() # type: Dict[str, Type[QuantumEngineServiceTransport]] _transport_registry["grpc"] = QuantumEngineServiceGrpcTransport _transport_registry["grpc_asyncio"] = QuantumEngineServiceGrpcAsyncIOTransport - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[QuantumEngineServiceTransport]: + def get_transport_class( + cls, label: Optional[str] = None + ) -> Type[QuantumEngineServiceTransport]: """Returns an appropriate transport class. Args: @@ -104,16 +105,12 @@ def _get_default_mtls_endpoint(api_endpoint): return api_endpoint if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) + return api_endpoint.replace("sandbox.googleapis.com", "mtls.sandbox.googleapis.com") return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") DEFAULT_ENDPOINT = "quantum.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__(DEFAULT_ENDPOINT) # type: ignore @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): @@ -146,8 +143,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): Returns: QuantumEngineServiceClient: The constructed client. """ - credentials = service_account.Credentials.from_service_account_file( - filename) + credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials return cls(*args, **kwargs) @@ -164,106 +160,113 @@ def transport(self) -> QuantumEngineServiceTransport: return self._transport @staticmethod - def quantum_job_path(project: str,program: str,job: str,) -> str: + def quantum_job_path(project: str, program: str, job: str) -> str: """Returns a fully-qualified quantum_job string.""" return f"projects/{project}/programs/{program}/jobs/{job}" @staticmethod - def parse_quantum_job_path(path: str) -> Dict[str,str]: + def parse_quantum_job_path(path: str) -> Dict[str, str]: """Parses a quantum_job path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/programs/(?P.+?)/jobs/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/programs/(?P.+?)/jobs/(?P.+?)$", path + ) return m.groupdict() if m else {} @staticmethod - def quantum_processor_path(project_id: str,processor_id: str,) -> str: + def quantum_processor_path(project_id: str, processor_id: str) -> str: """Returns a fully-qualified quantum_processor string.""" return f"projects/{project_id}/processors/{processor_id}" @staticmethod - def parse_quantum_processor_path(path: str) -> Dict[str,str]: + def parse_quantum_processor_path(path: str) -> Dict[str, str]: """Parses a quantum_processor path into its component segments.""" m = re.match(r"^projects/(?P.+?)/processors/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod - def quantum_program_path(project: str,program: str,) -> str: + def quantum_program_path(project: str, program: str) -> str: """Returns a fully-qualified quantum_program string.""" return f"projects/{project}/programs/{program}" @staticmethod - def parse_quantum_program_path(path: str) -> Dict[str,str]: + def parse_quantum_program_path(path: str) -> Dict[str, str]: """Parses a quantum_program path into its component segments.""" m = re.match(r"^projects/(?P.+?)/programs/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod - def quantum_reservation_path(project_id: str,processor_id: str,reservation_id: str,) -> str: + def quantum_reservation_path(project_id: str, processor_id: str, reservation_id: str) -> str: """Returns a fully-qualified quantum_reservation string.""" return f"projects/{project_id}/processors/{processor_id}/reservations/{reservation_id}" @staticmethod - def parse_quantum_reservation_path(path: str) -> Dict[str,str]: + def parse_quantum_reservation_path(path: str) -> Dict[str, str]: """Parses a quantum_reservation path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/processors/(?P.+?)/reservations/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/processors/(?P.+?)/reservations/(?P.+?)$", + path, + ) return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: + def common_billing_account_path(billing_account: str) -> str: """Returns a fully-qualified billing_account string.""" return f"billingAccounts/{billing_account}" @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: + def parse_common_billing_account_path(path: str) -> Dict[str, str]: """Parse a billing_account path into its component segments.""" m = re.match(r"^billingAccounts/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str, ) -> str: + def common_folder_path(folder: str) -> str: """Returns a fully-qualified folder string.""" return f"folders/{folder}" @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: + def parse_common_folder_path(path: str) -> Dict[str, str]: """Parse a folder path into its component segments.""" m = re.match(r"^folders/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str, ) -> str: + def common_organization_path(organization: str) -> str: """Returns a fully-qualified organization string.""" return f"organizations/{organization}" @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: + def parse_common_organization_path(path: str) -> Dict[str, str]: """Parse a organization path into its component segments.""" m = re.match(r"^organizations/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str, ) -> str: + def common_project_path(project: str) -> str: """Returns a fully-qualified project string.""" return f"projects/{project}" @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: + def parse_common_project_path(path: str) -> Dict[str, str]: """Parse a project path into its component segments.""" m = re.match(r"^projects/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str, ) -> str: + def common_location_path(project: str, location: str) -> str: """Returns a fully-qualified location string.""" return f"projects/{project}/locations/{location}" @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: + def parse_common_location_path(path: str) -> Dict[str, str]: """Parse a location path into its component segments.""" m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): """Return the API endpoint and client cert source for mutual TLS. The client cert source is determined in the following order: @@ -299,9 +302,13 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") if use_client_cert not in ("true", "false"): - raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) # Figure out the client cert source to use. client_cert_source = None @@ -321,12 +328,14 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio return api_endpoint, client_cert_source - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, QuantumEngineServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: + def __init__( + self, + *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, QuantumEngineServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: """Instantiates the quantum engine service client. Args: @@ -369,7 +378,9 @@ def __init__(self, *, if client_options is None: client_options = client_options_lib.ClientOptions() - api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(client_options) + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options + ) api_key_value = getattr(client_options, "api_key", None) if api_key_value and credentials: @@ -381,12 +392,12 @@ def __init__(self, *, if isinstance(transport, QuantumEngineServiceTransport): # transport is a QuantumEngineServiceTransport instance. if credentials or client_options.credentials_file or api_key_value: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") + raise ValueError( + "When providing a transport instance, " "provide its credentials directly." + ) if client_options.scopes: raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." + "When providing a transport instance, provide its scopes " "directly." ) self._transport = transport else: @@ -407,13 +418,14 @@ def __init__(self, *, always_use_jwt_access=True, ) - def create_quantum_program(self, - request: Union[engine.CreateQuantumProgramRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumProgram: + def create_quantum_program( + self, + request: Union[engine.CreateQuantumProgramRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumProgram: r"""- .. code-block:: python @@ -459,32 +471,26 @@ def sample_create_quantum_program(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_quantum_program] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def get_quantum_program(self, - request: Union[engine.GetQuantumProgramRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumProgram: + def get_quantum_program( + self, + request: Union[engine.GetQuantumProgramRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumProgram: r"""- .. code-block:: python @@ -530,32 +536,26 @@ def sample_get_quantum_program(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_quantum_program] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def list_quantum_programs(self, - request: Union[engine.ListQuantumProgramsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumProgramsPager: + def list_quantum_programs( + self, + request: Union[engine.ListQuantumProgramsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumProgramsPager: r"""- .. code-block:: python @@ -606,41 +606,32 @@ def sample_list_quantum_programs(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_programs] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumProgramsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - def delete_quantum_program(self, - request: Union[engine.DeleteQuantumProgramRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + def delete_quantum_program( + self, + request: Union[engine.DeleteQuantumProgramRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""- .. code-block:: python @@ -679,29 +670,23 @@ def sample_delete_quantum_program(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.delete_quantum_program] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def update_quantum_program(self, - request: Union[engine.UpdateQuantumProgramRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumProgram: + rpc(request, retry=retry, timeout=timeout, metadata=metadata) + + def update_quantum_program( + self, + request: Union[engine.UpdateQuantumProgramRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumProgram: r"""- .. code-block:: python @@ -747,32 +732,26 @@ def sample_update_quantum_program(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.update_quantum_program] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def create_quantum_job(self, - request: Union[engine.CreateQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumJob: + def create_quantum_job( + self, + request: Union[engine.CreateQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumJob: r"""- .. code-block:: python @@ -818,32 +797,26 @@ def sample_create_quantum_job(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_quantum_job] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def get_quantum_job(self, - request: Union[engine.GetQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumJob: + def get_quantum_job( + self, + request: Union[engine.GetQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumJob: r"""- .. code-block:: python @@ -889,32 +862,26 @@ def sample_get_quantum_job(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_quantum_job] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def list_quantum_jobs(self, - request: Union[engine.ListQuantumJobsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumJobsPager: + def list_quantum_jobs( + self, + request: Union[engine.ListQuantumJobsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumJobsPager: r"""- .. code-block:: python @@ -965,41 +932,32 @@ def sample_list_quantum_jobs(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_jobs] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumJobsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - def delete_quantum_job(self, - request: Union[engine.DeleteQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + def delete_quantum_job( + self, + request: Union[engine.DeleteQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""- .. code-block:: python @@ -1038,29 +996,23 @@ def sample_delete_quantum_job(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.delete_quantum_job] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def update_quantum_job(self, - request: Union[engine.UpdateQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumJob: + rpc(request, retry=retry, timeout=timeout, metadata=metadata) + + def update_quantum_job( + self, + request: Union[engine.UpdateQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumJob: r"""- .. code-block:: python @@ -1106,32 +1058,26 @@ def sample_update_quantum_job(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.update_quantum_job] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def cancel_quantum_job(self, - request: Union[engine.CancelQuantumJobRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + def cancel_quantum_job( + self, + request: Union[engine.CancelQuantumJobRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""- .. code-block:: python @@ -1170,29 +1116,23 @@ def sample_cancel_quantum_job(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.cancel_quantum_job] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def list_quantum_job_events(self, - request: Union[engine.ListQuantumJobEventsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumJobEventsPager: + rpc(request, retry=retry, timeout=timeout, metadata=metadata) + + def list_quantum_job_events( + self, + request: Union[engine.ListQuantumJobEventsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumJobEventsPager: r"""- .. code-block:: python @@ -1243,41 +1183,32 @@ def sample_list_quantum_job_events(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_job_events] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumJobEventsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - def get_quantum_result(self, - request: Union[engine.GetQuantumResultRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumResult: + def get_quantum_result( + self, + request: Union[engine.GetQuantumResultRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumResult: r"""- .. code-block:: python @@ -1323,32 +1254,26 @@ def sample_get_quantum_result(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_quantum_result] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def list_quantum_processors(self, - request: Union[engine.ListQuantumProcessorsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumProcessorsPager: + def list_quantum_processors( + self, + request: Union[engine.ListQuantumProcessorsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumProcessorsPager: r"""- .. code-block:: python @@ -1399,41 +1324,32 @@ def sample_list_quantum_processors(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_processors] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumProcessorsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - def get_quantum_processor(self, - request: Union[engine.GetQuantumProcessorRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumProcessor: + def get_quantum_processor( + self, + request: Union[engine.GetQuantumProcessorRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumProcessor: r"""- .. code-block:: python @@ -1479,32 +1395,26 @@ def sample_get_quantum_processor(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_quantum_processor] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def list_quantum_calibrations(self, - request: Union[engine.ListQuantumCalibrationsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumCalibrationsPager: + def list_quantum_calibrations( + self, + request: Union[engine.ListQuantumCalibrationsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumCalibrationsPager: r"""- .. code-block:: python @@ -1555,41 +1465,32 @@ def sample_list_quantum_calibrations(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_calibrations] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumCalibrationsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - def get_quantum_calibration(self, - request: Union[engine.GetQuantumCalibrationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumCalibration: + def get_quantum_calibration( + self, + request: Union[engine.GetQuantumCalibrationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumCalibration: r"""- .. code-block:: python @@ -1635,32 +1536,26 @@ def sample_get_quantum_calibration(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_quantum_calibration] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def create_quantum_reservation(self, - request: Union[engine.CreateQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservation: + def create_quantum_reservation( + self, + request: Union[engine.CreateQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservation: r"""- .. code-block:: python @@ -1706,32 +1601,26 @@ def sample_create_quantum_reservation(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_quantum_reservation] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def cancel_quantum_reservation(self, - request: Union[engine.CancelQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservation: + def cancel_quantum_reservation( + self, + request: Union[engine.CancelQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservation: r"""- .. code-block:: python @@ -1777,32 +1666,26 @@ def sample_cancel_quantum_reservation(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.cancel_quantum_reservation] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def delete_quantum_reservation(self, - request: Union[engine.DeleteQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: + def delete_quantum_reservation( + self, + request: Union[engine.DeleteQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: r"""- .. code-block:: python @@ -1841,29 +1724,23 @@ def sample_delete_quantum_reservation(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.delete_quantum_reservation] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def get_quantum_reservation(self, - request: Union[engine.GetQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservation: + rpc(request, retry=retry, timeout=timeout, metadata=metadata) + + def get_quantum_reservation( + self, + request: Union[engine.GetQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservation: r"""- .. code-block:: python @@ -1909,32 +1786,26 @@ def sample_get_quantum_reservation(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_quantum_reservation] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def list_quantum_reservations(self, - request: Union[engine.ListQuantumReservationsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumReservationsPager: + def list_quantum_reservations( + self, + request: Union[engine.ListQuantumReservationsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumReservationsPager: r"""- .. code-block:: python @@ -1985,41 +1856,32 @@ def sample_list_quantum_reservations(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_reservations] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumReservationsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - def update_quantum_reservation(self, - request: Union[engine.UpdateQuantumReservationRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservation: + def update_quantum_reservation( + self, + request: Union[engine.UpdateQuantumReservationRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservation: r"""- .. code-block:: python @@ -2065,32 +1927,26 @@ def sample_update_quantum_reservation(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.update_quantum_reservation] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def quantum_run_stream(self, - requests: Optional[Iterator[engine.QuantumRunStreamRequest]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> Iterable[engine.QuantumRunStreamResponse]: + def quantum_run_stream( + self, + requests: Optional[Iterator[engine.QuantumRunStreamRequest]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> Iterable[engine.QuantumRunStreamResponse]: r"""- .. code-block:: python @@ -2141,23 +1997,19 @@ def request_generator(): rpc = self._transport._wrapped_methods[self._transport.quantum_run_stream] # Send the request. - response = rpc( - requests, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def list_quantum_reservation_grants(self, - request: Union[engine.ListQuantumReservationGrantsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumReservationGrantsPager: + def list_quantum_reservation_grants( + self, + request: Union[engine.ListQuantumReservationGrantsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumReservationGrantsPager: r"""- .. code-block:: python @@ -2208,41 +2060,32 @@ def sample_list_quantum_reservation_grants(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_reservation_grants] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumReservationGrantsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - def reallocate_quantum_reservation_grant(self, - request: Union[engine.ReallocateQuantumReservationGrantRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> quantum.QuantumReservationGrant: + def reallocate_quantum_reservation_grant( + self, + request: Union[engine.ReallocateQuantumReservationGrantRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> quantum.QuantumReservationGrant: r"""- .. code-block:: python @@ -2288,32 +2131,26 @@ def sample_reallocate_quantum_reservation_grant(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.reallocate_quantum_reservation_grant] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response - def list_quantum_reservation_budgets(self, - request: Union[engine.ListQuantumReservationBudgetsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumReservationBudgetsPager: + def list_quantum_reservation_budgets( + self, + request: Union[engine.ListQuantumReservationBudgetsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumReservationBudgetsPager: r"""- .. code-block:: python @@ -2364,41 +2201,32 @@ def sample_list_quantum_reservation_budgets(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_reservation_budgets] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumReservationBudgetsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. return response - def list_quantum_time_slots(self, - request: Union[engine.ListQuantumTimeSlotsRequest, dict, None] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListQuantumTimeSlotsPager: + def list_quantum_time_slots( + self, + request: Union[engine.ListQuantumTimeSlotsRequest, dict, None] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListQuantumTimeSlotsPager: r"""- .. code-block:: python @@ -2449,29 +2277,19 @@ def sample_list_quantum_time_slots(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_quantum_time_slots] - # Certain fields should be provided within the metadata header; + # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQuantumTimeSlotsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, + method=rpc, request=request, response=response, metadata=metadata ) # Done; return the response. @@ -2491,17 +2309,12 @@ def __exit__(self, type, value, traceback): self.transport.close() - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-quantum", - ).version, + gapic_version=pkg_resources.get_distribution("google-cloud-quantum").version ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -__all__ = ( - "QuantumEngineServiceClient", -) +__all__ = ("QuantumEngineServiceClient",) diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/pagers.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/pagers.py index 49b315de505..b483c8023ca 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/pagers.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/pagers.py @@ -36,12 +36,15 @@ class ListQuantumProgramsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumProgramsResponse], - request: engine.ListQuantumProgramsRequest, - response: engine.ListQuantumProgramsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumProgramsResponse], + request: engine.ListQuantumProgramsRequest, + response: engine.ListQuantumProgramsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -95,12 +98,15 @@ class ListQuantumProgramsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumProgramsResponse]], - request: engine.ListQuantumProgramsRequest, - response: engine.ListQuantumProgramsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumProgramsResponse]], + request: engine.ListQuantumProgramsRequest, + response: engine.ListQuantumProgramsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -128,6 +134,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumProgramsResponse]: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumProgram]: async def async_generator(): async for page in self.pages: @@ -157,12 +164,15 @@ class ListQuantumJobsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumJobsResponse], - request: engine.ListQuantumJobsRequest, - response: engine.ListQuantumJobsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumJobsResponse], + request: engine.ListQuantumJobsRequest, + response: engine.ListQuantumJobsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -216,12 +226,15 @@ class ListQuantumJobsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumJobsResponse]], - request: engine.ListQuantumJobsRequest, - response: engine.ListQuantumJobsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumJobsResponse]], + request: engine.ListQuantumJobsRequest, + response: engine.ListQuantumJobsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -249,6 +262,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumJobsResponse]: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumJob]: async def async_generator(): async for page in self.pages: @@ -278,12 +292,15 @@ class ListQuantumJobEventsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumJobEventsResponse], - request: engine.ListQuantumJobEventsRequest, - response: engine.ListQuantumJobEventsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumJobEventsResponse], + request: engine.ListQuantumJobEventsRequest, + response: engine.ListQuantumJobEventsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -337,12 +354,15 @@ class ListQuantumJobEventsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumJobEventsResponse]], - request: engine.ListQuantumJobEventsRequest, - response: engine.ListQuantumJobEventsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumJobEventsResponse]], + request: engine.ListQuantumJobEventsRequest, + response: engine.ListQuantumJobEventsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -370,6 +390,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumJobEventsResponse]: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumJobEvent]: async def async_generator(): async for page in self.pages: @@ -399,12 +420,15 @@ class ListQuantumProcessorsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumProcessorsResponse], - request: engine.ListQuantumProcessorsRequest, - response: engine.ListQuantumProcessorsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumProcessorsResponse], + request: engine.ListQuantumProcessorsRequest, + response: engine.ListQuantumProcessorsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -458,12 +482,15 @@ class ListQuantumProcessorsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumProcessorsResponse]], - request: engine.ListQuantumProcessorsRequest, - response: engine.ListQuantumProcessorsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumProcessorsResponse]], + request: engine.ListQuantumProcessorsRequest, + response: engine.ListQuantumProcessorsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -491,6 +518,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumProcessorsResponse]: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumProcessor]: async def async_generator(): async for page in self.pages: @@ -520,12 +548,15 @@ class ListQuantumCalibrationsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumCalibrationsResponse], - request: engine.ListQuantumCalibrationsRequest, - response: engine.ListQuantumCalibrationsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumCalibrationsResponse], + request: engine.ListQuantumCalibrationsRequest, + response: engine.ListQuantumCalibrationsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -579,12 +610,15 @@ class ListQuantumCalibrationsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumCalibrationsResponse]], - request: engine.ListQuantumCalibrationsRequest, - response: engine.ListQuantumCalibrationsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumCalibrationsResponse]], + request: engine.ListQuantumCalibrationsRequest, + response: engine.ListQuantumCalibrationsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -612,6 +646,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumCalibrationsResponse]: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumCalibration]: async def async_generator(): async for page in self.pages: @@ -641,12 +676,15 @@ class ListQuantumReservationsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumReservationsResponse], - request: engine.ListQuantumReservationsRequest, - response: engine.ListQuantumReservationsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumReservationsResponse], + request: engine.ListQuantumReservationsRequest, + response: engine.ListQuantumReservationsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -700,12 +738,15 @@ class ListQuantumReservationsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumReservationsResponse]], - request: engine.ListQuantumReservationsRequest, - response: engine.ListQuantumReservationsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumReservationsResponse]], + request: engine.ListQuantumReservationsRequest, + response: engine.ListQuantumReservationsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -733,6 +774,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumReservationsResponse]: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumReservation]: async def async_generator(): async for page in self.pages: @@ -762,12 +804,15 @@ class ListQuantumReservationGrantsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumReservationGrantsResponse], - request: engine.ListQuantumReservationGrantsRequest, - response: engine.ListQuantumReservationGrantsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumReservationGrantsResponse], + request: engine.ListQuantumReservationGrantsRequest, + response: engine.ListQuantumReservationGrantsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -821,12 +866,15 @@ class ListQuantumReservationGrantsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumReservationGrantsResponse]], - request: engine.ListQuantumReservationGrantsRequest, - response: engine.ListQuantumReservationGrantsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumReservationGrantsResponse]], + request: engine.ListQuantumReservationGrantsRequest, + response: engine.ListQuantumReservationGrantsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -854,6 +902,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumReservationGrantsRespon self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumReservationGrant]: async def async_generator(): async for page in self.pages: @@ -883,12 +932,15 @@ class ListQuantumReservationBudgetsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumReservationBudgetsResponse], - request: engine.ListQuantumReservationBudgetsRequest, - response: engine.ListQuantumReservationBudgetsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumReservationBudgetsResponse], + request: engine.ListQuantumReservationBudgetsRequest, + response: engine.ListQuantumReservationBudgetsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -942,12 +994,15 @@ class ListQuantumReservationBudgetsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumReservationBudgetsResponse]], - request: engine.ListQuantumReservationBudgetsRequest, - response: engine.ListQuantumReservationBudgetsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumReservationBudgetsResponse]], + request: engine.ListQuantumReservationBudgetsRequest, + response: engine.ListQuantumReservationBudgetsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -975,6 +1030,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumReservationBudgetsRespo self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumReservationBudget]: async def async_generator(): async for page in self.pages: @@ -1004,12 +1060,15 @@ class ListQuantumTimeSlotsPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., engine.ListQuantumTimeSlotsResponse], - request: engine.ListQuantumTimeSlotsRequest, - response: engine.ListQuantumTimeSlotsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., engine.ListQuantumTimeSlotsResponse], + request: engine.ListQuantumTimeSlotsRequest, + response: engine.ListQuantumTimeSlotsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiate the pager. Args: @@ -1063,12 +1122,15 @@ class ListQuantumTimeSlotsAsyncPager: attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ - def __init__(self, - method: Callable[..., Awaitable[engine.ListQuantumTimeSlotsResponse]], - request: engine.ListQuantumTimeSlotsRequest, - response: engine.ListQuantumTimeSlotsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): + + def __init__( + self, + method: Callable[..., Awaitable[engine.ListQuantumTimeSlotsResponse]], + request: engine.ListQuantumTimeSlotsRequest, + response: engine.ListQuantumTimeSlotsResponse, + *, + metadata: Sequence[Tuple[str, str]] = (), + ): """Instantiates the pager. Args: @@ -1096,6 +1158,7 @@ async def pages(self) -> AsyncIterator[engine.ListQuantumTimeSlotsResponse]: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response + def __aiter__(self) -> AsyncIterator[quantum.QuantumTimeSlot]: async def async_generator(): async for page in self.pages: diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/base.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/base.py index dbb27582d2a..a4f489e3437 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/base.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/base.py @@ -23,7 +23,7 @@ from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials -from google.oauth2 import service_account # type: ignore +from google.oauth2 import service_account # type: ignore from cirq_google.cloud.quantum_v1alpha1.types import engine from cirq_google.cloud.quantum_v1alpha1.types import quantum @@ -31,9 +31,7 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - 'google-cloud-quantum', - ).version, + gapic_version=pkg_resources.get_distribution('google-cloud-quantum').version ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -42,22 +40,22 @@ class QuantumEngineServiceTransport(abc.ABC): """Abstract transport class for QuantumEngineService.""" - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) + AUTH_SCOPES = ('https://www.googleapis.com/auth/cloud-platform',) DEFAULT_HOST: str = 'quantum.googleapis.com' + def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - **kwargs, - ) -> None: + self, + *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: """Instantiate the transport. Args: @@ -95,19 +93,23 @@ def __init__( # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + raise core_exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + ) elif credentials is None: credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) # If the credentials are service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. @@ -117,129 +119,79 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_quantum_program: gapic_v1.method.wrap_method( - self.create_quantum_program, - default_timeout=60.0, - client_info=client_info, + self.create_quantum_program, default_timeout=60.0, client_info=client_info ), self.get_quantum_program: gapic_v1.method.wrap_method( - self.get_quantum_program, - default_timeout=60.0, - client_info=client_info, + self.get_quantum_program, default_timeout=60.0, client_info=client_info ), self.list_quantum_programs: gapic_v1.method.wrap_method( - self.list_quantum_programs, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_programs, default_timeout=60.0, client_info=client_info ), self.delete_quantum_program: gapic_v1.method.wrap_method( - self.delete_quantum_program, - default_timeout=60.0, - client_info=client_info, + self.delete_quantum_program, default_timeout=60.0, client_info=client_info ), self.update_quantum_program: gapic_v1.method.wrap_method( - self.update_quantum_program, - default_timeout=60.0, - client_info=client_info, + self.update_quantum_program, default_timeout=60.0, client_info=client_info ), self.create_quantum_job: gapic_v1.method.wrap_method( - self.create_quantum_job, - default_timeout=60.0, - client_info=client_info, + self.create_quantum_job, default_timeout=60.0, client_info=client_info ), self.get_quantum_job: gapic_v1.method.wrap_method( - self.get_quantum_job, - default_timeout=60.0, - client_info=client_info, + self.get_quantum_job, default_timeout=60.0, client_info=client_info ), self.list_quantum_jobs: gapic_v1.method.wrap_method( - self.list_quantum_jobs, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_jobs, default_timeout=60.0, client_info=client_info ), self.delete_quantum_job: gapic_v1.method.wrap_method( - self.delete_quantum_job, - default_timeout=60.0, - client_info=client_info, + self.delete_quantum_job, default_timeout=60.0, client_info=client_info ), self.update_quantum_job: gapic_v1.method.wrap_method( - self.update_quantum_job, - default_timeout=60.0, - client_info=client_info, + self.update_quantum_job, default_timeout=60.0, client_info=client_info ), self.cancel_quantum_job: gapic_v1.method.wrap_method( - self.cancel_quantum_job, - default_timeout=None, - client_info=client_info, + self.cancel_quantum_job, default_timeout=None, client_info=client_info ), self.list_quantum_job_events: gapic_v1.method.wrap_method( - self.list_quantum_job_events, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_job_events, default_timeout=60.0, client_info=client_info ), self.get_quantum_result: gapic_v1.method.wrap_method( - self.get_quantum_result, - default_timeout=60.0, - client_info=client_info, + self.get_quantum_result, default_timeout=60.0, client_info=client_info ), self.list_quantum_processors: gapic_v1.method.wrap_method( - self.list_quantum_processors, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_processors, default_timeout=60.0, client_info=client_info ), self.get_quantum_processor: gapic_v1.method.wrap_method( - self.get_quantum_processor, - default_timeout=60.0, - client_info=client_info, + self.get_quantum_processor, default_timeout=60.0, client_info=client_info ), self.list_quantum_calibrations: gapic_v1.method.wrap_method( - self.list_quantum_calibrations, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_calibrations, default_timeout=60.0, client_info=client_info ), self.get_quantum_calibration: gapic_v1.method.wrap_method( - self.get_quantum_calibration, - default_timeout=60.0, - client_info=client_info, + self.get_quantum_calibration, default_timeout=60.0, client_info=client_info ), self.create_quantum_reservation: gapic_v1.method.wrap_method( - self.create_quantum_reservation, - default_timeout=60.0, - client_info=client_info, + self.create_quantum_reservation, default_timeout=60.0, client_info=client_info ), self.cancel_quantum_reservation: gapic_v1.method.wrap_method( - self.cancel_quantum_reservation, - default_timeout=60.0, - client_info=client_info, + self.cancel_quantum_reservation, default_timeout=60.0, client_info=client_info ), self.delete_quantum_reservation: gapic_v1.method.wrap_method( - self.delete_quantum_reservation, - default_timeout=60.0, - client_info=client_info, + self.delete_quantum_reservation, default_timeout=60.0, client_info=client_info ), self.get_quantum_reservation: gapic_v1.method.wrap_method( - self.get_quantum_reservation, - default_timeout=60.0, - client_info=client_info, + self.get_quantum_reservation, default_timeout=60.0, client_info=client_info ), self.list_quantum_reservations: gapic_v1.method.wrap_method( - self.list_quantum_reservations, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_reservations, default_timeout=60.0, client_info=client_info ), self.update_quantum_reservation: gapic_v1.method.wrap_method( - self.update_quantum_reservation, - default_timeout=60.0, - client_info=client_info, + self.update_quantum_reservation, default_timeout=60.0, client_info=client_info ), self.quantum_run_stream: gapic_v1.method.wrap_method( - self.quantum_run_stream, - default_timeout=60.0, - client_info=client_info, + self.quantum_run_stream, default_timeout=60.0, client_info=client_info ), self.list_quantum_reservation_grants: gapic_v1.method.wrap_method( - self.list_quantum_reservation_grants, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_reservation_grants, default_timeout=60.0, client_info=client_info ), self.reallocate_quantum_reservation_grant: gapic_v1.method.wrap_method( self.reallocate_quantum_reservation_grant, @@ -247,279 +199,280 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.list_quantum_reservation_budgets: gapic_v1.method.wrap_method( - self.list_quantum_reservation_budgets, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_reservation_budgets, default_timeout=60.0, client_info=client_info ), self.list_quantum_time_slots: gapic_v1.method.wrap_method( - self.list_quantum_time_slots, - default_timeout=60.0, - client_info=client_info, + self.list_quantum_time_slots, default_timeout=60.0, client_info=client_info ), - } + } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @property - def create_quantum_program(self) -> Callable[ - [engine.CreateQuantumProgramRequest], - Union[ - quantum.QuantumProgram, - Awaitable[quantum.QuantumProgram] - ]]: + def create_quantum_program( + self, + ) -> Callable[ + [engine.CreateQuantumProgramRequest], + Union[quantum.QuantumProgram, Awaitable[quantum.QuantumProgram]], + ]: raise NotImplementedError() @property - def get_quantum_program(self) -> Callable[ - [engine.GetQuantumProgramRequest], - Union[ - quantum.QuantumProgram, - Awaitable[quantum.QuantumProgram] - ]]: + def get_quantum_program( + self, + ) -> Callable[ + [engine.GetQuantumProgramRequest], + Union[quantum.QuantumProgram, Awaitable[quantum.QuantumProgram]], + ]: raise NotImplementedError() @property - def list_quantum_programs(self) -> Callable[ - [engine.ListQuantumProgramsRequest], - Union[ - engine.ListQuantumProgramsResponse, - Awaitable[engine.ListQuantumProgramsResponse] - ]]: + def list_quantum_programs( + self, + ) -> Callable[ + [engine.ListQuantumProgramsRequest], + Union[engine.ListQuantumProgramsResponse, Awaitable[engine.ListQuantumProgramsResponse]], + ]: raise NotImplementedError() @property - def delete_quantum_program(self) -> Callable[ - [engine.DeleteQuantumProgramRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: + def delete_quantum_program( + self, + ) -> Callable[ + [engine.DeleteQuantumProgramRequest], Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]] + ]: raise NotImplementedError() @property - def update_quantum_program(self) -> Callable[ - [engine.UpdateQuantumProgramRequest], - Union[ - quantum.QuantumProgram, - Awaitable[quantum.QuantumProgram] - ]]: + def update_quantum_program( + self, + ) -> Callable[ + [engine.UpdateQuantumProgramRequest], + Union[quantum.QuantumProgram, Awaitable[quantum.QuantumProgram]], + ]: raise NotImplementedError() @property - def create_quantum_job(self) -> Callable[ - [engine.CreateQuantumJobRequest], - Union[ - quantum.QuantumJob, - Awaitable[quantum.QuantumJob] - ]]: + def create_quantum_job( + self, + ) -> Callable[ + [engine.CreateQuantumJobRequest], Union[quantum.QuantumJob, Awaitable[quantum.QuantumJob]] + ]: raise NotImplementedError() @property - def get_quantum_job(self) -> Callable[ - [engine.GetQuantumJobRequest], - Union[ - quantum.QuantumJob, - Awaitable[quantum.QuantumJob] - ]]: + def get_quantum_job( + self, + ) -> Callable[ + [engine.GetQuantumJobRequest], Union[quantum.QuantumJob, Awaitable[quantum.QuantumJob]] + ]: raise NotImplementedError() @property - def list_quantum_jobs(self) -> Callable[ - [engine.ListQuantumJobsRequest], - Union[ - engine.ListQuantumJobsResponse, - Awaitable[engine.ListQuantumJobsResponse] - ]]: + def list_quantum_jobs( + self, + ) -> Callable[ + [engine.ListQuantumJobsRequest], + Union[engine.ListQuantumJobsResponse, Awaitable[engine.ListQuantumJobsResponse]], + ]: raise NotImplementedError() @property - def delete_quantum_job(self) -> Callable[ - [engine.DeleteQuantumJobRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: + def delete_quantum_job( + self, + ) -> Callable[ + [engine.DeleteQuantumJobRequest], Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]] + ]: raise NotImplementedError() @property - def update_quantum_job(self) -> Callable[ - [engine.UpdateQuantumJobRequest], - Union[ - quantum.QuantumJob, - Awaitable[quantum.QuantumJob] - ]]: + def update_quantum_job( + self, + ) -> Callable[ + [engine.UpdateQuantumJobRequest], Union[quantum.QuantumJob, Awaitable[quantum.QuantumJob]] + ]: raise NotImplementedError() @property - def cancel_quantum_job(self) -> Callable[ - [engine.CancelQuantumJobRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: + def cancel_quantum_job( + self, + ) -> Callable[ + [engine.CancelQuantumJobRequest], Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]] + ]: raise NotImplementedError() @property - def list_quantum_job_events(self) -> Callable[ - [engine.ListQuantumJobEventsRequest], - Union[ - engine.ListQuantumJobEventsResponse, - Awaitable[engine.ListQuantumJobEventsResponse] - ]]: + def list_quantum_job_events( + self, + ) -> Callable[ + [engine.ListQuantumJobEventsRequest], + Union[engine.ListQuantumJobEventsResponse, Awaitable[engine.ListQuantumJobEventsResponse]], + ]: raise NotImplementedError() @property - def get_quantum_result(self) -> Callable[ - [engine.GetQuantumResultRequest], - Union[ - quantum.QuantumResult, - Awaitable[quantum.QuantumResult] - ]]: + def get_quantum_result( + self, + ) -> Callable[ + [engine.GetQuantumResultRequest], + Union[quantum.QuantumResult, Awaitable[quantum.QuantumResult]], + ]: raise NotImplementedError() @property - def list_quantum_processors(self) -> Callable[ - [engine.ListQuantumProcessorsRequest], - Union[ - engine.ListQuantumProcessorsResponse, - Awaitable[engine.ListQuantumProcessorsResponse] - ]]: + def list_quantum_processors( + self, + ) -> Callable[ + [engine.ListQuantumProcessorsRequest], + Union[ + engine.ListQuantumProcessorsResponse, Awaitable[engine.ListQuantumProcessorsResponse] + ], + ]: raise NotImplementedError() @property - def get_quantum_processor(self) -> Callable[ - [engine.GetQuantumProcessorRequest], - Union[ - quantum.QuantumProcessor, - Awaitable[quantum.QuantumProcessor] - ]]: + def get_quantum_processor( + self, + ) -> Callable[ + [engine.GetQuantumProcessorRequest], + Union[quantum.QuantumProcessor, Awaitable[quantum.QuantumProcessor]], + ]: raise NotImplementedError() @property - def list_quantum_calibrations(self) -> Callable[ - [engine.ListQuantumCalibrationsRequest], - Union[ - engine.ListQuantumCalibrationsResponse, - Awaitable[engine.ListQuantumCalibrationsResponse] - ]]: + def list_quantum_calibrations( + self, + ) -> Callable[ + [engine.ListQuantumCalibrationsRequest], + Union[ + engine.ListQuantumCalibrationsResponse, + Awaitable[engine.ListQuantumCalibrationsResponse], + ], + ]: raise NotImplementedError() @property - def get_quantum_calibration(self) -> Callable[ - [engine.GetQuantumCalibrationRequest], - Union[ - quantum.QuantumCalibration, - Awaitable[quantum.QuantumCalibration] - ]]: + def get_quantum_calibration( + self, + ) -> Callable[ + [engine.GetQuantumCalibrationRequest], + Union[quantum.QuantumCalibration, Awaitable[quantum.QuantumCalibration]], + ]: raise NotImplementedError() @property - def create_quantum_reservation(self) -> Callable[ - [engine.CreateQuantumReservationRequest], - Union[ - quantum.QuantumReservation, - Awaitable[quantum.QuantumReservation] - ]]: + def create_quantum_reservation( + self, + ) -> Callable[ + [engine.CreateQuantumReservationRequest], + Union[quantum.QuantumReservation, Awaitable[quantum.QuantumReservation]], + ]: raise NotImplementedError() @property - def cancel_quantum_reservation(self) -> Callable[ - [engine.CancelQuantumReservationRequest], - Union[ - quantum.QuantumReservation, - Awaitable[quantum.QuantumReservation] - ]]: + def cancel_quantum_reservation( + self, + ) -> Callable[ + [engine.CancelQuantumReservationRequest], + Union[quantum.QuantumReservation, Awaitable[quantum.QuantumReservation]], + ]: raise NotImplementedError() @property - def delete_quantum_reservation(self) -> Callable[ - [engine.DeleteQuantumReservationRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: + def delete_quantum_reservation( + self, + ) -> Callable[ + [engine.DeleteQuantumReservationRequest], Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]] + ]: raise NotImplementedError() @property - def get_quantum_reservation(self) -> Callable[ - [engine.GetQuantumReservationRequest], - Union[ - quantum.QuantumReservation, - Awaitable[quantum.QuantumReservation] - ]]: + def get_quantum_reservation( + self, + ) -> Callable[ + [engine.GetQuantumReservationRequest], + Union[quantum.QuantumReservation, Awaitable[quantum.QuantumReservation]], + ]: raise NotImplementedError() @property - def list_quantum_reservations(self) -> Callable[ - [engine.ListQuantumReservationsRequest], - Union[ - engine.ListQuantumReservationsResponse, - Awaitable[engine.ListQuantumReservationsResponse] - ]]: + def list_quantum_reservations( + self, + ) -> Callable[ + [engine.ListQuantumReservationsRequest], + Union[ + engine.ListQuantumReservationsResponse, + Awaitable[engine.ListQuantumReservationsResponse], + ], + ]: raise NotImplementedError() @property - def update_quantum_reservation(self) -> Callable[ - [engine.UpdateQuantumReservationRequest], - Union[ - quantum.QuantumReservation, - Awaitable[quantum.QuantumReservation] - ]]: + def update_quantum_reservation( + self, + ) -> Callable[ + [engine.UpdateQuantumReservationRequest], + Union[quantum.QuantumReservation, Awaitable[quantum.QuantumReservation]], + ]: raise NotImplementedError() @property - def quantum_run_stream(self) -> Callable[ - [engine.QuantumRunStreamRequest], - Union[ - engine.QuantumRunStreamResponse, - Awaitable[engine.QuantumRunStreamResponse] - ]]: + def quantum_run_stream( + self, + ) -> Callable[ + [engine.QuantumRunStreamRequest], + Union[engine.QuantumRunStreamResponse, Awaitable[engine.QuantumRunStreamResponse]], + ]: raise NotImplementedError() @property - def list_quantum_reservation_grants(self) -> Callable[ - [engine.ListQuantumReservationGrantsRequest], - Union[ - engine.ListQuantumReservationGrantsResponse, - Awaitable[engine.ListQuantumReservationGrantsResponse] - ]]: + def list_quantum_reservation_grants( + self, + ) -> Callable[ + [engine.ListQuantumReservationGrantsRequest], + Union[ + engine.ListQuantumReservationGrantsResponse, + Awaitable[engine.ListQuantumReservationGrantsResponse], + ], + ]: raise NotImplementedError() @property - def reallocate_quantum_reservation_grant(self) -> Callable[ - [engine.ReallocateQuantumReservationGrantRequest], - Union[ - quantum.QuantumReservationGrant, - Awaitable[quantum.QuantumReservationGrant] - ]]: + def reallocate_quantum_reservation_grant( + self, + ) -> Callable[ + [engine.ReallocateQuantumReservationGrantRequest], + Union[quantum.QuantumReservationGrant, Awaitable[quantum.QuantumReservationGrant]], + ]: raise NotImplementedError() @property - def list_quantum_reservation_budgets(self) -> Callable[ - [engine.ListQuantumReservationBudgetsRequest], - Union[ - engine.ListQuantumReservationBudgetsResponse, - Awaitable[engine.ListQuantumReservationBudgetsResponse] - ]]: + def list_quantum_reservation_budgets( + self, + ) -> Callable[ + [engine.ListQuantumReservationBudgetsRequest], + Union[ + engine.ListQuantumReservationBudgetsResponse, + Awaitable[engine.ListQuantumReservationBudgetsResponse], + ], + ]: raise NotImplementedError() @property - def list_quantum_time_slots(self) -> Callable[ - [engine.ListQuantumTimeSlotsRequest], - Union[ - engine.ListQuantumTimeSlotsResponse, - Awaitable[engine.ListQuantumTimeSlotsResponse] - ]]: + def list_quantum_time_slots( + self, + ) -> Callable[ + [engine.ListQuantumTimeSlotsRequest], + Union[engine.ListQuantumTimeSlotsResponse, Awaitable[engine.ListQuantumTimeSlotsResponse]], + ]: raise NotImplementedError() -__all__ = ( - 'QuantumEngineServiceTransport', -) +__all__ = ('QuantumEngineServiceTransport',) diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/grpc.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/grpc.py index 4b5a94b212d..5658f4293da 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/grpc.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/grpc.py @@ -42,22 +42,25 @@ class QuantumEngineServiceGrpcTransport(QuantumEngineServiceTransport): It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """ + _stubs: Dict[str, Callable] - def __init__(self, *, - host: str = 'quantum.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[grpc.Channel] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - ) -> None: + def __init__( + self, + *, + host: str = 'quantum.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + ) -> None: """Instantiate the transport. Args: @@ -175,13 +178,15 @@ def __init__(self, *, self._prep_wrapped_messages(client_info) @classmethod - def create_channel(cls, - host: str = 'quantum.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: + def create_channel( + cls, + host: str = 'quantum.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. @@ -216,19 +221,18 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property - def create_quantum_program(self) -> Callable[ - [engine.CreateQuantumProgramRequest], - quantum.QuantumProgram]: + def create_quantum_program( + self, + ) -> Callable[[engine.CreateQuantumProgramRequest], quantum.QuantumProgram]: r"""Return a callable for the create quantum program method over gRPC. - @@ -252,9 +256,9 @@ def create_quantum_program(self) -> Callable[ return self._stubs['create_quantum_program'] @property - def get_quantum_program(self) -> Callable[ - [engine.GetQuantumProgramRequest], - quantum.QuantumProgram]: + def get_quantum_program( + self, + ) -> Callable[[engine.GetQuantumProgramRequest], quantum.QuantumProgram]: r"""Return a callable for the get quantum program method over gRPC. - @@ -278,9 +282,9 @@ def get_quantum_program(self) -> Callable[ return self._stubs['get_quantum_program'] @property - def list_quantum_programs(self) -> Callable[ - [engine.ListQuantumProgramsRequest], - engine.ListQuantumProgramsResponse]: + def list_quantum_programs( + self, + ) -> Callable[[engine.ListQuantumProgramsRequest], engine.ListQuantumProgramsResponse]: r"""Return a callable for the list quantum programs method over gRPC. - @@ -304,9 +308,9 @@ def list_quantum_programs(self) -> Callable[ return self._stubs['list_quantum_programs'] @property - def delete_quantum_program(self) -> Callable[ - [engine.DeleteQuantumProgramRequest], - empty_pb2.Empty]: + def delete_quantum_program( + self, + ) -> Callable[[engine.DeleteQuantumProgramRequest], empty_pb2.Empty]: r"""Return a callable for the delete quantum program method over gRPC. - @@ -330,9 +334,9 @@ def delete_quantum_program(self) -> Callable[ return self._stubs['delete_quantum_program'] @property - def update_quantum_program(self) -> Callable[ - [engine.UpdateQuantumProgramRequest], - quantum.QuantumProgram]: + def update_quantum_program( + self, + ) -> Callable[[engine.UpdateQuantumProgramRequest], quantum.QuantumProgram]: r"""Return a callable for the update quantum program method over gRPC. - @@ -356,9 +360,7 @@ def update_quantum_program(self) -> Callable[ return self._stubs['update_quantum_program'] @property - def create_quantum_job(self) -> Callable[ - [engine.CreateQuantumJobRequest], - quantum.QuantumJob]: + def create_quantum_job(self) -> Callable[[engine.CreateQuantumJobRequest], quantum.QuantumJob]: r"""Return a callable for the create quantum job method over gRPC. - @@ -382,9 +384,7 @@ def create_quantum_job(self) -> Callable[ return self._stubs['create_quantum_job'] @property - def get_quantum_job(self) -> Callable[ - [engine.GetQuantumJobRequest], - quantum.QuantumJob]: + def get_quantum_job(self) -> Callable[[engine.GetQuantumJobRequest], quantum.QuantumJob]: r"""Return a callable for the get quantum job method over gRPC. - @@ -408,9 +408,9 @@ def get_quantum_job(self) -> Callable[ return self._stubs['get_quantum_job'] @property - def list_quantum_jobs(self) -> Callable[ - [engine.ListQuantumJobsRequest], - engine.ListQuantumJobsResponse]: + def list_quantum_jobs( + self, + ) -> Callable[[engine.ListQuantumJobsRequest], engine.ListQuantumJobsResponse]: r"""Return a callable for the list quantum jobs method over gRPC. - @@ -434,9 +434,7 @@ def list_quantum_jobs(self) -> Callable[ return self._stubs['list_quantum_jobs'] @property - def delete_quantum_job(self) -> Callable[ - [engine.DeleteQuantumJobRequest], - empty_pb2.Empty]: + def delete_quantum_job(self) -> Callable[[engine.DeleteQuantumJobRequest], empty_pb2.Empty]: r"""Return a callable for the delete quantum job method over gRPC. - @@ -460,9 +458,7 @@ def delete_quantum_job(self) -> Callable[ return self._stubs['delete_quantum_job'] @property - def update_quantum_job(self) -> Callable[ - [engine.UpdateQuantumJobRequest], - quantum.QuantumJob]: + def update_quantum_job(self) -> Callable[[engine.UpdateQuantumJobRequest], quantum.QuantumJob]: r"""Return a callable for the update quantum job method over gRPC. - @@ -486,9 +482,7 @@ def update_quantum_job(self) -> Callable[ return self._stubs['update_quantum_job'] @property - def cancel_quantum_job(self) -> Callable[ - [engine.CancelQuantumJobRequest], - empty_pb2.Empty]: + def cancel_quantum_job(self) -> Callable[[engine.CancelQuantumJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel quantum job method over gRPC. - @@ -512,9 +506,9 @@ def cancel_quantum_job(self) -> Callable[ return self._stubs['cancel_quantum_job'] @property - def list_quantum_job_events(self) -> Callable[ - [engine.ListQuantumJobEventsRequest], - engine.ListQuantumJobEventsResponse]: + def list_quantum_job_events( + self, + ) -> Callable[[engine.ListQuantumJobEventsRequest], engine.ListQuantumJobEventsResponse]: r"""Return a callable for the list quantum job events method over gRPC. - @@ -538,9 +532,9 @@ def list_quantum_job_events(self) -> Callable[ return self._stubs['list_quantum_job_events'] @property - def get_quantum_result(self) -> Callable[ - [engine.GetQuantumResultRequest], - quantum.QuantumResult]: + def get_quantum_result( + self, + ) -> Callable[[engine.GetQuantumResultRequest], quantum.QuantumResult]: r"""Return a callable for the get quantum result method over gRPC. - @@ -564,9 +558,9 @@ def get_quantum_result(self) -> Callable[ return self._stubs['get_quantum_result'] @property - def list_quantum_processors(self) -> Callable[ - [engine.ListQuantumProcessorsRequest], - engine.ListQuantumProcessorsResponse]: + def list_quantum_processors( + self, + ) -> Callable[[engine.ListQuantumProcessorsRequest], engine.ListQuantumProcessorsResponse]: r"""Return a callable for the list quantum processors method over gRPC. - @@ -590,9 +584,9 @@ def list_quantum_processors(self) -> Callable[ return self._stubs['list_quantum_processors'] @property - def get_quantum_processor(self) -> Callable[ - [engine.GetQuantumProcessorRequest], - quantum.QuantumProcessor]: + def get_quantum_processor( + self, + ) -> Callable[[engine.GetQuantumProcessorRequest], quantum.QuantumProcessor]: r"""Return a callable for the get quantum processor method over gRPC. - @@ -616,9 +610,9 @@ def get_quantum_processor(self) -> Callable[ return self._stubs['get_quantum_processor'] @property - def list_quantum_calibrations(self) -> Callable[ - [engine.ListQuantumCalibrationsRequest], - engine.ListQuantumCalibrationsResponse]: + def list_quantum_calibrations( + self, + ) -> Callable[[engine.ListQuantumCalibrationsRequest], engine.ListQuantumCalibrationsResponse]: r"""Return a callable for the list quantum calibrations method over gRPC. - @@ -642,9 +636,9 @@ def list_quantum_calibrations(self) -> Callable[ return self._stubs['list_quantum_calibrations'] @property - def get_quantum_calibration(self) -> Callable[ - [engine.GetQuantumCalibrationRequest], - quantum.QuantumCalibration]: + def get_quantum_calibration( + self, + ) -> Callable[[engine.GetQuantumCalibrationRequest], quantum.QuantumCalibration]: r"""Return a callable for the get quantum calibration method over gRPC. - @@ -668,9 +662,9 @@ def get_quantum_calibration(self) -> Callable[ return self._stubs['get_quantum_calibration'] @property - def create_quantum_reservation(self) -> Callable[ - [engine.CreateQuantumReservationRequest], - quantum.QuantumReservation]: + def create_quantum_reservation( + self, + ) -> Callable[[engine.CreateQuantumReservationRequest], quantum.QuantumReservation]: r"""Return a callable for the create quantum reservation method over gRPC. - @@ -694,9 +688,9 @@ def create_quantum_reservation(self) -> Callable[ return self._stubs['create_quantum_reservation'] @property - def cancel_quantum_reservation(self) -> Callable[ - [engine.CancelQuantumReservationRequest], - quantum.QuantumReservation]: + def cancel_quantum_reservation( + self, + ) -> Callable[[engine.CancelQuantumReservationRequest], quantum.QuantumReservation]: r"""Return a callable for the cancel quantum reservation method over gRPC. - @@ -720,9 +714,9 @@ def cancel_quantum_reservation(self) -> Callable[ return self._stubs['cancel_quantum_reservation'] @property - def delete_quantum_reservation(self) -> Callable[ - [engine.DeleteQuantumReservationRequest], - empty_pb2.Empty]: + def delete_quantum_reservation( + self, + ) -> Callable[[engine.DeleteQuantumReservationRequest], empty_pb2.Empty]: r"""Return a callable for the delete quantum reservation method over gRPC. - @@ -746,9 +740,9 @@ def delete_quantum_reservation(self) -> Callable[ return self._stubs['delete_quantum_reservation'] @property - def get_quantum_reservation(self) -> Callable[ - [engine.GetQuantumReservationRequest], - quantum.QuantumReservation]: + def get_quantum_reservation( + self, + ) -> Callable[[engine.GetQuantumReservationRequest], quantum.QuantumReservation]: r"""Return a callable for the get quantum reservation method over gRPC. - @@ -772,9 +766,9 @@ def get_quantum_reservation(self) -> Callable[ return self._stubs['get_quantum_reservation'] @property - def list_quantum_reservations(self) -> Callable[ - [engine.ListQuantumReservationsRequest], - engine.ListQuantumReservationsResponse]: + def list_quantum_reservations( + self, + ) -> Callable[[engine.ListQuantumReservationsRequest], engine.ListQuantumReservationsResponse]: r"""Return a callable for the list quantum reservations method over gRPC. - @@ -798,9 +792,9 @@ def list_quantum_reservations(self) -> Callable[ return self._stubs['list_quantum_reservations'] @property - def update_quantum_reservation(self) -> Callable[ - [engine.UpdateQuantumReservationRequest], - quantum.QuantumReservation]: + def update_quantum_reservation( + self, + ) -> Callable[[engine.UpdateQuantumReservationRequest], quantum.QuantumReservation]: r"""Return a callable for the update quantum reservation method over gRPC. - @@ -824,9 +818,9 @@ def update_quantum_reservation(self) -> Callable[ return self._stubs['update_quantum_reservation'] @property - def quantum_run_stream(self) -> Callable[ - [engine.QuantumRunStreamRequest], - engine.QuantumRunStreamResponse]: + def quantum_run_stream( + self, + ) -> Callable[[engine.QuantumRunStreamRequest], engine.QuantumRunStreamResponse]: r"""Return a callable for the quantum run stream method over gRPC. - @@ -850,9 +844,11 @@ def quantum_run_stream(self) -> Callable[ return self._stubs['quantum_run_stream'] @property - def list_quantum_reservation_grants(self) -> Callable[ - [engine.ListQuantumReservationGrantsRequest], - engine.ListQuantumReservationGrantsResponse]: + def list_quantum_reservation_grants( + self, + ) -> Callable[ + [engine.ListQuantumReservationGrantsRequest], engine.ListQuantumReservationGrantsResponse + ]: r"""Return a callable for the list quantum reservation grants method over gRPC. @@ -877,9 +873,11 @@ def list_quantum_reservation_grants(self) -> Callable[ return self._stubs['list_quantum_reservation_grants'] @property - def reallocate_quantum_reservation_grant(self) -> Callable[ - [engine.ReallocateQuantumReservationGrantRequest], - quantum.QuantumReservationGrant]: + def reallocate_quantum_reservation_grant( + self, + ) -> Callable[ + [engine.ReallocateQuantumReservationGrantRequest], quantum.QuantumReservationGrant + ]: r"""Return a callable for the reallocate quantum reservation grant method over gRPC. @@ -904,9 +902,11 @@ def reallocate_quantum_reservation_grant(self) -> Callable[ return self._stubs['reallocate_quantum_reservation_grant'] @property - def list_quantum_reservation_budgets(self) -> Callable[ - [engine.ListQuantumReservationBudgetsRequest], - engine.ListQuantumReservationBudgetsResponse]: + def list_quantum_reservation_budgets( + self, + ) -> Callable[ + [engine.ListQuantumReservationBudgetsRequest], engine.ListQuantumReservationBudgetsResponse + ]: r"""Return a callable for the list quantum reservation budgets method over gRPC. @@ -931,9 +931,9 @@ def list_quantum_reservation_budgets(self) -> Callable[ return self._stubs['list_quantum_reservation_budgets'] @property - def list_quantum_time_slots(self) -> Callable[ - [engine.ListQuantumTimeSlotsRequest], - engine.ListQuantumTimeSlotsResponse]: + def list_quantum_time_slots( + self, + ) -> Callable[[engine.ListQuantumTimeSlotsRequest], engine.ListQuantumTimeSlotsResponse]: r"""Return a callable for the list quantum time slots method over gRPC. - @@ -959,6 +959,5 @@ def list_quantum_time_slots(self) -> Callable[ def close(self): self.grpc_channel.close() -__all__ = ( - 'QuantumEngineServiceGrpcTransport', -) + +__all__ = ('QuantumEngineServiceGrpcTransport',) diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/grpc_asyncio.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/grpc_asyncio.py index ab3a8d873e0..56b4bfd59a2 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/grpc_asyncio.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/transports/grpc_asyncio.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials from google.auth.transport.grpc import SslCredentials -import grpc # type: ignore +import grpc # type: ignore from grpc.experimental import aio # type: ignore from cirq_google.cloud.quantum_v1alpha1.types import engine @@ -48,13 +48,15 @@ class QuantumEngineServiceGrpcAsyncIOTransport(QuantumEngineServiceTransport): _stubs: Dict[str, Callable] = {} @classmethod - def create_channel(cls, - host: str = 'quantum.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: + def create_channel( + cls, + host: str = 'quantum.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: host (Optional[str]): The host for the channel to use. @@ -85,23 +87,25 @@ def create_channel(cls, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, - **kwargs + **kwargs, ) - def __init__(self, *, - host: str = 'quantum.googleapis.com', - credentials: ga_credentials.Credentials = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[aio.Channel] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id=None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - ) -> None: + def __init__( + self, + *, + host: str = 'quantum.googleapis.com', + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + ) -> None: """Instantiate the transport. Args: @@ -229,9 +233,9 @@ def grpc_channel(self) -> aio.Channel: return self._grpc_channel @property - def create_quantum_program(self) -> Callable[ - [engine.CreateQuantumProgramRequest], - Awaitable[quantum.QuantumProgram]]: + def create_quantum_program( + self, + ) -> Callable[[engine.CreateQuantumProgramRequest], Awaitable[quantum.QuantumProgram]]: r"""Return a callable for the create quantum program method over gRPC. - @@ -255,9 +259,9 @@ def create_quantum_program(self) -> Callable[ return self._stubs['create_quantum_program'] @property - def get_quantum_program(self) -> Callable[ - [engine.GetQuantumProgramRequest], - Awaitable[quantum.QuantumProgram]]: + def get_quantum_program( + self, + ) -> Callable[[engine.GetQuantumProgramRequest], Awaitable[quantum.QuantumProgram]]: r"""Return a callable for the get quantum program method over gRPC. - @@ -281,9 +285,11 @@ def get_quantum_program(self) -> Callable[ return self._stubs['get_quantum_program'] @property - def list_quantum_programs(self) -> Callable[ - [engine.ListQuantumProgramsRequest], - Awaitable[engine.ListQuantumProgramsResponse]]: + def list_quantum_programs( + self, + ) -> Callable[ + [engine.ListQuantumProgramsRequest], Awaitable[engine.ListQuantumProgramsResponse] + ]: r"""Return a callable for the list quantum programs method over gRPC. - @@ -307,9 +313,9 @@ def list_quantum_programs(self) -> Callable[ return self._stubs['list_quantum_programs'] @property - def delete_quantum_program(self) -> Callable[ - [engine.DeleteQuantumProgramRequest], - Awaitable[empty_pb2.Empty]]: + def delete_quantum_program( + self, + ) -> Callable[[engine.DeleteQuantumProgramRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete quantum program method over gRPC. - @@ -333,9 +339,9 @@ def delete_quantum_program(self) -> Callable[ return self._stubs['delete_quantum_program'] @property - def update_quantum_program(self) -> Callable[ - [engine.UpdateQuantumProgramRequest], - Awaitable[quantum.QuantumProgram]]: + def update_quantum_program( + self, + ) -> Callable[[engine.UpdateQuantumProgramRequest], Awaitable[quantum.QuantumProgram]]: r"""Return a callable for the update quantum program method over gRPC. - @@ -359,9 +365,9 @@ def update_quantum_program(self) -> Callable[ return self._stubs['update_quantum_program'] @property - def create_quantum_job(self) -> Callable[ - [engine.CreateQuantumJobRequest], - Awaitable[quantum.QuantumJob]]: + def create_quantum_job( + self, + ) -> Callable[[engine.CreateQuantumJobRequest], Awaitable[quantum.QuantumJob]]: r"""Return a callable for the create quantum job method over gRPC. - @@ -385,9 +391,9 @@ def create_quantum_job(self) -> Callable[ return self._stubs['create_quantum_job'] @property - def get_quantum_job(self) -> Callable[ - [engine.GetQuantumJobRequest], - Awaitable[quantum.QuantumJob]]: + def get_quantum_job( + self, + ) -> Callable[[engine.GetQuantumJobRequest], Awaitable[quantum.QuantumJob]]: r"""Return a callable for the get quantum job method over gRPC. - @@ -411,9 +417,9 @@ def get_quantum_job(self) -> Callable[ return self._stubs['get_quantum_job'] @property - def list_quantum_jobs(self) -> Callable[ - [engine.ListQuantumJobsRequest], - Awaitable[engine.ListQuantumJobsResponse]]: + def list_quantum_jobs( + self, + ) -> Callable[[engine.ListQuantumJobsRequest], Awaitable[engine.ListQuantumJobsResponse]]: r"""Return a callable for the list quantum jobs method over gRPC. - @@ -437,9 +443,9 @@ def list_quantum_jobs(self) -> Callable[ return self._stubs['list_quantum_jobs'] @property - def delete_quantum_job(self) -> Callable[ - [engine.DeleteQuantumJobRequest], - Awaitable[empty_pb2.Empty]]: + def delete_quantum_job( + self, + ) -> Callable[[engine.DeleteQuantumJobRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete quantum job method over gRPC. - @@ -463,9 +469,9 @@ def delete_quantum_job(self) -> Callable[ return self._stubs['delete_quantum_job'] @property - def update_quantum_job(self) -> Callable[ - [engine.UpdateQuantumJobRequest], - Awaitable[quantum.QuantumJob]]: + def update_quantum_job( + self, + ) -> Callable[[engine.UpdateQuantumJobRequest], Awaitable[quantum.QuantumJob]]: r"""Return a callable for the update quantum job method over gRPC. - @@ -489,9 +495,9 @@ def update_quantum_job(self) -> Callable[ return self._stubs['update_quantum_job'] @property - def cancel_quantum_job(self) -> Callable[ - [engine.CancelQuantumJobRequest], - Awaitable[empty_pb2.Empty]]: + def cancel_quantum_job( + self, + ) -> Callable[[engine.CancelQuantumJobRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the cancel quantum job method over gRPC. - @@ -515,9 +521,11 @@ def cancel_quantum_job(self) -> Callable[ return self._stubs['cancel_quantum_job'] @property - def list_quantum_job_events(self) -> Callable[ - [engine.ListQuantumJobEventsRequest], - Awaitable[engine.ListQuantumJobEventsResponse]]: + def list_quantum_job_events( + self, + ) -> Callable[ + [engine.ListQuantumJobEventsRequest], Awaitable[engine.ListQuantumJobEventsResponse] + ]: r"""Return a callable for the list quantum job events method over gRPC. - @@ -541,9 +549,9 @@ def list_quantum_job_events(self) -> Callable[ return self._stubs['list_quantum_job_events'] @property - def get_quantum_result(self) -> Callable[ - [engine.GetQuantumResultRequest], - Awaitable[quantum.QuantumResult]]: + def get_quantum_result( + self, + ) -> Callable[[engine.GetQuantumResultRequest], Awaitable[quantum.QuantumResult]]: r"""Return a callable for the get quantum result method over gRPC. - @@ -567,9 +575,11 @@ def get_quantum_result(self) -> Callable[ return self._stubs['get_quantum_result'] @property - def list_quantum_processors(self) -> Callable[ - [engine.ListQuantumProcessorsRequest], - Awaitable[engine.ListQuantumProcessorsResponse]]: + def list_quantum_processors( + self, + ) -> Callable[ + [engine.ListQuantumProcessorsRequest], Awaitable[engine.ListQuantumProcessorsResponse] + ]: r"""Return a callable for the list quantum processors method over gRPC. - @@ -593,9 +603,9 @@ def list_quantum_processors(self) -> Callable[ return self._stubs['list_quantum_processors'] @property - def get_quantum_processor(self) -> Callable[ - [engine.GetQuantumProcessorRequest], - Awaitable[quantum.QuantumProcessor]]: + def get_quantum_processor( + self, + ) -> Callable[[engine.GetQuantumProcessorRequest], Awaitable[quantum.QuantumProcessor]]: r"""Return a callable for the get quantum processor method over gRPC. - @@ -619,9 +629,11 @@ def get_quantum_processor(self) -> Callable[ return self._stubs['get_quantum_processor'] @property - def list_quantum_calibrations(self) -> Callable[ - [engine.ListQuantumCalibrationsRequest], - Awaitable[engine.ListQuantumCalibrationsResponse]]: + def list_quantum_calibrations( + self, + ) -> Callable[ + [engine.ListQuantumCalibrationsRequest], Awaitable[engine.ListQuantumCalibrationsResponse] + ]: r"""Return a callable for the list quantum calibrations method over gRPC. - @@ -645,9 +657,9 @@ def list_quantum_calibrations(self) -> Callable[ return self._stubs['list_quantum_calibrations'] @property - def get_quantum_calibration(self) -> Callable[ - [engine.GetQuantumCalibrationRequest], - Awaitable[quantum.QuantumCalibration]]: + def get_quantum_calibration( + self, + ) -> Callable[[engine.GetQuantumCalibrationRequest], Awaitable[quantum.QuantumCalibration]]: r"""Return a callable for the get quantum calibration method over gRPC. - @@ -671,9 +683,9 @@ def get_quantum_calibration(self) -> Callable[ return self._stubs['get_quantum_calibration'] @property - def create_quantum_reservation(self) -> Callable[ - [engine.CreateQuantumReservationRequest], - Awaitable[quantum.QuantumReservation]]: + def create_quantum_reservation( + self, + ) -> Callable[[engine.CreateQuantumReservationRequest], Awaitable[quantum.QuantumReservation]]: r"""Return a callable for the create quantum reservation method over gRPC. - @@ -697,9 +709,9 @@ def create_quantum_reservation(self) -> Callable[ return self._stubs['create_quantum_reservation'] @property - def cancel_quantum_reservation(self) -> Callable[ - [engine.CancelQuantumReservationRequest], - Awaitable[quantum.QuantumReservation]]: + def cancel_quantum_reservation( + self, + ) -> Callable[[engine.CancelQuantumReservationRequest], Awaitable[quantum.QuantumReservation]]: r"""Return a callable for the cancel quantum reservation method over gRPC. - @@ -723,9 +735,9 @@ def cancel_quantum_reservation(self) -> Callable[ return self._stubs['cancel_quantum_reservation'] @property - def delete_quantum_reservation(self) -> Callable[ - [engine.DeleteQuantumReservationRequest], - Awaitable[empty_pb2.Empty]]: + def delete_quantum_reservation( + self, + ) -> Callable[[engine.DeleteQuantumReservationRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete quantum reservation method over gRPC. - @@ -749,9 +761,9 @@ def delete_quantum_reservation(self) -> Callable[ return self._stubs['delete_quantum_reservation'] @property - def get_quantum_reservation(self) -> Callable[ - [engine.GetQuantumReservationRequest], - Awaitable[quantum.QuantumReservation]]: + def get_quantum_reservation( + self, + ) -> Callable[[engine.GetQuantumReservationRequest], Awaitable[quantum.QuantumReservation]]: r"""Return a callable for the get quantum reservation method over gRPC. - @@ -775,9 +787,11 @@ def get_quantum_reservation(self) -> Callable[ return self._stubs['get_quantum_reservation'] @property - def list_quantum_reservations(self) -> Callable[ - [engine.ListQuantumReservationsRequest], - Awaitable[engine.ListQuantumReservationsResponse]]: + def list_quantum_reservations( + self, + ) -> Callable[ + [engine.ListQuantumReservationsRequest], Awaitable[engine.ListQuantumReservationsResponse] + ]: r"""Return a callable for the list quantum reservations method over gRPC. - @@ -801,9 +815,9 @@ def list_quantum_reservations(self) -> Callable[ return self._stubs['list_quantum_reservations'] @property - def update_quantum_reservation(self) -> Callable[ - [engine.UpdateQuantumReservationRequest], - Awaitable[quantum.QuantumReservation]]: + def update_quantum_reservation( + self, + ) -> Callable[[engine.UpdateQuantumReservationRequest], Awaitable[quantum.QuantumReservation]]: r"""Return a callable for the update quantum reservation method over gRPC. - @@ -827,9 +841,9 @@ def update_quantum_reservation(self) -> Callable[ return self._stubs['update_quantum_reservation'] @property - def quantum_run_stream(self) -> Callable[ - [engine.QuantumRunStreamRequest], - Awaitable[engine.QuantumRunStreamResponse]]: + def quantum_run_stream( + self, + ) -> Callable[[engine.QuantumRunStreamRequest], Awaitable[engine.QuantumRunStreamResponse]]: r"""Return a callable for the quantum run stream method over gRPC. - @@ -853,9 +867,12 @@ def quantum_run_stream(self) -> Callable[ return self._stubs['quantum_run_stream'] @property - def list_quantum_reservation_grants(self) -> Callable[ - [engine.ListQuantumReservationGrantsRequest], - Awaitable[engine.ListQuantumReservationGrantsResponse]]: + def list_quantum_reservation_grants( + self, + ) -> Callable[ + [engine.ListQuantumReservationGrantsRequest], + Awaitable[engine.ListQuantumReservationGrantsResponse], + ]: r"""Return a callable for the list quantum reservation grants method over gRPC. @@ -880,9 +897,12 @@ def list_quantum_reservation_grants(self) -> Callable[ return self._stubs['list_quantum_reservation_grants'] @property - def reallocate_quantum_reservation_grant(self) -> Callable[ - [engine.ReallocateQuantumReservationGrantRequest], - Awaitable[quantum.QuantumReservationGrant]]: + def reallocate_quantum_reservation_grant( + self, + ) -> Callable[ + [engine.ReallocateQuantumReservationGrantRequest], + Awaitable[quantum.QuantumReservationGrant], + ]: r"""Return a callable for the reallocate quantum reservation grant method over gRPC. @@ -907,9 +927,12 @@ def reallocate_quantum_reservation_grant(self) -> Callable[ return self._stubs['reallocate_quantum_reservation_grant'] @property - def list_quantum_reservation_budgets(self) -> Callable[ - [engine.ListQuantumReservationBudgetsRequest], - Awaitable[engine.ListQuantumReservationBudgetsResponse]]: + def list_quantum_reservation_budgets( + self, + ) -> Callable[ + [engine.ListQuantumReservationBudgetsRequest], + Awaitable[engine.ListQuantumReservationBudgetsResponse], + ]: r"""Return a callable for the list quantum reservation budgets method over gRPC. @@ -934,9 +957,11 @@ def list_quantum_reservation_budgets(self) -> Callable[ return self._stubs['list_quantum_reservation_budgets'] @property - def list_quantum_time_slots(self) -> Callable[ - [engine.ListQuantumTimeSlotsRequest], - Awaitable[engine.ListQuantumTimeSlotsResponse]]: + def list_quantum_time_slots( + self, + ) -> Callable[ + [engine.ListQuantumTimeSlotsRequest], Awaitable[engine.ListQuantumTimeSlotsResponse] + ]: r"""Return a callable for the list quantum time slots method over gRPC. - @@ -963,6 +988,4 @@ def close(self): return self.grpc_channel.close() -__all__ = ( - 'QuantumEngineServiceGrpcAsyncIOTransport', -) +__all__ = ('QuantumEngineServiceGrpcAsyncIOTransport',) diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/types/engine.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/types/engine.py index 188909e526e..8eea162bc5e 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/types/engine.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/types/engine.py @@ -79,19 +79,9 @@ class CreateQuantumJobRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - quantum_job = proto.Field( - proto.MESSAGE, - number=2, - message=quantum.QuantumJob, - ) - overwrite_existing_run_context = proto.Field( - proto.BOOL, - number=3, - ) + parent = proto.Field(proto.STRING, number=1) + quantum_job = proto.Field(proto.MESSAGE, number=2, message=quantum.QuantumJob) + overwrite_existing_run_context = proto.Field(proto.BOOL, number=3) class GetQuantumJobRequest(proto.Message): @@ -104,14 +94,8 @@ class GetQuantumJobRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - return_run_context = proto.Field( - proto.BOOL, - number=2, - ) + name = proto.Field(proto.STRING, number=1) + return_run_context = proto.Field(proto.BOOL, number=2) class ListQuantumJobsRequest(proto.Message): @@ -128,22 +112,10 @@ class ListQuantumJobsRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) + filter = proto.Field(proto.STRING, number=4) class ListQuantumJobsResponse(proto.Message): @@ -160,15 +132,8 @@ class ListQuantumJobsResponse(proto.Message): def raw_page(self): return self - jobs = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumJob, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + jobs = proto.RepeatedField(proto.MESSAGE, number=1, message=quantum.QuantumJob) + next_page_token = proto.Field(proto.STRING, number=2) class DeleteQuantumJobRequest(proto.Message): @@ -179,10 +144,7 @@ class DeleteQuantumJobRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1) class UpdateQuantumJobRequest(proto.Message): @@ -197,20 +159,9 @@ class UpdateQuantumJobRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - quantum_job = proto.Field( - proto.MESSAGE, - number=2, - message=quantum.QuantumJob, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) + name = proto.Field(proto.STRING, number=1) + quantum_job = proto.Field(proto.MESSAGE, number=2, message=quantum.QuantumJob) + update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask) class CancelQuantumJobRequest(proto.Message): @@ -221,10 +172,7 @@ class CancelQuantumJobRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1) class ListQuantumJobEventsRequest(proto.Message): @@ -239,18 +187,9 @@ class ListQuantumJobEventsRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) + parent = proto.Field(proto.STRING, number=1) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) class ListQuantumJobEventsResponse(proto.Message): @@ -267,15 +206,8 @@ class ListQuantumJobEventsResponse(proto.Message): def raw_page(self): return self - events = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumJobEvent, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + events = proto.RepeatedField(proto.MESSAGE, number=1, message=quantum.QuantumJobEvent) + next_page_token = proto.Field(proto.STRING, number=2) class GetQuantumResultRequest(proto.Message): @@ -286,10 +218,7 @@ class GetQuantumResultRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) + parent = proto.Field(proto.STRING, number=1) class CreateQuantumProgramRequest(proto.Message): @@ -304,19 +233,9 @@ class CreateQuantumProgramRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - quantum_program = proto.Field( - proto.MESSAGE, - number=2, - message=quantum.QuantumProgram, - ) - overwrite_existing_source_code = proto.Field( - proto.BOOL, - number=3, - ) + parent = proto.Field(proto.STRING, number=1) + quantum_program = proto.Field(proto.MESSAGE, number=2, message=quantum.QuantumProgram) + overwrite_existing_source_code = proto.Field(proto.BOOL, number=3) class GetQuantumProgramRequest(proto.Message): @@ -329,14 +248,8 @@ class GetQuantumProgramRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - return_code = proto.Field( - proto.BOOL, - number=2, - ) + name = proto.Field(proto.STRING, number=1) + return_code = proto.Field(proto.BOOL, number=2) class ListQuantumProgramsRequest(proto.Message): @@ -353,22 +266,10 @@ class ListQuantumProgramsRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) + filter = proto.Field(proto.STRING, number=4) class ListQuantumProgramsResponse(proto.Message): @@ -385,15 +286,8 @@ class ListQuantumProgramsResponse(proto.Message): def raw_page(self): return self - programs = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumProgram, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + programs = proto.RepeatedField(proto.MESSAGE, number=1, message=quantum.QuantumProgram) + next_page_token = proto.Field(proto.STRING, number=2) class DeleteQuantumProgramRequest(proto.Message): @@ -406,14 +300,8 @@ class DeleteQuantumProgramRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - delete_jobs = proto.Field( - proto.BOOL, - number=2, - ) + name = proto.Field(proto.STRING, number=1) + delete_jobs = proto.Field(proto.BOOL, number=2) class UpdateQuantumProgramRequest(proto.Message): @@ -428,20 +316,9 @@ class UpdateQuantumProgramRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - quantum_program = proto.Field( - proto.MESSAGE, - number=2, - message=quantum.QuantumProgram, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) + name = proto.Field(proto.STRING, number=1) + quantum_program = proto.Field(proto.MESSAGE, number=2, message=quantum.QuantumProgram) + update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask) class ListQuantumProcessorsRequest(proto.Message): @@ -458,22 +335,10 @@ class ListQuantumProcessorsRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) + filter = proto.Field(proto.STRING, number=4) class ListQuantumProcessorsResponse(proto.Message): @@ -490,15 +355,8 @@ class ListQuantumProcessorsResponse(proto.Message): def raw_page(self): return self - processors = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumProcessor, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + processors = proto.RepeatedField(proto.MESSAGE, number=1, message=quantum.QuantumProcessor) + next_page_token = proto.Field(proto.STRING, number=2) class GetQuantumProcessorRequest(proto.Message): @@ -509,10 +367,7 @@ class GetQuantumProcessorRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1) class ListQuantumCalibrationsRequest(proto.Message): @@ -530,33 +385,19 @@ class ListQuantumCalibrationsRequest(proto.Message): filter (str): - """ + class QuantumCalibrationView(proto.Enum): r"""-""" + QUANTUM_CALIBRATION_VIEW_UNSPECIFIED = 0 BASIC = 1 FULL = 2 - parent = proto.Field( - proto.STRING, - number=1, - ) - view = proto.Field( - proto.ENUM, - number=5, - enum=QuantumCalibrationView, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1) + view = proto.Field(proto.ENUM, number=5, enum=QuantumCalibrationView) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) + filter = proto.Field(proto.STRING, number=4) class ListQuantumCalibrationsResponse(proto.Message): @@ -573,15 +414,8 @@ class ListQuantumCalibrationsResponse(proto.Message): def raw_page(self): return self - calibrations = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumCalibration, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + calibrations = proto.RepeatedField(proto.MESSAGE, number=1, message=quantum.QuantumCalibration) + next_page_token = proto.Field(proto.STRING, number=2) class GetQuantumCalibrationRequest(proto.Message): @@ -592,10 +426,7 @@ class GetQuantumCalibrationRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1) class CreateQuantumReservationRequest(proto.Message): @@ -608,15 +439,8 @@ class CreateQuantumReservationRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - quantum_reservation = proto.Field( - proto.MESSAGE, - number=2, - message=quantum.QuantumReservation, - ) + parent = proto.Field(proto.STRING, number=1) + quantum_reservation = proto.Field(proto.MESSAGE, number=2, message=quantum.QuantumReservation) class CancelQuantumReservationRequest(proto.Message): @@ -627,10 +451,7 @@ class CancelQuantumReservationRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1) class DeleteQuantumReservationRequest(proto.Message): @@ -641,10 +462,7 @@ class DeleteQuantumReservationRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1) class GetQuantumReservationRequest(proto.Message): @@ -655,10 +473,7 @@ class GetQuantumReservationRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) + name = proto.Field(proto.STRING, number=1) class ListQuantumReservationsRequest(proto.Message): @@ -675,22 +490,10 @@ class ListQuantumReservationsRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) + filter = proto.Field(proto.STRING, number=4) class ListQuantumReservationsResponse(proto.Message): @@ -707,15 +510,8 @@ class ListQuantumReservationsResponse(proto.Message): def raw_page(self): return self - reservations = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumReservation, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + reservations = proto.RepeatedField(proto.MESSAGE, number=1, message=quantum.QuantumReservation) + next_page_token = proto.Field(proto.STRING, number=2) class UpdateQuantumReservationRequest(proto.Message): @@ -730,20 +526,9 @@ class UpdateQuantumReservationRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - quantum_reservation = proto.Field( - proto.MESSAGE, - number=2, - message=quantum.QuantumReservation, - ) - update_mask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) + name = proto.Field(proto.STRING, number=1) + quantum_reservation = proto.Field(proto.MESSAGE, number=2, message=quantum.QuantumReservation) + update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask) class QuantumRunStreamRequest(proto.Message): @@ -775,31 +560,16 @@ class QuantumRunStreamRequest(proto.Message): This field is a member of `oneof`_ ``request``. """ - message_id = proto.Field( - proto.STRING, - number=1, - ) - parent = proto.Field( - proto.STRING, - number=2, - ) + message_id = proto.Field(proto.STRING, number=1) + parent = proto.Field(proto.STRING, number=2) create_quantum_program_and_job = proto.Field( - proto.MESSAGE, - number=3, - oneof='request', - message='CreateQuantumProgramAndJobRequest', + proto.MESSAGE, number=3, oneof='request', message='CreateQuantumProgramAndJobRequest' ) create_quantum_job = proto.Field( - proto.MESSAGE, - number=4, - oneof='request', - message='CreateQuantumJobRequest', + proto.MESSAGE, number=4, oneof='request', message='CreateQuantumJobRequest' ) get_quantum_result = proto.Field( - proto.MESSAGE, - number=5, - oneof='request', - message='GetQuantumResultRequest', + proto.MESSAGE, number=5, oneof='request', message='GetQuantumResultRequest' ) @@ -815,20 +585,9 @@ class CreateQuantumProgramAndJobRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - quantum_program = proto.Field( - proto.MESSAGE, - number=2, - message=quantum.QuantumProgram, - ) - quantum_job = proto.Field( - proto.MESSAGE, - number=3, - message=quantum.QuantumJob, - ) + parent = proto.Field(proto.STRING, number=1) + quantum_program = proto.Field(proto.MESSAGE, number=2, message=quantum.QuantumProgram) + quantum_job = proto.Field(proto.MESSAGE, number=3, message=quantum.QuantumJob) class QuantumRunStreamResponse(proto.Message): @@ -858,28 +617,10 @@ class QuantumRunStreamResponse(proto.Message): This field is a member of `oneof`_ ``response``. """ - message_id = proto.Field( - proto.STRING, - number=1, - ) - error = proto.Field( - proto.MESSAGE, - number=2, - oneof='response', - message='StreamError', - ) - job = proto.Field( - proto.MESSAGE, - number=3, - oneof='response', - message=quantum.QuantumJob, - ) - result = proto.Field( - proto.MESSAGE, - number=4, - oneof='response', - message=quantum.QuantumResult, - ) + message_id = proto.Field(proto.STRING, number=1) + error = proto.Field(proto.MESSAGE, number=2, oneof='response', message='StreamError') + job = proto.Field(proto.MESSAGE, number=3, oneof='response', message=quantum.QuantumJob) + result = proto.Field(proto.MESSAGE, number=4, oneof='response', message=quantum.QuantumResult) class StreamError(proto.Message): @@ -891,8 +632,10 @@ class StreamError(proto.Message): message (str): - """ + class Code(proto.Enum): r"""-""" + CODE_UNSPECIFIED = 0 INTERNAL = 1 INVALID_ARGUMENT = 2 @@ -904,15 +647,8 @@ class Code(proto.Enum): PROCESSOR_DOES_NOT_EXIST = 8 INVALID_PROCESSOR_FOR_JOB = 9 - code = proto.Field( - proto.ENUM, - number=1, - enum=Code, - ) - message = proto.Field( - proto.STRING, - number=2, - ) + code = proto.Field(proto.ENUM, number=1, enum=Code) + message = proto.Field(proto.STRING, number=2) class ListQuantumReservationGrantsRequest(proto.Message): @@ -929,22 +665,10 @@ class ListQuantumReservationGrantsRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) + filter = proto.Field(proto.STRING, number=4) class ListQuantumReservationGrantsResponse(proto.Message): @@ -962,14 +686,9 @@ def raw_page(self): return self reservation_grants = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumReservationGrant, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, + proto.MESSAGE, number=1, message=quantum.QuantumReservationGrant ) + next_page_token = proto.Field(proto.STRING, number=2) class ReallocateQuantumReservationGrantRequest(proto.Message): @@ -986,23 +705,10 @@ class ReallocateQuantumReservationGrantRequest(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - source_project_id = proto.Field( - proto.STRING, - number=2, - ) - target_project_id = proto.Field( - proto.STRING, - number=3, - ) - duration = proto.Field( - proto.MESSAGE, - number=4, - message=duration_pb2.Duration, - ) + name = proto.Field(proto.STRING, number=1) + source_project_id = proto.Field(proto.STRING, number=2) + target_project_id = proto.Field(proto.STRING, number=3) + duration = proto.Field(proto.MESSAGE, number=4, message=duration_pb2.Duration) class ListQuantumReservationBudgetsRequest(proto.Message): @@ -1019,22 +725,10 @@ class ListQuantumReservationBudgetsRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) + filter = proto.Field(proto.STRING, number=4) class ListQuantumReservationBudgetsResponse(proto.Message): @@ -1052,14 +746,9 @@ def raw_page(self): return self reservation_budgets = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumReservationBudget, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, + proto.MESSAGE, number=1, message=quantum.QuantumReservationBudget ) + next_page_token = proto.Field(proto.STRING, number=2) class ListQuantumTimeSlotsRequest(proto.Message): @@ -1076,22 +765,10 @@ class ListQuantumTimeSlotsRequest(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - page_size = proto.Field( - proto.INT32, - number=2, - ) - page_token = proto.Field( - proto.STRING, - number=3, - ) - filter = proto.Field( - proto.STRING, - number=4, - ) + parent = proto.Field(proto.STRING, number=1) + page_size = proto.Field(proto.INT32, number=2) + page_token = proto.Field(proto.STRING, number=3) + filter = proto.Field(proto.STRING, number=4) class ListQuantumTimeSlotsResponse(proto.Message): @@ -1108,15 +785,8 @@ class ListQuantumTimeSlotsResponse(proto.Message): def raw_page(self): return self - time_slots = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=quantum.QuantumTimeSlot, - ) - next_page_token = proto.Field( - proto.STRING, - number=2, - ) + time_slots = proto.RepeatedField(proto.MESSAGE, number=1, message=quantum.QuantumTimeSlot) + next_page_token = proto.Field(proto.STRING, number=2) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/types/quantum.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/types/quantum.py index 040aaab7f32..9a7962c206a 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/types/quantum.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/types/quantum.py @@ -78,50 +78,19 @@ class QuantumProgram(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - create_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - label_fingerprint = proto.Field( - proto.STRING, - number=5, - ) - description = proto.Field( - proto.STRING, - number=6, - ) + name = proto.Field(proto.STRING, number=1) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp) + labels = proto.MapField(proto.STRING, proto.STRING, number=4) + label_fingerprint = proto.Field(proto.STRING, number=5) + description = proto.Field(proto.STRING, number=6) gcs_code_location = proto.Field( - proto.MESSAGE, - number=7, - oneof='code_location', - message='GcsLocation', + proto.MESSAGE, number=7, oneof='code_location', message='GcsLocation' ) code_inline_data = proto.Field( - proto.MESSAGE, - number=9, - oneof='code_location', - message='InlineData', - ) - code = proto.Field( - proto.MESSAGE, - number=8, - message=any_pb2.Any, + proto.MESSAGE, number=9, oneof='code_location', message='InlineData' ) + code = proto.Field(proto.MESSAGE, number=8, message=any_pb2.Any) class QuantumJob(proto.Message): @@ -165,65 +134,22 @@ class QuantumJob(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - create_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - update_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - labels = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - label_fingerprint = proto.Field( - proto.STRING, - number=5, - ) - description = proto.Field( - proto.STRING, - number=6, - ) - scheduling_config = proto.Field( - proto.MESSAGE, - number=7, - message='SchedulingConfig', - ) - output_config = proto.Field( - proto.MESSAGE, - number=8, - message='OutputConfig', - ) - execution_status = proto.Field( - proto.MESSAGE, - number=9, - message='ExecutionStatus', - ) + name = proto.Field(proto.STRING, number=1) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp) + labels = proto.MapField(proto.STRING, proto.STRING, number=4) + label_fingerprint = proto.Field(proto.STRING, number=5) + description = proto.Field(proto.STRING, number=6) + scheduling_config = proto.Field(proto.MESSAGE, number=7, message='SchedulingConfig') + output_config = proto.Field(proto.MESSAGE, number=8, message='OutputConfig') + execution_status = proto.Field(proto.MESSAGE, number=9, message='ExecutionStatus') gcs_run_context_location = proto.Field( - proto.MESSAGE, - number=10, - oneof='run_context_location', - message='GcsLocation', + proto.MESSAGE, number=10, oneof='run_context_location', message='GcsLocation' ) run_context_inline_data = proto.Field( - proto.MESSAGE, - number=12, - oneof='run_context_location', - message='InlineData', - ) - run_context = proto.Field( - proto.MESSAGE, - number=11, - message=any_pb2.Any, + proto.MESSAGE, number=12, oneof='run_context_location', message='InlineData' ) + run_context = proto.Field(proto.MESSAGE, number=11, message=any_pb2.Any) class DeviceConfigKey(proto.Message): @@ -235,14 +161,8 @@ class DeviceConfigKey(proto.Message): - """ - run_name = proto.Field( - proto.STRING, - number=1, - ) - config_alias = proto.Field( - proto.STRING, - number=2, - ) + run_name = proto.Field(proto.STRING, number=1) + config_alias = proto.Field(proto.STRING, number=2) class SchedulingConfig(proto.Message): @@ -269,33 +189,13 @@ class ProcessorSelector(proto.Message): - """ - processor_names = proto.RepeatedField( - proto.STRING, - number=1, - ) - processor = proto.Field( - proto.STRING, - number=2, - ) - device_config_key = proto.Field( - proto.MESSAGE, - number=3, - message=DeviceConfigKey - ) - - target_route = proto.Field( - proto.STRING, - number=1, - ) - processor_selector = proto.Field( - proto.MESSAGE, - number=3, - message=ProcessorSelector, - ) - priority = proto.Field( - proto.INT32, - number=2, - ) + processor_names = proto.RepeatedField(proto.STRING, number=1) + processor = proto.Field(proto.STRING, number=2) + device_config_key = proto.Field(proto.MESSAGE, number=3, message=DeviceConfigKey) + + target_route = proto.Field(proto.STRING, number=1) + processor_selector = proto.Field(proto.MESSAGE, number=3, message=ProcessorSelector) + priority = proto.Field(proto.INT32, number=2) class ExecutionStatus(proto.Message): @@ -313,8 +213,10 @@ class ExecutionStatus(proto.Message): timing (google.cloud.quantum_v1alpha1.types.ExecutionStatus.Timing): - """ + class State(proto.Enum): r"""-""" + STATE_UNSPECIFIED = 0 READY = 1 RUNNING = 2 @@ -332,8 +234,10 @@ class Failure(proto.Message): error_message (str): - """ + class Code(proto.Enum): r"""-""" + CODE_UNSPECIFIED = 0 SYSTEM_ERROR = 1 INVALID_PROGRAM = 2 @@ -349,15 +253,8 @@ class Code(proto.Enum): SCHEDULING_EXPIRED = 14 FAILED_PRECONDITION = 15 - error_code = proto.Field( - proto.ENUM, - number=1, - enum='ExecutionStatus.Failure.Code', - ) - error_message = proto.Field( - proto.STRING, - number=2, - ) + error_code = proto.Field(proto.ENUM, number=1, enum='ExecutionStatus.Failure.Code') + error_message = proto.Field(proto.STRING, number=2) class Timing(proto.Message): r"""- @@ -369,40 +266,14 @@ class Timing(proto.Message): - """ - started_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - completed_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - state = proto.Field( - proto.ENUM, - number=1, - enum=State, - ) - processor_name = proto.Field( - proto.STRING, - number=3, - ) - calibration_name = proto.Field( - proto.STRING, - number=4, - ) - failure = proto.Field( - proto.MESSAGE, - number=5, - message=Failure, - ) - timing = proto.Field( - proto.MESSAGE, - number=6, - message=Timing, - ) + started_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp) + completed_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp) + + state = proto.Field(proto.ENUM, number=1, enum=State) + processor_name = proto.Field(proto.STRING, number=3) + calibration_name = proto.Field(proto.STRING, number=4) + failure = proto.Field(proto.MESSAGE, number=5, message=Failure) + timing = proto.Field(proto.MESSAGE, number=6, message=Timing) class OutputConfig(proto.Message): @@ -420,15 +291,9 @@ class OutputConfig(proto.Message): """ gcs_results_location = proto.Field( - proto.MESSAGE, - number=1, - oneof='output_destination', - message='GcsLocation', - ) - overwrite_existing = proto.Field( - proto.BOOL, - number=2, + proto.MESSAGE, number=1, oneof='output_destination', message='GcsLocation' ) + overwrite_existing = proto.Field(proto.BOOL, number=2) class GcsLocation(proto.Message): @@ -441,14 +306,8 @@ class GcsLocation(proto.Message): - """ - uri = proto.Field( - proto.STRING, - number=1, - ) - type_url = proto.Field( - proto.STRING, - number=2, - ) + uri = proto.Field(proto.STRING, number=1) + type_url = proto.Field(proto.STRING, number=2) class InlineData(proto.Message): @@ -459,10 +318,7 @@ class InlineData(proto.Message): - """ - type_url = proto.Field( - proto.STRING, - number=1, - ) + type_url = proto.Field(proto.STRING, number=1) class QuantumJobEvent(proto.Message): @@ -477,21 +333,9 @@ class QuantumJobEvent(proto.Message): - """ - event_time = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - job = proto.Field( - proto.MESSAGE, - number=2, - message='QuantumJob', - ) - modified_field_mask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) + event_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp) + job = proto.Field(proto.MESSAGE, number=2, message='QuantumJob') + modified_field_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask) class QuantumResult(proto.Message): @@ -504,15 +348,8 @@ class QuantumResult(proto.Message): - """ - parent = proto.Field( - proto.STRING, - number=1, - ) - result = proto.Field( - proto.MESSAGE, - number=2, - message=any_pb2.Any, - ) + parent = proto.Field(proto.STRING, number=1) + result = proto.Field(proto.MESSAGE, number=2, message=any_pb2.Any) class QuantumProcessor(proto.Message): @@ -542,8 +379,10 @@ class QuantumProcessor(proto.Message): activity_stats (google.cloud.quantum_v1alpha1.types.QuantumProcessor.ActivityStats): - """ + class Health(proto.Enum): r"""-""" + HEALTH_UNSPECIFIED = 0 OK = 1 DOWN = 2 @@ -560,67 +399,20 @@ class ActivityStats(proto.Message): - """ - active_users_count = proto.Field( - proto.INT64, - number=1, - ) - active_jobs_count = proto.Field( - proto.INT64, - number=2, - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - health = proto.Field( - proto.ENUM, - number=3, - enum=Health, - ) - expected_down_time = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - expected_recovery_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - supported_languages = proto.RepeatedField( - proto.STRING, - number=5, - ) - device_spec = proto.Field( - proto.MESSAGE, - number=6, - message=any_pb2.Any, - ) - schedule_horizon = proto.Field( - proto.MESSAGE, - number=8, - message=duration_pb2.Duration, - ) - schedule_frozen_period = proto.Field( - proto.MESSAGE, - number=9, - message=duration_pb2.Duration, - ) - current_calibration = proto.Field( - proto.STRING, - number=10, - ) - active_time_slot = proto.Field( - proto.MESSAGE, - number=11, - message='QuantumTimeSlot', - ) - activity_stats = proto.Field( - proto.MESSAGE, - number=12, - message=ActivityStats, - ) + active_users_count = proto.Field(proto.INT64, number=1) + active_jobs_count = proto.Field(proto.INT64, number=2) + + name = proto.Field(proto.STRING, number=1) + health = proto.Field(proto.ENUM, number=3, enum=Health) + expected_down_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp) + expected_recovery_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp) + supported_languages = proto.RepeatedField(proto.STRING, number=5) + device_spec = proto.Field(proto.MESSAGE, number=6, message=any_pb2.Any) + schedule_horizon = proto.Field(proto.MESSAGE, number=8, message=duration_pb2.Duration) + schedule_frozen_period = proto.Field(proto.MESSAGE, number=9, message=duration_pb2.Duration) + current_calibration = proto.Field(proto.STRING, number=10) + active_time_slot = proto.Field(proto.MESSAGE, number=11, message='QuantumTimeSlot') + activity_stats = proto.Field(proto.MESSAGE, number=12, message=ActivityStats) class QuantumCalibration(proto.Message): @@ -635,20 +427,9 @@ class QuantumCalibration(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - data = proto.Field( - proto.MESSAGE, - number=3, - message=any_pb2.Any, - ) + name = proto.Field(proto.STRING, number=1) + timestamp = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp) + data = proto.Field(proto.MESSAGE, number=3, message=any_pb2.Any) class QuantumReservationGrant(proto.Message): @@ -683,54 +464,17 @@ class Budget(proto.Message): - """ - project_id = proto.Field( - proto.STRING, - number=1, - ) - granted_duration = proto.Field( - proto.MESSAGE, - number=2, - message=duration_pb2.Duration, - ) - available_duration = proto.Field( - proto.MESSAGE, - number=3, - message=duration_pb2.Duration, - ) - - name = proto.Field( - proto.STRING, - number=1, - ) - processor_names = proto.RepeatedField( - proto.STRING, - number=2, - ) - effective_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - expire_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - granted_duration = proto.Field( - proto.MESSAGE, - number=5, - message=duration_pb2.Duration, - ) - available_duration = proto.Field( - proto.MESSAGE, - number=6, - message=duration_pb2.Duration, - ) - budgets = proto.RepeatedField( - proto.MESSAGE, - number=7, - message=Budget, - ) + project_id = proto.Field(proto.STRING, number=1) + granted_duration = proto.Field(proto.MESSAGE, number=2, message=duration_pb2.Duration) + available_duration = proto.Field(proto.MESSAGE, number=3, message=duration_pb2.Duration) + + name = proto.Field(proto.STRING, number=1) + processor_names = proto.RepeatedField(proto.STRING, number=2) + effective_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp) + expire_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp) + granted_duration = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration) + available_duration = proto.Field(proto.MESSAGE, number=6, message=duration_pb2.Duration) + budgets = proto.RepeatedField(proto.MESSAGE, number=7, message=Budget) class QuantumReservationBudget(proto.Message): @@ -751,34 +495,12 @@ class QuantumReservationBudget(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - processor_names = proto.RepeatedField( - proto.STRING, - number=2, - ) - effective_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - expire_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - granted_duration = proto.Field( - proto.MESSAGE, - number=5, - message=duration_pb2.Duration, - ) - available_duration = proto.Field( - proto.MESSAGE, - number=6, - message=duration_pb2.Duration, - ) + name = proto.Field(proto.STRING, number=1) + processor_names = proto.RepeatedField(proto.STRING, number=2) + effective_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp) + expire_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp) + granted_duration = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration) + available_duration = proto.Field(proto.MESSAGE, number=6, message=duration_pb2.Duration) class QuantumTimeSlot(proto.Message): @@ -809,8 +531,10 @@ class QuantumTimeSlot(proto.Message): This field is a member of `oneof`_ ``type_config``. """ + class TimeSlotType(proto.Enum): r"""-""" + TIME_SLOT_TYPE_UNSPECIFIED = 0 MAINTENANCE = 1 OPEN_SWIM = 2 @@ -829,18 +553,9 @@ class ReservationConfig(proto.Message): - """ - reservation = proto.Field( - proto.STRING, - number=3, - ) - project_id = proto.Field( - proto.STRING, - number=1, - ) - whitelisted_users = proto.RepeatedField( - proto.STRING, - number=2, - ) + reservation = proto.Field(proto.STRING, number=3) + project_id = proto.Field(proto.STRING, number=1) + whitelisted_users = proto.RepeatedField(proto.STRING, number=2) class MaintenanceConfig(proto.Message): r"""- @@ -852,45 +567,18 @@ class MaintenanceConfig(proto.Message): - """ - title = proto.Field( - proto.STRING, - number=1, - ) - description = proto.Field( - proto.STRING, - number=2, - ) - - processor_name = proto.Field( - proto.STRING, - number=1, - ) - start_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - time_slot_type = proto.Field( - proto.ENUM, - number=5, - enum=TimeSlotType, - ) + title = proto.Field(proto.STRING, number=1) + description = proto.Field(proto.STRING, number=2) + + processor_name = proto.Field(proto.STRING, number=1) + start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp) + end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp) + time_slot_type = proto.Field(proto.ENUM, number=5, enum=TimeSlotType) reservation_config = proto.Field( - proto.MESSAGE, - number=6, - oneof='type_config', - message=ReservationConfig, + proto.MESSAGE, number=6, oneof='type_config', message=ReservationConfig ) maintenance_config = proto.Field( - proto.MESSAGE, - number=7, - oneof='type_config', - message=MaintenanceConfig, + proto.MESSAGE, number=7, oneof='type_config', message=MaintenanceConfig ) @@ -910,29 +598,11 @@ class QuantumReservation(proto.Message): - """ - name = proto.Field( - proto.STRING, - number=1, - ) - start_time = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - end_time = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - cancelled_time = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - whitelisted_users = proto.RepeatedField( - proto.STRING, - number=5, - ) + name = proto.Field(proto.STRING, number=1) + start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp) + end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp) + cancelled_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp) + whitelisted_users = proto.RepeatedField(proto.STRING, number=5) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/cirq-google/cirq_google/engine/abstract_local_processor.py b/cirq-google/cirq_google/engine/abstract_local_processor.py index a69d1410ecc..38b869f973c 100644 --- a/cirq-google/cirq_google/engine/abstract_local_processor.py +++ b/cirq-google/cirq_google/engine/abstract_local_processor.py @@ -28,13 +28,11 @@ @overload -def _to_timestamp(union_time: None) -> None: - ... +def _to_timestamp(union_time: None) -> None: ... @overload -def _to_timestamp(union_time: Union[datetime.datetime, datetime.timedelta]) -> int: - ... +def _to_timestamp(union_time: Union[datetime.datetime, datetime.timedelta]) -> int: ... def _to_timestamp(union_time: Union[None, datetime.datetime, datetime.timedelta]) -> Optional[int]: diff --git a/cirq-google/cirq_google/line/placement/greedy_test.py b/cirq-google/cirq_google/line/placement/greedy_test.py index e41d5d2b182..0eceae06e82 100644 --- a/cirq-google/cirq_google/line/placement/greedy_test.py +++ b/cirq-google/cirq_google/line/placement/greedy_test.py @@ -78,9 +78,10 @@ def test_find_sequence_calls_expand_sequence(): qubits = [q00, q01, q02] start = q01 search = greedy.GreedySequenceSearch(_create_device(qubits), start) - with mock.patch.object(search, '_sequence_search') as sequence_search, mock.patch.object( - search, '_expand_sequence' - ) as expand_sequence: + with ( + mock.patch.object(search, '_sequence_search') as sequence_search, + mock.patch.object(search, '_expand_sequence') as expand_sequence, + ): head = [q01, q00] tail = [q01, q02] sequence_search.side_effect = [tail, head] diff --git a/cirq-google/cirq_google/transformers/target_gatesets/sycamore_gateset.py b/cirq-google/cirq_google/transformers/target_gatesets/sycamore_gateset.py index 10605ef6395..57599ca1ff9 100644 --- a/cirq-google/cirq_google/transformers/target_gatesets/sycamore_gateset.py +++ b/cirq-google/cirq_google/transformers/target_gatesets/sycamore_gateset.py @@ -92,9 +92,11 @@ def merge_func_swap_rzz( merged_cop_tags = {merged_swap_rzz_tag, merged_2q_component_tag} circuit = cirq.map_operations( circuit, - map_func=lambda op, _: op - if merged_cop_tags.isdisjoint(op.tags) - else op.with_tags(cast(str, intermediate_result_tag)), + map_func=lambda op, _: ( + op + if merged_cop_tags.isdisjoint(op.tags) + else op.with_tags(cast(str, intermediate_result_tag)) + ), tags_to_ignore=tags_to_ignore, deep=True, ) diff --git a/cirq-ionq/cirq_ionq/ionq_gateset.py b/cirq-ionq/cirq_ionq/ionq_gateset.py index 849df1081ac..0a67787030c 100644 --- a/cirq-ionq/cirq_ionq/ionq_gateset.py +++ b/cirq-ionq/cirq_ionq/ionq_gateset.py @@ -71,9 +71,11 @@ def _decompose_two_qubit_operation(self, op: cirq.Operation, _) -> cirq.OP_TREE: naive = cirq.two_qubit_matrix_to_cz_operations(q0, q1, mat, allow_partial_czs=False) temp = cirq.map_operations_and_unroll( cirq.Circuit(naive), - lambda op, _: [cirq.H(op.qubits[1]), cirq.CNOT(*op.qubits), cirq.H(op.qubits[1])] - if op.gate == cirq.CZ - else op, + lambda op, _: ( + [cirq.H(op.qubits[1]), cirq.CNOT(*op.qubits), cirq.H(op.qubits[1])] + if op.gate == cirq.CZ + else op + ), ) return cirq.merge_k_qubit_unitaries( temp, k=1, rewriter=lambda op: self._decompose_single_qubit_operation(op, -1) diff --git a/examples/direct_fidelity_estimation.py b/examples/direct_fidelity_estimation.py index 723513193c5..7bda166acb3 100644 --- a/examples/direct_fidelity_estimation.py +++ b/examples/direct_fidelity_estimation.py @@ -140,7 +140,7 @@ def _enumerate_all_from_stabilizer_bases( dense_pauli_strings = [] for coefficients in itertools.product([False, True], repeat=n_qubits): dense_pauli_string = cirq.DensePauliString.eye(n_qubits) - for (keep, stabilizer) in zip(coefficients, stabilizer_basis): + for keep, stabilizer in zip(coefficients, stabilizer_basis): if keep: dense_pauli_string *= stabilizer dense_pauli_strings.append(dense_pauli_string)