Skip to content

Commit b6971d2

Browse files
committed
fix: remove Optional type hint on deploy
1 parent b4b1b12 commit b6971d2

File tree

1 file changed

+21
-62
lines changed

1 file changed

+21
-62
lines changed

google/cloud/aiplatform/models.py

+21-62
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,13 @@ def deploy(
470470
self,
471471
model: "Model",
472472
deployed_model_display_name: Optional[str] = None,
473-
traffic_percentage: int = 0,
473+
traffic_percentage: Optional[int] = 0,
474474
traffic_split: Optional[Dict[str, int]] = None,
475475
machine_type: Optional[str] = None,
476476
min_replica_count: int = 1,
477477
max_replica_count: int = 1,
478478
accelerator_type: Optional[str] = None,
479479
accelerator_count: Optional[int] = None,
480-
service_account: Optional[str] = None,
481480
explanation_metadata: Optional[explain.ExplanationMetadata] = None,
482481
explanation_parameters: Optional[explain.ExplanationParameters] = None,
483482
metadata: Optional[Sequence[Tuple[str, str]]] = (),
@@ -532,13 +531,6 @@ def deploy(
532531
NVIDIA_TESLA_V100, NVIDIA_TESLA_P4, NVIDIA_TESLA_T4, TPU_V2, TPU_V3
533532
accelerator_count (int):
534533
Optional. The number of accelerators to attach to a worker replica.
535-
service_account (str):
536-
The service account that the DeployedModel's container runs as. Specify the
537-
email address of the service account. If this service account is not
538-
specified, the container runs as a service account that doesn't have access
539-
to the resource project.
540-
Users deploying the Model must have the `iam.serviceAccounts.actAs`
541-
permission on this service account.
542534
explanation_metadata (explain.ExplanationMetadata):
543535
Optional. Metadata describing the Model's input and output for explanation.
544536
Both `explanation_metadata` and `explanation_parameters` must be
@@ -577,7 +569,6 @@ def deploy(
577569
max_replica_count=max_replica_count,
578570
accelerator_type=accelerator_type,
579571
accelerator_count=accelerator_count,
580-
service_account=service_account,
581572
explanation_metadata=explanation_metadata,
582573
explanation_parameters=explanation_parameters,
583574
metadata=metadata,
@@ -592,11 +583,10 @@ def _deploy(
592583
traffic_percentage: Optional[int] = 0,
593584
traffic_split: Optional[Dict[str, int]] = None,
594585
machine_type: Optional[str] = None,
595-
min_replica_count: Optional[int] = 1,
596-
max_replica_count: Optional[int] = 1,
586+
min_replica_count: int = 1,
587+
max_replica_count: int = 1,
597588
accelerator_type: Optional[str] = None,
598589
accelerator_count: Optional[int] = None,
599-
service_account: Optional[str] = None,
600590
explanation_metadata: Optional[explain.ExplanationMetadata] = None,
601591
explanation_parameters: Optional[explain.ExplanationParameters] = None,
602592
metadata: Optional[Sequence[Tuple[str, str]]] = (),
@@ -651,13 +641,6 @@ def _deploy(
651641
NVIDIA_TESLA_V100, NVIDIA_TESLA_P4, NVIDIA_TESLA_T4, TPU_V2, TPU_V3
652642
accelerator_count (int):
653643
Optional. The number of accelerators to attach to a worker replica.
654-
service_account (str):
655-
The service account that the DeployedModel's container runs as. Specify the
656-
email address of the service account. If this service account is not
657-
specified, the container runs as a service account that doesn't have access
658-
to the resource project.
659-
Users deploying the Model must have the `iam.serviceAccounts.actAs`
660-
permission on this service account.
661644
explanation_metadata (explain.ExplanationMetadata):
662645
Optional. Metadata describing the Model's input and output for explanation.
663646
Both `explanation_metadata` and `explanation_parameters` must be
@@ -694,7 +677,6 @@ def _deploy(
694677
max_replica_count=max_replica_count,
695678
accelerator_type=accelerator_type,
696679
accelerator_count=accelerator_count,
697-
service_account=service_account,
698680
explanation_metadata=explanation_metadata,
699681
explanation_parameters=explanation_parameters,
700682
metadata=metadata,
@@ -715,11 +697,10 @@ def _deploy_call(
715697
traffic_percentage: Optional[int] = 0,
716698
traffic_split: Optional[Dict[str, int]] = None,
717699
machine_type: Optional[str] = None,
718-
min_replica_count: Optional[int] = 1,
719-
max_replica_count: Optional[int] = 1,
700+
min_replica_count: int = 1,
701+
max_replica_count: int = 1,
720702
accelerator_type: Optional[str] = None,
721703
accelerator_count: Optional[int] = None,
722-
service_account: Optional[str] = None,
723704
explanation_metadata: Optional[explain.ExplanationMetadata] = None,
724705
explanation_parameters: Optional[explain.ExplanationParameters] = None,
725706
metadata: Optional[Sequence[Tuple[str, str]]] = (),
@@ -772,13 +753,6 @@ def _deploy_call(
772753
is not provided, the larger value of min_replica_count or 1 will
773754
be used. If value provided is smaller than min_replica_count, it
774755
will automatically be increased to be min_replica_count.
775-
service_account (str):
776-
The service account that the DeployedModel's container runs as. Specify the
777-
email address of the service account. If this service account is not
778-
specified, the container runs as a service account that doesn't have access
779-
to the resource project.
780-
Users deploying the Model must have the `iam.serviceAccounts.actAs`
781-
permission on this service account.
782756
explanation_metadata (explain.ExplanationMetadata):
783757
Optional. Metadata describing the Model's input and output for explanation.
784758
Both `explanation_metadata` and `explanation_parameters` must be
@@ -814,12 +788,6 @@ def _deploy_call(
814788
gca_endpoint = gca_endpoint_v1beta1
815789
gca_machine_resources = gca_machine_resources_v1beta1
816790

817-
deployed_model = gca_endpoint.DeployedModel(
818-
model=model_resource_name,
819-
display_name=deployed_model_display_name,
820-
service_account=service_account,
821-
)
822-
823791
if machine_type:
824792
machine_spec = gca_machine_resources.MachineSpec(machine_type=machine_type)
825793

@@ -828,17 +796,26 @@ def _deploy_call(
828796
machine_spec.accelerator_type = accelerator_type
829797
machine_spec.accelerator_count = accelerator_count
830798

831-
deployed_model.dedicated_resources = gca_machine_resources.DedicatedResources(
799+
dedicated_resources = gca_machine_resources.DedicatedResources(
832800
machine_spec=machine_spec,
833801
min_replica_count=min_replica_count,
834802
max_replica_count=max_replica_count,
835803
)
836-
804+
deployed_model = gca_endpoint.DeployedModel(
805+
dedicated_resources=dedicated_resources,
806+
model=model_resource_name,
807+
display_name=deployed_model_display_name,
808+
)
837809
else:
838-
deployed_model.automatic_resources = gca_machine_resources.AutomaticResources(
810+
automatic_resources = gca_machine_resources.AutomaticResources(
839811
min_replica_count=min_replica_count,
840812
max_replica_count=max_replica_count,
841813
)
814+
deployed_model = gca_endpoint.DeployedModel(
815+
automatic_resources=automatic_resources,
816+
model=model_resource_name,
817+
display_name=deployed_model_display_name,
818+
)
842819

843820
# Service will throw error if both metadata and parameters are not provided
844821
if explanation_metadata and explanation_parameters:
@@ -1512,11 +1489,10 @@ def deploy(
15121489
traffic_percentage: Optional[int] = 0,
15131490
traffic_split: Optional[Dict[str, int]] = None,
15141491
machine_type: Optional[str] = None,
1515-
min_replica_count: Optional[int] = 1,
1516-
max_replica_count: Optional[int] = 1,
1492+
min_replica_count: int = 1,
1493+
max_replica_count: int = 1,
15171494
accelerator_type: Optional[str] = None,
15181495
accelerator_count: Optional[int] = None,
1519-
service_account: Optional[str] = None,
15201496
explanation_metadata: Optional[explain.ExplanationMetadata] = None,
15211497
explanation_parameters: Optional[explain.ExplanationParameters] = None,
15221498
metadata: Optional[Sequence[Tuple[str, str]]] = (),
@@ -1572,13 +1548,6 @@ def deploy(
15721548
NVIDIA_TESLA_V100, NVIDIA_TESLA_P4, NVIDIA_TESLA_T4, TPU_V2, TPU_V3
15731549
accelerator_count (int):
15741550
Optional. The number of accelerators to attach to a worker replica.
1575-
service_account (str):
1576-
The service account that the DeployedModel's container runs as. Specify the
1577-
email address of the service account. If this service account is not
1578-
specified, the container runs as a service account that doesn't have access
1579-
to the resource project.
1580-
Users deploying the Model must have the `iam.serviceAccounts.actAs`
1581-
permission on this service account.
15821551
explanation_metadata (explain.ExplanationMetadata):
15831552
Optional. Metadata describing the Model's input and output for explanation.
15841553
Both `explanation_metadata` and `explanation_parameters` must be
@@ -1632,7 +1601,6 @@ def deploy(
16321601
max_replica_count=max_replica_count,
16331602
accelerator_type=accelerator_type,
16341603
accelerator_count=accelerator_count,
1635-
service_account=service_account,
16361604
explanation_metadata=explanation_metadata,
16371605
explanation_parameters=explanation_parameters,
16381606
metadata=metadata,
@@ -1649,11 +1617,10 @@ def _deploy(
16491617
traffic_percentage: Optional[int] = 0,
16501618
traffic_split: Optional[Dict[str, int]] = None,
16511619
machine_type: Optional[str] = None,
1652-
min_replica_count: Optional[int] = 1,
1653-
max_replica_count: Optional[int] = 1,
1620+
min_replica_count: int = 1,
1621+
max_replica_count: int = 1,
16541622
accelerator_type: Optional[str] = None,
16551623
accelerator_count: Optional[int] = None,
1656-
service_account: Optional[str] = None,
16571624
explanation_metadata: Optional[explain.ExplanationMetadata] = None,
16581625
explanation_parameters: Optional[explain.ExplanationParameters] = None,
16591626
metadata: Optional[Sequence[Tuple[str, str]]] = (),
@@ -1709,13 +1676,6 @@ def _deploy(
17091676
NVIDIA_TESLA_V100, NVIDIA_TESLA_P4, NVIDIA_TESLA_T4, TPU_V2, TPU_V3
17101677
accelerator_count (int):
17111678
Optional. The number of accelerators to attach to a worker replica.
1712-
service_account (str):
1713-
The service account that the DeployedModel's container runs as. Specify the
1714-
email address of the service account. If this service account is not
1715-
specified, the container runs as a service account that doesn't have access
1716-
to the resource project.
1717-
Users deploying the Model must have the `iam.serviceAccounts.actAs`
1718-
permission on this service account.
17191679
explanation_metadata (explain.ExplanationMetadata):
17201680
Optional. Metadata describing the Model's input and output for explanation.
17211681
Both `explanation_metadata` and `explanation_parameters` must be
@@ -1772,7 +1732,6 @@ def _deploy(
17721732
max_replica_count=max_replica_count,
17731733
accelerator_type=accelerator_type,
17741734
accelerator_count=accelerator_count,
1775-
service_account=service_account,
17761735
explanation_metadata=explanation_metadata,
17771736
explanation_parameters=explanation_parameters,
17781737
metadata=metadata,

0 commit comments

Comments
 (0)