Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.ruff]
target-version = "py39"
target-version = "py310"
line-length = 100
lint.isort = { known-first-party = [
"braket",
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
python_requires=">= 3.11",
packages=find_namespace_packages(where="src", exclude=("test",)),
package_dir={"": "src"},
install_requires=["pydantic>2"],
install_requires=[
"pydantic>2",
"setuptools==81.0.0", # pin until https://github.com/pypa/setuptools/issues/5174 is fixed
],
extras_require={
"test": [
"jsonschema",
Expand Down
5 changes: 2 additions & 3 deletions src/braket/device_schema/aqt/aqt_device_capabilities_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License

from typing import Union

from pydantic.v1 import Field

Expand Down Expand Up @@ -50,8 +49,8 @@ class AqtDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
action: dict[
Union[DeviceActionType, str],
Union[OpenQASMDeviceActionProperties, OpenQASMProgramSetDeviceActionProperties],
DeviceActionType | str,
OpenQASMDeviceActionProperties | OpenQASMProgramSetDeviceActionProperties,
]
paradigm: GateModelQpuParadigmProperties
provider: AqtProviderProperties
Expand Down
3 changes: 1 addition & 2 deletions src/braket/device_schema/device_action_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# language governing permissions and limitations under the License.

from enum import Enum
from typing import Union

from pydantic.v1 import BaseModel

Expand Down Expand Up @@ -49,4 +48,4 @@ class DeviceActionProperties(BaseModel):
"""

version: list[str]
actionType: Union[DeviceActionType, str]
actionType: DeviceActionType | str
3 changes: 1 addition & 2 deletions src/braket/device_schema/device_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

from typing import Union

from pydantic.v1 import BaseModel

Expand Down Expand Up @@ -72,5 +71,5 @@ class DeviceCapabilities(BaseModel):
"""

service: DeviceServiceProperties
action: dict[Union[DeviceActionType, str], DeviceActionProperties]
action: dict[DeviceActionType | str, DeviceActionProperties]
deviceParameters: dict
3 changes: 1 addition & 2 deletions src/braket/device_schema/device_execution_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from datetime import time
from enum import Enum
from typing import Union

from pydantic.v1 import BaseModel

Expand Down Expand Up @@ -67,6 +66,6 @@ class DeviceExecutionWindow(BaseModel):

"""

executionDay: Union[ExecutionDay, str]
executionDay: ExecutionDay | str
windowStartHour: time
windowEndHour: time
17 changes: 8 additions & 9 deletions src/braket/device_schema/device_service_properties_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# language governing permissions and limitations under the License.

from datetime import datetime
from typing import Optional

from pydantic.v1 import BaseModel, Field

Expand Down Expand Up @@ -61,9 +60,9 @@ class DeviceDocumentation(BaseModel):
>>> DeviceDocumentation.parse_raw(json.dumps(input_json))
"""

imageUrl: Optional[str]
summary: Optional[str]
externalDocumentationUrl: Optional[str]
imageUrl: str | None
summary: str | None
externalDocumentationUrl: str | None


class DeviceServiceProperties(BraketSchemaBase):
Expand Down Expand Up @@ -120,8 +119,8 @@ class DeviceServiceProperties(BraketSchemaBase):
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
executionWindows: list[DeviceExecutionWindow]
shotsRange: tuple[int, int]
deviceCost: Optional[DeviceCost]
deviceDocumentation: Optional[DeviceDocumentation]
deviceLocation: Optional[str]
updatedAt: Optional[datetime]
getTaskPollIntervalMillis: Optional[int]
deviceCost: DeviceCost | None
deviceDocumentation: DeviceDocumentation | None
deviceLocation: str | None
updatedAt: datetime | None
getTaskPollIntervalMillis: int | None
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License

from typing import Optional, Union
# ruff: noqa: N999

from pydantic.v1 import Field

Expand Down Expand Up @@ -80,20 +80,20 @@ class Dwave2000QDeviceLevelParameters(BraketSchemaBase):
name="braket.device_schema.dwave.dwave_2000Q_device_level_parameters", version="1"
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
annealingOffsets: Optional[list[float]]
annealingSchedule: Optional[list[list[float]]]
annealingDuration: Optional[float] = Field(gt=0)
autoScale: Optional[bool]
beta: Optional[float]
chains: Optional[list[list[int]]]
compensateFluxDrift: Optional[bool]
fluxBiases: Optional[list[float]]
initialState: Optional[list[int]]
maxResults: Optional[int] = Field(gt=0)
postprocessingType: Optional[Union[PostProcessingType, str]]
programmingThermalizationDuration: Optional[int]
readoutThermalizationDuration: Optional[int]
reduceIntersampleCorrelation: Optional[bool]
reinitializeState: Optional[bool]
resultFormat: Optional[ResultFormat]
spinReversalTransformCount: Optional[int] = Field(gt=0)
annealingOffsets: list[float] | None
annealingSchedule: list[list[float]] | None
annealingDuration: float | None = Field(gt=0)
autoScale: bool | None
beta: float | None
chains: list[list[int]] | None
compensateFluxDrift: bool | None
fluxBiases: list[float] | None
initialState: list[int] | None
maxResults: int | None = Field(gt=0)
postprocessingType: PostProcessingType | str | None
programmingThermalizationDuration: int | None
readoutThermalizationDuration: int | None
reduceIntersampleCorrelation: bool | None
reinitializeState: bool | None
resultFormat: ResultFormat | None
spinReversalTransformCount: int | None = Field(gt=0)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License

# ruff: noqa: N999

from pydantic.v1 import Field

from braket.device_schema.dwave.dwave_2000Q_device_level_parameters_v1 import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License

from typing import Optional

from pydantic.v1 import Field

Expand Down Expand Up @@ -69,17 +68,17 @@ class DwaveAdvantageDeviceLevelParameters(BraketSchemaBase):
name="braket.device_schema.dwave.dwave_advantage_device_level_parameters", version="1"
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
annealingOffsets: Optional[list[float]]
annealingSchedule: Optional[list[list[float]]]
annealingDuration: Optional[float] = Field(gt=0)
autoScale: Optional[bool]
compensateFluxDrift: Optional[bool]
fluxBiases: Optional[list[float]]
initialState: Optional[list[int]]
maxResults: Optional[int] = Field(gt=0)
programmingThermalizationDuration: Optional[int]
readoutThermalizationDuration: Optional[int]
reduceIntersampleCorrelation: Optional[bool]
reinitializeState: Optional[bool]
resultFormat: Optional[ResultFormat]
spinReversalTransformCount: Optional[int] = Field(gt=0)
annealingOffsets: list[float] | None
annealingSchedule: list[list[float]] | None
annealingDuration: float | None = Field(gt=0)
autoScale: bool | None
compensateFluxDrift: bool | None
fluxBiases: list[float] | None
initialState: list[int] | None
maxResults: int | None = Field(gt=0)
programmingThermalizationDuration: int | None
readoutThermalizationDuration: int | None
reduceIntersampleCorrelation: bool | None
reinitializeState: bool | None
resultFormat: ResultFormat | None
spinReversalTransformCount: int | None = Field(gt=0)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
from typing import Optional, Union

from pydantic.v1 import Field

Expand Down Expand Up @@ -54,7 +53,7 @@ class DwaveDeviceParameters(BraketSchemaBase):
name="braket.device_schema.dwave.dwave_device_parameters", version="1"
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
providerLevelParameters: Optional[DwaveProviderLevelParameters]
deviceLevelParameters: Optional[
Union[DwaveAdvantageDeviceLevelParameters, Dwave2000QDeviceLevelParameters]
]
providerLevelParameters: DwaveProviderLevelParameters | None
deviceLevelParameters: (
DwaveAdvantageDeviceLevelParameters | Dwave2000QDeviceLevelParameters | None
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# language governing permissions and limitations under the License.

from enum import Enum
from typing import Optional, Union

from pydantic.v1 import Field

Expand Down Expand Up @@ -97,20 +96,20 @@ class DwaveProviderLevelParameters(BraketSchemaBase):
name="braket.device_schema.dwave.dwave_provider_level_parameters", version="1"
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
annealingOffsets: Optional[list[float]]
annealingSchedule: Optional[list[list[float]]]
annealingDuration: Optional[int] = Field(gt=0)
autoScale: Optional[bool]
beta: Optional[float]
chains: Optional[list[list[int]]]
compensateFluxDrift: Optional[bool]
fluxBiases: Optional[list[float]]
initialState: Optional[list[int]]
maxResults: Optional[int] = Field(gt=0)
postprocessingType: Optional[Union[PostProcessingType, str]]
programmingThermalizationDuration: Optional[int]
readoutThermalizationDuration: Optional[int]
reduceIntersampleCorrelation: Optional[bool]
reinitializeState: Optional[bool]
resultFormat: Optional[ResultFormat]
spinReversalTransformCount: Optional[int] = Field(gt=0)
annealingOffsets: list[float] | None
annealingSchedule: list[list[float]] | None
annealingDuration: int | None = Field(gt=0)
autoScale: bool | None
beta: float | None
chains: list[list[int]] | None
compensateFluxDrift: bool | None
fluxBiases: list[float] | None
initialState: list[int] | None
maxResults: int | None = Field(gt=0)
postprocessingType: PostProcessingType | str | None
programmingThermalizationDuration: int | None
readoutThermalizationDuration: int | None
reduceIntersampleCorrelation: bool | None
reinitializeState: bool | None
resultFormat: ResultFormat | None
spinReversalTransformCount: int | None = Field(gt=0)
2 changes: 1 addition & 1 deletion src/braket/device_schema/ionq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
IonqDeviceCapabilities,
)
from braket.device_schema.ionq.ionq_device_parameters_v1 import IonqDeviceParameters # noqa: F401
from braket.device_schema.ionq.ionq_provider_properties_v1 import ( # noqa: F401, E501
from braket.device_schema.ionq.ionq_provider_properties_v1 import ( # noqa: F401
IonqProviderProperties,
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# language governing permissions and limitations under the License.

import json
from typing import Optional, Union

from pydantic.v1 import Field

Expand Down Expand Up @@ -126,12 +125,12 @@ class IonqDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
action: dict[
Union[DeviceActionType, str],
Union[OpenQASMDeviceActionProperties, JaqcdDeviceActionProperties],
DeviceActionType | str,
OpenQASMDeviceActionProperties | JaqcdDeviceActionProperties,
]
paradigm: GateModelQpuParadigmProperties
provider: Optional[IonqProviderProperties]
standardized: Optional[StandardizedGateModelQpuDeviceProperties]
provider: IonqProviderProperties | None
standardized: StandardizedGateModelQpuDeviceProperties | None

class Config:
# Pydantic does not use the custom encoders/decoders of nested models:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# language governing permissions and limitations under the License.

from importlib import import_module
from typing import Optional

from pydantic.v1 import Field, validator

Expand Down Expand Up @@ -54,7 +53,7 @@ class IonqDeviceParameters(BraketSchemaBase):
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
paradigmParameters: GateModelParameters
errorMitigation: Optional[list[ErrorMitigationScheme]] = None
errorMitigation: list[ErrorMitigationScheme] | None = None

@validator("errorMitigation", each_item=True, pre=True)
def validate_em(cls, value, field):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import json
from importlib import import_module
from typing import Optional

from pydantic.v1 import Field

Expand Down Expand Up @@ -97,7 +96,7 @@ class IonqProviderProperties(BraketSchemaBase):
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
fidelity: dict[str, dict[str, float]]
timing: dict[str, float]
errorMitigation: Optional[dict[type[ErrorMitigationScheme], ErrorMitigationProperties]] = None
errorMitigation: dict[type[ErrorMitigationScheme], ErrorMitigationProperties] | None = None

class Config:
json_loads = _loads_with_error_mitigation
Expand Down
9 changes: 4 additions & 5 deletions src/braket/device_schema/iqm/iqm_device_capabilities_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License

from typing import Optional, Union

from pydantic.v1 import Field

Expand Down Expand Up @@ -51,9 +50,9 @@ class IqmDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
action: dict[
Union[DeviceActionType, str],
Union[OpenQASMDeviceActionProperties, OpenQASMProgramSetDeviceActionProperties],
DeviceActionType | str,
OpenQASMDeviceActionProperties | OpenQASMProgramSetDeviceActionProperties,
]
paradigm: GateModelQpuParadigmProperties
provider: Optional[IqmProviderProperties]
standardized: Optional[StandardizedGateModelQpuDeviceProperties]
provider: IqmProviderProperties | None
standardized: StandardizedGateModelQpuDeviceProperties | None
10 changes: 5 additions & 5 deletions src/braket/device_schema/iqm/iqm_provider_properties_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License

from typing import TypeVar, Union
from typing import TypeVar

from pydantic.v1 import Field

from braket.schema_common.schema_base import BraketSchemaBase
from braket.schema_common.schema_header import BraketSchemaHeader

GateFidelityType = TypeVar("GateFidelityType", bound=dict[str, Union[str, float]])
OneQubitType = TypeVar("OneQubitType", bound=Union[float, list[GateFidelityType]])
TwoQubitType = TypeVar("TwoQubitType", bound=dict[str, Union[float, dict[str, int]]])
GateFidelityType = TypeVar("GateFidelityType", bound=dict[str, str | float])
OneQubitType = TypeVar("OneQubitType", bound=float | list[GateFidelityType])
TwoQubitType = TypeVar("TwoQubitType", bound=dict[str, float | dict[str, int]])

QubitType = TypeVar("QubitType", bound=dict[str, Union[OneQubitType, TwoQubitType]])
QubitType = TypeVar("QubitType", bound=dict[str, OneQubitType | TwoQubitType])


class IqmProviderProperties(BraketSchemaBase):
Expand Down
Loading
Loading