From 6fd23207bc2dc97e02656839e14f1ae291815ac9 Mon Sep 17 00:00:00 2001 From: Kalan Date: Mon, 5 Jun 2023 19:24:59 -0700 Subject: [PATCH 1/8] feat(python): support TranslationOptions --- .../qcs_sdk/grpc/models/translation.pyi | 45 +++++++++++++++++++ crates/python/qcs_sdk/qpu/translation.pyi | 3 ++ crates/python/src/grpc/mod.rs | 8 ++++ crates/python/src/grpc/models/mod.rs | 8 ++++ crates/python/src/grpc/models/translation.rs | 11 ++++- 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 crates/python/qcs_sdk/grpc/models/translation.pyi diff --git a/crates/python/qcs_sdk/grpc/models/translation.pyi b/crates/python/qcs_sdk/grpc/models/translation.pyi new file mode 100644 index 000000000..78bb203b6 --- /dev/null +++ b/crates/python/qcs_sdk/grpc/models/translation.pyi @@ -0,0 +1,45 @@ +from typing import Optional, final + +class TranslationOptions: + translation_backend: Optional[TranslationBackend] = None + + ... + +@final +class TranslationBackend: + """ + Object specifying which translation backend to use to translate a particular program, + and for that given backend, what options to apply. + + Variants: + ``v1``: Corresponds to the V1 translation backend. + ``v2``: Corresponds to the V2 translation backend. + + Methods (each per variant): + - ``is_*``: if the underlying values are that type. + - ``as_*``: if the underlying values are that type, then those values, otherwise ``None``. + - ``to_*``: the underlying values as that type, raises ``ValueError`` if they are not. + - ``from_*``: wrap underlying values as this enum type. + + """ + + def is_v1(self) -> bool: ... + def is_v2(self) -> bool: ... + def as_v1(self) -> Optional[BackendV1Options]: ... + def as_v2(self) -> Optional[BackendV2Options]: ... + def to_v1(self) -> BackendV1Options: ... + def to_v2(self) -> BackendV2Options: ... + @staticmethod + def from_v1(inner: BackendV1Options) -> "TranslationBackend": ... + @staticmethod + def from_v2(inner: BackendV2Options) -> "TranslationBackend": ... + +class BackendV1Options: + """ + Options for the V1 translation backend. + """ + +class BackendV2Options: + """ + Options for the V2 translation backend. + """ \ No newline at end of file diff --git a/crates/python/qcs_sdk/qpu/translation.pyi b/crates/python/qcs_sdk/qpu/translation.pyi index ea8fd13da..11666738e 100644 --- a/crates/python/qcs_sdk/qpu/translation.pyi +++ b/crates/python/qcs_sdk/qpu/translation.pyi @@ -1,6 +1,7 @@ from typing import Dict, Optional, final from qcs_sdk.client import QCSClient +from qcs_sdk.grpc.models.translation import TranslationOptions class GetQuiltCalibrationsError(RuntimeError): """An error occured while fetching Quil-T calibrations.""" @@ -88,6 +89,7 @@ def translate( num_shots: int, quantum_processor_id: str, client: Optional[QCSClient] = None, + translation_options: Optional[TranslationOptions] = None, ) -> TranslationResult: """ Translates a native Quil program into an executable program. @@ -109,6 +111,7 @@ async def translate_async( num_shots: int, quantum_processor_id: str, client: Optional[QCSClient] = None, + translation_options: Optional[TranslationOptions] = None, ) -> TranslationResult: """ Translates a native Quil program into an executable program. diff --git a/crates/python/src/grpc/mod.rs b/crates/python/src/grpc/mod.rs index c446ac883..28364fb7d 100644 --- a/crates/python/src/grpc/mod.rs +++ b/crates/python/src/grpc/mod.rs @@ -1 +1,9 @@ +use rigetti_pyo3::create_init_submodule; + pub mod models; + +create_init_submodule! { + submodules: [ + "models": models::init_submodule + ], +} \ No newline at end of file diff --git a/crates/python/src/grpc/models/mod.rs b/crates/python/src/grpc/models/mod.rs index 8eb70c293..7d4136c54 100644 --- a/crates/python/src/grpc/models/mod.rs +++ b/crates/python/src/grpc/models/mod.rs @@ -1,2 +1,10 @@ +use rigetti_pyo3::create_init_submodule; + pub mod controller; pub mod translation; + +create_init_submodule! { + submodules: [ + "translation": translation::init_submodule + ], +} diff --git a/crates/python/src/grpc/models/translation.rs b/crates/python/src/grpc/models/translation.rs index 1c999272c..846618df4 100644 --- a/crates/python/src/grpc/models/translation.rs +++ b/crates/python/src/grpc/models/translation.rs @@ -1,7 +1,7 @@ use qcs_api_client_grpc::services::translation::{ translation_options::TranslationBackend, BackendV1Options, BackendV2Options, TranslationOptions, }; -use rigetti_pyo3::{py_wrap_data_struct, py_wrap_type, py_wrap_union_enum}; +use rigetti_pyo3::{py_wrap_data_struct, py_wrap_type, py_wrap_union_enum, create_init_submodule}; py_wrap_type! { #[derive(Default)] @@ -26,3 +26,12 @@ py_wrap_data_struct! { translation_backend: Option => Option } } + +create_init_submodule! { + classes: [ + PyTranslationBackend, + PyTranslationOptions, + PyBackendV1Options, + PyBackendV2Options + ], +} \ No newline at end of file From 327f9848a17e59418b728a0d22a9590a873ce862 Mon Sep 17 00:00:00 2001 From: Kalan Date: Mon, 5 Jun 2023 19:52:58 -0700 Subject: [PATCH 2/8] add submodule reference --- crates/lib/src/qpu/translation.rs | 47 +++++++++++++++++++++++++++---- crates/python/src/lib.rs | 1 + 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/crates/lib/src/qpu/translation.rs b/crates/lib/src/qpu/translation.rs index 6e30de029..7183c5455 100644 --- a/crates/lib/src/qpu/translation.rs +++ b/crates/lib/src/qpu/translation.rs @@ -6,8 +6,9 @@ use std::{collections::HashMap, time::Duration}; use qcs_api_client_grpc::{ models::controller::EncryptedControllerJob, services::translation::{ - translate_quil_to_encrypted_controller_job_request::NumShots, - TranslateQuilToEncryptedControllerJobRequest, TranslationOptions, + self, translate_quil_to_encrypted_controller_job_request::NumShots, + translation_options::TranslationBackend, TranslateQuilToEncryptedControllerJobRequest, + TranslationOptions as RdmTranslationOptions, }, }; use qcs_api_client_openapi::{ @@ -33,13 +34,16 @@ pub struct EncryptedTranslationResult { } /// Translate a program, returning an encrypted and translated program. -pub async fn translate( +pub async fn translate( quantum_processor_id: &str, quil_program: &str, num_shots: u32, client: &Qcs, - translation_options: Option, -) -> Result { + translation_options: TO, +) -> Result +where + TO: Into>, +{ #[cfg(feature = "tracing")] tracing::debug!( %num_shots, @@ -47,11 +51,13 @@ pub async fn translate( quantum_processor_id, ); + let options = translation_options.into(); + let request = TranslateQuilToEncryptedControllerJobRequest { quantum_processor_id: quantum_processor_id.to_owned(), num_shots: Some(NumShots::NumShotsValue(num_shots)), quil_program: quil_program.to_owned(), - options: translation_options, + options, }; let response = client @@ -104,3 +110,32 @@ pub async fn get_quilt_calibrations( }) .await? } + +/// Options available for Quil program translation. +/// +/// This wraps [`RdmTranslationOptions`] in order to improve the user experience, +/// because the structs auto-generated by `prost` can be clumsy to use directly. +#[derive(Debug, Default)] +pub struct TranslationOptions { + inner: RdmTranslationOptions, +} + +impl TranslationOptions { + /// Use the first-generation translation backend available on QCS since 2018. + pub fn use_backend_v1(&mut self) { + self.inner.translation_backend = + Some(TranslationBackend::V1(translation::BackendV1Options {})) + } + + /// Use the second-generation translation backend available on QCS since 2023 + pub fn use_backend_v2(&mut self) { + self.inner.translation_backend = + Some(TranslationBackend::V2(translation::BackendV2Options {})) + } +} + +impl From for RdmTranslationOptions { + fn from(options: TranslationOptions) -> Self { + options.inner + } +} diff --git a/crates/python/src/lib.rs b/crates/python/src/lib.rs index e1f970879..a338583fb 100644 --- a/crates/python/src/lib.rs +++ b/crates/python/src/lib.rs @@ -36,6 +36,7 @@ create_init_submodule! { submodules: [ "client": client::init_submodule, "compiler": compiler::init_submodule, + "grpc": grpc::init_submodule, "qpu": qpu::init_submodule, "qvm": qvm::init_submodule ], From 6ce00781431e0d31cddcbde6c7d054945ec77c7c Mon Sep 17 00:00:00 2001 From: Jake Selig Date: Tue, 6 Jun 2023 12:16:43 +0900 Subject: [PATCH 3/8] chore: add constructors for grpc types --- crates/python/src/grpc/models/translation.rs | 33 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/crates/python/src/grpc/models/translation.rs b/crates/python/src/grpc/models/translation.rs index 846618df4..8e198a671 100644 --- a/crates/python/src/grpc/models/translation.rs +++ b/crates/python/src/grpc/models/translation.rs @@ -1,18 +1,37 @@ use qcs_api_client_grpc::services::translation::{ translation_options::TranslationBackend, BackendV1Options, BackendV2Options, TranslationOptions, }; -use rigetti_pyo3::{py_wrap_data_struct, py_wrap_type, py_wrap_union_enum, create_init_submodule}; +use rigetti_pyo3::{ + create_init_submodule, py_wrap_data_struct, py_wrap_type, py_wrap_union_enum, + pyo3::{pymethods, PyResult}, +}; py_wrap_type! { #[derive(Default)] PyBackendV1Options(BackendV1Options) as "BackendV1Options"; } +#[pymethods] +impl PyBackendV1Options { + #[new] + fn __new__() -> PyResult { + Ok(Self::default()) + } +} + py_wrap_type! { #[derive(Default)] PyBackendV2Options(BackendV2Options) as "BackendV2Options"; } +#[pymethods] +impl PyBackendV2Options { + #[new] + fn __new__() -> PyResult { + Ok(Self::default()) + } +} + py_wrap_union_enum! { PyTranslationBackend(TranslationBackend) as "TranslationBackend" { v1: V1 => PyBackendV1Options, @@ -27,6 +46,16 @@ py_wrap_data_struct! { } } +#[pymethods] +impl PyTranslationOptions { + #[new] + fn __new__(translation_backend: Option) -> PyResult { + Ok(Self(TranslationOptions { + translation_backend: translation_backend.map(|b| b.0), + })) + } +} + create_init_submodule! { classes: [ PyTranslationBackend, @@ -34,4 +63,4 @@ create_init_submodule! { PyBackendV1Options, PyBackendV2Options ], -} \ No newline at end of file +} From 58f5beb1bb119ea52028579c831e2d80b9dcd450 Mon Sep 17 00:00:00 2001 From: Kalan Date: Tue, 6 Jun 2023 14:30:59 -0700 Subject: [PATCH 4/8] feat: TranslationOptions owned by these crates rather than imported --- crates/lib/src/qpu/translation.rs | 15 ++--- crates/python/src/executable.rs | 17 ++--- crates/python/src/grpc/mod.rs | 8 --- crates/python/src/grpc/models/mod.rs | 9 --- crates/python/src/grpc/models/translation.rs | 66 -------------------- crates/python/src/lib.rs | 1 - crates/python/src/qpu/translation.rs | 36 ++++++++++- 7 files changed, 47 insertions(+), 105 deletions(-) delete mode 100644 crates/python/src/grpc/models/translation.rs diff --git a/crates/lib/src/qpu/translation.rs b/crates/lib/src/qpu/translation.rs index 7183c5455..ad22ae7d8 100644 --- a/crates/lib/src/qpu/translation.rs +++ b/crates/lib/src/qpu/translation.rs @@ -39,10 +39,10 @@ pub async fn translate( quil_program: &str, num_shots: u32, client: &Qcs, - translation_options: TO, + translation_options: Option, ) -> Result where - TO: Into>, + TO: Into, { #[cfg(feature = "tracing")] tracing::debug!( @@ -51,7 +51,7 @@ where quantum_processor_id, ); - let options = translation_options.into(); + let options = translation_options.map(Into::into); let request = TranslateQuilToEncryptedControllerJobRequest { quantum_processor_id: quantum_processor_id.to_owned(), @@ -112,10 +112,11 @@ pub async fn get_quilt_calibrations( } /// Options available for Quil program translation. -/// +/// /// This wraps [`RdmTranslationOptions`] in order to improve the user experience, /// because the structs auto-generated by `prost` can be clumsy to use directly. -#[derive(Debug, Default)] +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug, Default)] pub struct TranslationOptions { inner: RdmTranslationOptions, } @@ -124,13 +125,13 @@ impl TranslationOptions { /// Use the first-generation translation backend available on QCS since 2018. pub fn use_backend_v1(&mut self) { self.inner.translation_backend = - Some(TranslationBackend::V1(translation::BackendV1Options {})) + Some(TranslationBackend::V1(translation::BackendV1Options {})); } /// Use the second-generation translation backend available on QCS since 2023 pub fn use_backend_v2(&mut self) { self.inner.translation_backend = - Some(TranslationBackend::V2(translation::BackendV2Options {})) + Some(TranslationBackend::V2(translation::BackendV2Options {})); } } diff --git a/crates/python/src/executable.rs b/crates/python/src/executable.rs index 5610ff11f..20696e034 100644 --- a/crates/python/src/executable.rs +++ b/crates/python/src/executable.rs @@ -2,19 +2,18 @@ use std::{num::NonZeroU16, sync::Arc}; use pyo3::{pyclass, FromPyObject}; use qcs::{Error, Executable, ExecutionData, JobHandle, Service}; -use qcs_api_client_grpc::services::translation::TranslationOptions; use rigetti_pyo3::{ impl_as_mut_for_wrapper, py_wrap_error, py_wrap_simple_enum, py_wrap_type, pyo3::{exceptions::PyRuntimeError, pymethods, types::PyDict, Py, PyAny, PyResult, Python}, - wrap_error, PyTryFrom, PyWrapper, ToPython, ToPythonError, + wrap_error, PyWrapper, ToPython, ToPythonError, }; use tokio::sync::Mutex; use crate::{ compiler::quilc::PyCompilerOpts, execution_data::PyExecutionData, - grpc::models::translation::PyTranslationOptions, py_sync::{py_async, py_sync}, + qpu::translation::PyTranslationOptions, }; wrap_error!(RustExecutionError(Error)); @@ -151,8 +150,7 @@ impl PyExecutable { endpoint_id: Option, translation_options: Option, ) -> PyResult { - let translation_options = - Option::::py_try_from(py, &translation_options)?; + let translation_options = translation_options.map(|opts| opts.as_inner().clone().into()); match endpoint_id { Some(endpoint_id) => py_sync!( py, @@ -184,8 +182,7 @@ impl PyExecutable { endpoint_id: Option, translation_options: Option, ) -> PyResult<&PyAny> { - let translation_options = - Option::::py_try_from(py, &translation_options)?; + let translation_options = translation_options.map(|opts| opts.as_inner().clone().into()); match endpoint_id { Some(endpoint_id) => py_async!( py, @@ -217,8 +214,7 @@ impl PyExecutable { endpoint_id: Option, translation_options: Option, ) -> PyResult { - let translation_options = - Option::::py_try_from(py, &translation_options)?; + let translation_options = translation_options.map(|opts| opts.as_inner().clone().into()); match endpoint_id { Some(endpoint_id) => py_sync!( py, @@ -250,8 +246,7 @@ impl PyExecutable { endpoint_id: Option, translation_options: Option, ) -> PyResult<&PyAny> { - let translation_options = - Option::::py_try_from(py, &translation_options)?; + let translation_options = translation_options.map(|opts| opts.as_inner().clone().into()); match endpoint_id { Some(endpoint_id) => { py_async!( diff --git a/crates/python/src/grpc/mod.rs b/crates/python/src/grpc/mod.rs index 28364fb7d..c446ac883 100644 --- a/crates/python/src/grpc/mod.rs +++ b/crates/python/src/grpc/mod.rs @@ -1,9 +1 @@ -use rigetti_pyo3::create_init_submodule; - pub mod models; - -create_init_submodule! { - submodules: [ - "models": models::init_submodule - ], -} \ No newline at end of file diff --git a/crates/python/src/grpc/models/mod.rs b/crates/python/src/grpc/models/mod.rs index 7d4136c54..cb9e0ac5c 100644 --- a/crates/python/src/grpc/models/mod.rs +++ b/crates/python/src/grpc/models/mod.rs @@ -1,10 +1 @@ -use rigetti_pyo3::create_init_submodule; - pub mod controller; -pub mod translation; - -create_init_submodule! { - submodules: [ - "translation": translation::init_submodule - ], -} diff --git a/crates/python/src/grpc/models/translation.rs b/crates/python/src/grpc/models/translation.rs deleted file mode 100644 index 8e198a671..000000000 --- a/crates/python/src/grpc/models/translation.rs +++ /dev/null @@ -1,66 +0,0 @@ -use qcs_api_client_grpc::services::translation::{ - translation_options::TranslationBackend, BackendV1Options, BackendV2Options, TranslationOptions, -}; -use rigetti_pyo3::{ - create_init_submodule, py_wrap_data_struct, py_wrap_type, py_wrap_union_enum, - pyo3::{pymethods, PyResult}, -}; - -py_wrap_type! { - #[derive(Default)] - PyBackendV1Options(BackendV1Options) as "BackendV1Options"; -} - -#[pymethods] -impl PyBackendV1Options { - #[new] - fn __new__() -> PyResult { - Ok(Self::default()) - } -} - -py_wrap_type! { - #[derive(Default)] - PyBackendV2Options(BackendV2Options) as "BackendV2Options"; -} - -#[pymethods] -impl PyBackendV2Options { - #[new] - fn __new__() -> PyResult { - Ok(Self::default()) - } -} - -py_wrap_union_enum! { - PyTranslationBackend(TranslationBackend) as "TranslationBackend" { - v1: V1 => PyBackendV1Options, - v2: V2 => PyBackendV2Options - } -} - -py_wrap_data_struct! { - #[derive(Default)] - PyTranslationOptions(TranslationOptions) as "TranslationOptions" { - translation_backend: Option => Option - } -} - -#[pymethods] -impl PyTranslationOptions { - #[new] - fn __new__(translation_backend: Option) -> PyResult { - Ok(Self(TranslationOptions { - translation_backend: translation_backend.map(|b| b.0), - })) - } -} - -create_init_submodule! { - classes: [ - PyTranslationBackend, - PyTranslationOptions, - PyBackendV1Options, - PyBackendV2Options - ], -} diff --git a/crates/python/src/lib.rs b/crates/python/src/lib.rs index a338583fb..e1f970879 100644 --- a/crates/python/src/lib.rs +++ b/crates/python/src/lib.rs @@ -36,7 +36,6 @@ create_init_submodule! { submodules: [ "client": client::init_submodule, "compiler": compiler::init_submodule, - "grpc": grpc::init_submodule, "qpu": qpu::init_submodule, "qvm": qvm::init_submodule ], diff --git a/crates/python/src/qpu/translation.rs b/crates/python/src/qpu/translation.rs index 3a6425034..cba6a4ab7 100644 --- a/crates/python/src/qpu/translation.rs +++ b/crates/python/src/qpu/translation.rs @@ -1,20 +1,24 @@ //! Translating programs. use std::{collections::HashMap, time::Duration}; -use pyo3::{exceptions::PyRuntimeError, pyclass, pyfunction, types::PyString, Py, PyResult}; +use pyo3::{ + exceptions::PyRuntimeError, pyclass, pyfunction, pymethods, types::PyString, Py, PyResult, +}; use qcs::client::GrpcClientError; +use qcs::qpu::translation::TranslationOptions; use qcs_api_client_openapi::models::GetQuiltCalibrationsResponse; use rigetti_pyo3::{ - create_init_submodule, py_wrap_data_struct, py_wrap_error, wrap_error, PyWrapper, ToPythonError, + create_init_submodule, py_wrap_data_struct, py_wrap_error, wrap_error, ToPythonError, }; -use crate::{grpc::models::translation::PyTranslationOptions, py_sync::py_function_sync_async}; +use crate::py_sync::py_function_sync_async; use crate::client::PyQcsClient; create_init_submodule! { classes: [ PyQuiltCalibrations, + PyTranslationOptions, PyTranslationResult ], errors: [ @@ -83,6 +87,32 @@ py_wrap_error!( PyRuntimeError ); +#[derive(Clone, Default)] +#[pyclass] +pub struct PyTranslationOptions(TranslationOptions); + +impl PyTranslationOptions { + pub fn as_inner(&self) -> &TranslationOptions { + &self.0 + } +} + +#[pymethods] +impl PyTranslationOptions { + #[new] + fn __new__() -> PyResult { + Ok(Self(Default::default())) + } + + fn use_backend_v1(&mut self) { + self.0.use_backend_v1() + } + + fn use_backend_v2(&mut self) { + self.0.use_backend_v2() + } +} + /// The result of a call to [`translate`] which provides information about the /// translated program. #[pyclass] From 934b3265a258304f641f42aee512d867714daf64 Mon Sep 17 00:00:00 2001 From: Kalan Date: Tue, 6 Jun 2023 14:44:04 -0700 Subject: [PATCH 5/8] update python bindings --- .../qcs_sdk/grpc/models/translation.pyi | 45 ------------------- crates/python/qcs_sdk/qpu/translation.pyi | 16 +++++++ 2 files changed, 16 insertions(+), 45 deletions(-) delete mode 100644 crates/python/qcs_sdk/grpc/models/translation.pyi diff --git a/crates/python/qcs_sdk/grpc/models/translation.pyi b/crates/python/qcs_sdk/grpc/models/translation.pyi deleted file mode 100644 index 78bb203b6..000000000 --- a/crates/python/qcs_sdk/grpc/models/translation.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from typing import Optional, final - -class TranslationOptions: - translation_backend: Optional[TranslationBackend] = None - - ... - -@final -class TranslationBackend: - """ - Object specifying which translation backend to use to translate a particular program, - and for that given backend, what options to apply. - - Variants: - ``v1``: Corresponds to the V1 translation backend. - ``v2``: Corresponds to the V2 translation backend. - - Methods (each per variant): - - ``is_*``: if the underlying values are that type. - - ``as_*``: if the underlying values are that type, then those values, otherwise ``None``. - - ``to_*``: the underlying values as that type, raises ``ValueError`` if they are not. - - ``from_*``: wrap underlying values as this enum type. - - """ - - def is_v1(self) -> bool: ... - def is_v2(self) -> bool: ... - def as_v1(self) -> Optional[BackendV1Options]: ... - def as_v2(self) -> Optional[BackendV2Options]: ... - def to_v1(self) -> BackendV1Options: ... - def to_v2(self) -> BackendV2Options: ... - @staticmethod - def from_v1(inner: BackendV1Options) -> "TranslationBackend": ... - @staticmethod - def from_v2(inner: BackendV2Options) -> "TranslationBackend": ... - -class BackendV1Options: - """ - Options for the V1 translation backend. - """ - -class BackendV2Options: - """ - Options for the V2 translation backend. - """ \ No newline at end of file diff --git a/crates/python/qcs_sdk/qpu/translation.pyi b/crates/python/qcs_sdk/qpu/translation.pyi index 11666738e..a9c33f476 100644 --- a/crates/python/qcs_sdk/qpu/translation.pyi +++ b/crates/python/qcs_sdk/qpu/translation.pyi @@ -128,3 +128,19 @@ async def translate_async( :raises TranslationError: If the `native_quil` program could not be translated. """ ... + +@final +class TranslationOptions: + """ + Options for translating via the QCS API. + """ + + def use_backend_v1(self) -> None: + """ + Use the v1 backend for translation, available on QCS since 2018. + """ + + def use_backend_v2(self) -> None: + """ + Use the v2 backend for translation, available on QCS since 2023. + """ From 10504898b90657fe0f5f03091b91607471f10f1a Mon Sep 17 00:00:00 2001 From: Kalan Date: Tue, 6 Jun 2023 14:50:12 -0700 Subject: [PATCH 6/8] rename alias type RdmTranslationOptions --- crates/lib/src/qpu/translation.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/lib/src/qpu/translation.rs b/crates/lib/src/qpu/translation.rs index ad22ae7d8..d494a55e8 100644 --- a/crates/lib/src/qpu/translation.rs +++ b/crates/lib/src/qpu/translation.rs @@ -8,7 +8,7 @@ use qcs_api_client_grpc::{ services::translation::{ self, translate_quil_to_encrypted_controller_job_request::NumShots, translation_options::TranslationBackend, TranslateQuilToEncryptedControllerJobRequest, - TranslationOptions as RdmTranslationOptions, + TranslationOptions as ApiTranslationOptions, }, }; use qcs_api_client_openapi::{ @@ -42,7 +42,7 @@ pub async fn translate( translation_options: Option, ) -> Result where - TO: Into, + TO: Into, { #[cfg(feature = "tracing")] tracing::debug!( @@ -113,12 +113,12 @@ pub async fn get_quilt_calibrations( /// Options available for Quil program translation. /// -/// This wraps [`RdmTranslationOptions`] in order to improve the user experience, +/// This wraps [`ApiTranslationOptions`] in order to improve the user experience, /// because the structs auto-generated by `prost` can be clumsy to use directly. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Default)] pub struct TranslationOptions { - inner: RdmTranslationOptions, + inner: ApiTranslationOptions, } impl TranslationOptions { @@ -135,7 +135,7 @@ impl TranslationOptions { } } -impl From for RdmTranslationOptions { +impl From for ApiTranslationOptions { fn from(options: TranslationOptions) -> Self { options.inner } From fcfa292ec26f7f4319e1f9f09f62143026ec001f Mon Sep 17 00:00:00 2001 From: Kalan Date: Tue, 6 Jun 2023 16:16:56 -0700 Subject: [PATCH 7/8] rename PyTranslationOptions --- crates/python/src/qpu/translation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/python/src/qpu/translation.rs b/crates/python/src/qpu/translation.rs index cba6a4ab7..4c13cc292 100644 --- a/crates/python/src/qpu/translation.rs +++ b/crates/python/src/qpu/translation.rs @@ -88,7 +88,7 @@ py_wrap_error!( ); #[derive(Clone, Default)] -#[pyclass] +#[pyclass(name = "TranslationOptions")] pub struct PyTranslationOptions(TranslationOptions); impl PyTranslationOptions { From 7b029a75b230cb6e8bc97fd865758cad03441fd0 Mon Sep 17 00:00:00 2001 From: Kalan Date: Tue, 6 Jun 2023 16:17:43 -0700 Subject: [PATCH 8/8] fix pyi import --- crates/python/qcs_sdk/qpu/translation.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/python/qcs_sdk/qpu/translation.pyi b/crates/python/qcs_sdk/qpu/translation.pyi index a9c33f476..f3be090f7 100644 --- a/crates/python/qcs_sdk/qpu/translation.pyi +++ b/crates/python/qcs_sdk/qpu/translation.pyi @@ -1,7 +1,6 @@ from typing import Dict, Optional, final from qcs_sdk.client import QCSClient -from qcs_sdk.grpc.models.translation import TranslationOptions class GetQuiltCalibrationsError(RuntimeError): """An error occured while fetching Quil-T calibrations."""