Skip to content

Commit

Permalink
Automated DCL import.
Browse files Browse the repository at this point in the history
  - 573cf0cdebedc3d250e0d74b5c67457cd39f9ee3 Automatic import from cloud_mmv2_dcl_20220805_0931_RC00 by DCL Team <[email protected]>

GitOrigin-RevId: 573cf0cdebedc3d250e0d74b5c67457cd39f9ee3
  • Loading branch information
DCL Team authored and copybara-github committed Aug 5, 2022
1 parent da34736 commit 094a3cb
Show file tree
Hide file tree
Showing 28 changed files with 129 additions and 289 deletions.
61 changes: 39 additions & 22 deletions dcl/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,34 +94,51 @@ func TitleToCamelCasePath(s string) string {
// go protoc special rules: convert to camel case, except when
// the character following the underscore is a digit; e.g.,
// foo_bar_2 -> FooBar_2.
// From: http://google3/net/goa/codegen/names.go;l=14;rcl=294425921
func ProtoCamelCase(s string) string {
var result string
// Invariant: if the next letter is lower case, it must be converted
// to upper case.
// That is, we process a word at a time, where words are marked by _ or
// upper case letter. Digits are treated as words.
var b []byte
for i := 0; i < len(s); i++ {
c := s[i]
if i == 0 {
result += strings.ToUpper(string(c))
continue
}
if c == '_' {
// Current character is underscore.
continue
}
p := s[i-1]
if p == '_' {
// Previous character was underscore.
if '0' <= c && c <= '9' {
// Current character is digit following an underscore.
result += "_"
switch {
case c == '.' && i+1 < len(s) && isASCIILower(s[i+1]):
// Skip over '.' in ".{{lowercase}}".
case c == '.':
b = append(b, '_') // convert '.' to '_'
case c == '_' && (i == 0 || s[i-1] == '.'):
// Convert initial '_' to ensure we start with a capital letter.
// Do the same for '_' after '.' to match historic behavior.
b = append(b, 'X') // convert '_' to 'X'
case c == '_' && i+1 < len(s) && isASCIILower(s[i+1]):
// Skip over '_' in "_{{lowercase}}".
case isASCIIDigit(c):
b = append(b, c)
default:
// Assume we have a letter now - if not, it's a bogus identifier.
// The next word is a sequence of characters that must start upper case.
if isASCIILower(c) {
c -= 'a' - 'A' // convert lowercase to uppercase
}
b = append(b, c)

// Accept lower case sequence that follows.
for ; i+1 < len(s) && isASCIILower(s[i+1]); i++ {
b = append(b, s[i+1])
}
result += strings.ToUpper(string(c))
} else if '0' <= p && p <= '9' {
// Previous character was digit.
result += strings.ToUpper(string(c))
} else {
result += string(c)
}
}
return result
return string(b)
}

func isASCIILower(c byte) bool {
return 'a' <= c && c <= 'z'
}

func isASCIIDigit(c byte) bool {
return '0' <= c && c <= '9'
}

// TitleToSnakeCase takes in a TitleCase string and returns a snake_case string.
Expand Down
9 changes: 4 additions & 5 deletions python/proto/vertexai/alpha/endpoint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ message VertexaiAlphaEndpointDeployedModels {
string display_name = 6;
string create_time = 7;
string service_account = 8;
bool disable_container_logging = 9;
bool enable_access_logging = 10;
VertexaiAlphaEndpointDeployedModelsPrivateEndpoints private_endpoints = 11;
string shared_resources = 12;
bool enable_container_logging = 13;
bool enable_access_logging = 9;
VertexaiAlphaEndpointDeployedModelsPrivateEndpoints private_endpoints = 10;
string shared_resources = 11;
bool enable_container_logging = 12;
}

message VertexaiAlphaEndpointDeployedModelsDedicatedResources {
Expand Down
9 changes: 4 additions & 5 deletions python/proto/vertexai/beta/endpoint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ message VertexaiBetaEndpointDeployedModels {
string display_name = 6;
string create_time = 7;
string service_account = 8;
bool disable_container_logging = 9;
bool enable_access_logging = 10;
VertexaiBetaEndpointDeployedModelsPrivateEndpoints private_endpoints = 11;
string shared_resources = 12;
bool enable_container_logging = 13;
bool enable_access_logging = 9;
VertexaiBetaEndpointDeployedModelsPrivateEndpoints private_endpoints = 10;
string shared_resources = 11;
bool enable_container_logging = 12;
}

message VertexaiBetaEndpointDeployedModelsDedicatedResources {
Expand Down
5 changes: 2 additions & 3 deletions python/proto/vertexai/endpoint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ message VertexaiEndpointDeployedModels {
string display_name = 6;
string create_time = 7;
string service_account = 8;
bool disable_container_logging = 9;
bool enable_access_logging = 10;
VertexaiEndpointDeployedModelsPrivateEndpoints private_endpoints = 11;
bool enable_access_logging = 9;
VertexaiEndpointDeployedModelsPrivateEndpoints private_endpoints = 10;
}

message VertexaiEndpointDeployedModelsDedicatedResources {
Expand Down
9 changes: 0 additions & 9 deletions python/services/vertexai/alpha/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def __init__(
display_name: str = None,
create_time: str = None,
service_account: str = None,
disable_container_logging: bool = None,
enable_access_logging: bool = None,
private_endpoints: dict = None,
shared_resources: str = None,
Expand All @@ -195,7 +194,6 @@ def __init__(
self.display_name = display_name
self.create_time = create_time
self.service_account = service_account
self.disable_container_logging = disable_container_logging
self.enable_access_logging = enable_access_logging
self.private_endpoints = private_endpoints
self.shared_resources = shared_resources
Expand Down Expand Up @@ -239,10 +237,6 @@ def to_proto(self, resource):
res.create_time = Primitive.to_proto(resource.create_time)
if Primitive.to_proto(resource.service_account):
res.service_account = Primitive.to_proto(resource.service_account)
if Primitive.to_proto(resource.disable_container_logging):
res.disable_container_logging = Primitive.to_proto(
resource.disable_container_logging
)
if Primitive.to_proto(resource.enable_access_logging):
res.enable_access_logging = Primitive.to_proto(
resource.enable_access_logging
Expand Down Expand Up @@ -281,9 +275,6 @@ def from_proto(self, resource):
display_name=Primitive.from_proto(resource.display_name),
create_time=Primitive.from_proto(resource.create_time),
service_account=Primitive.from_proto(resource.service_account),
disable_container_logging=Primitive.from_proto(
resource.disable_container_logging
),
enable_access_logging=Primitive.from_proto(resource.enable_access_logging),
private_endpoints=EndpointDeployedModelsPrivateEndpoints.from_proto(
resource.private_endpoints
Expand Down
26 changes: 12 additions & 14 deletions python/services/vertexai/alpha/endpoint_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,18 @@ func ProtoToVertexaiAlphaEndpointDeployedModels(p *alphapb.VertexaiAlphaEndpoint
return nil
}
obj := &alpha.EndpointDeployedModels{
DedicatedResources: ProtoToVertexaiAlphaEndpointDeployedModelsDedicatedResources(p.GetDedicatedResources()),
AutomaticResources: ProtoToVertexaiAlphaEndpointDeployedModelsAutomaticResources(p.GetAutomaticResources()),
Id: dcl.StringOrNil(p.GetId()),
Model: dcl.StringOrNil(p.GetModel()),
ModelVersionId: dcl.StringOrNil(p.GetModelVersionId()),
DisplayName: dcl.StringOrNil(p.GetDisplayName()),
CreateTime: dcl.StringOrNil(p.GetCreateTime()),
ServiceAccount: dcl.StringOrNil(p.GetServiceAccount()),
DisableContainerLogging: dcl.Bool(p.GetDisableContainerLogging()),
EnableAccessLogging: dcl.Bool(p.GetEnableAccessLogging()),
PrivateEndpoints: ProtoToVertexaiAlphaEndpointDeployedModelsPrivateEndpoints(p.GetPrivateEndpoints()),
SharedResources: dcl.StringOrNil(p.GetSharedResources()),
EnableContainerLogging: dcl.Bool(p.GetEnableContainerLogging()),
DedicatedResources: ProtoToVertexaiAlphaEndpointDeployedModelsDedicatedResources(p.GetDedicatedResources()),
AutomaticResources: ProtoToVertexaiAlphaEndpointDeployedModelsAutomaticResources(p.GetAutomaticResources()),
Id: dcl.StringOrNil(p.GetId()),
Model: dcl.StringOrNil(p.GetModel()),
ModelVersionId: dcl.StringOrNil(p.GetModelVersionId()),
DisplayName: dcl.StringOrNil(p.GetDisplayName()),
CreateTime: dcl.StringOrNil(p.GetCreateTime()),
ServiceAccount: dcl.StringOrNil(p.GetServiceAccount()),
EnableAccessLogging: dcl.Bool(p.GetEnableAccessLogging()),
PrivateEndpoints: ProtoToVertexaiAlphaEndpointDeployedModelsPrivateEndpoints(p.GetPrivateEndpoints()),
SharedResources: dcl.StringOrNil(p.GetSharedResources()),
EnableContainerLogging: dcl.Bool(p.GetEnableContainerLogging()),
}
return obj
}
Expand Down Expand Up @@ -183,7 +182,6 @@ func VertexaiAlphaEndpointDeployedModelsToProto(o *alpha.EndpointDeployedModels)
p.SetDisplayName(dcl.ValueOrEmptyString(o.DisplayName))
p.SetCreateTime(dcl.ValueOrEmptyString(o.CreateTime))
p.SetServiceAccount(dcl.ValueOrEmptyString(o.ServiceAccount))
p.SetDisableContainerLogging(dcl.ValueOrEmptyBool(o.DisableContainerLogging))
p.SetEnableAccessLogging(dcl.ValueOrEmptyBool(o.EnableAccessLogging))
p.SetPrivateEndpoints(VertexaiAlphaEndpointDeployedModelsPrivateEndpointsToProto(o.PrivateEndpoints))
p.SetSharedResources(dcl.ValueOrEmptyString(o.SharedResources))
Expand Down
9 changes: 0 additions & 9 deletions python/services/vertexai/beta/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def __init__(
display_name: str = None,
create_time: str = None,
service_account: str = None,
disable_container_logging: bool = None,
enable_access_logging: bool = None,
private_endpoints: dict = None,
shared_resources: str = None,
Expand All @@ -195,7 +194,6 @@ def __init__(
self.display_name = display_name
self.create_time = create_time
self.service_account = service_account
self.disable_container_logging = disable_container_logging
self.enable_access_logging = enable_access_logging
self.private_endpoints = private_endpoints
self.shared_resources = shared_resources
Expand Down Expand Up @@ -239,10 +237,6 @@ def to_proto(self, resource):
res.create_time = Primitive.to_proto(resource.create_time)
if Primitive.to_proto(resource.service_account):
res.service_account = Primitive.to_proto(resource.service_account)
if Primitive.to_proto(resource.disable_container_logging):
res.disable_container_logging = Primitive.to_proto(
resource.disable_container_logging
)
if Primitive.to_proto(resource.enable_access_logging):
res.enable_access_logging = Primitive.to_proto(
resource.enable_access_logging
Expand Down Expand Up @@ -281,9 +275,6 @@ def from_proto(self, resource):
display_name=Primitive.from_proto(resource.display_name),
create_time=Primitive.from_proto(resource.create_time),
service_account=Primitive.from_proto(resource.service_account),
disable_container_logging=Primitive.from_proto(
resource.disable_container_logging
),
enable_access_logging=Primitive.from_proto(resource.enable_access_logging),
private_endpoints=EndpointDeployedModelsPrivateEndpoints.from_proto(
resource.private_endpoints
Expand Down
26 changes: 12 additions & 14 deletions python/services/vertexai/beta/endpoint_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,18 @@ func ProtoToVertexaiBetaEndpointDeployedModels(p *betapb.VertexaiBetaEndpointDep
return nil
}
obj := &beta.EndpointDeployedModels{
DedicatedResources: ProtoToVertexaiBetaEndpointDeployedModelsDedicatedResources(p.GetDedicatedResources()),
AutomaticResources: ProtoToVertexaiBetaEndpointDeployedModelsAutomaticResources(p.GetAutomaticResources()),
Id: dcl.StringOrNil(p.GetId()),
Model: dcl.StringOrNil(p.GetModel()),
ModelVersionId: dcl.StringOrNil(p.GetModelVersionId()),
DisplayName: dcl.StringOrNil(p.GetDisplayName()),
CreateTime: dcl.StringOrNil(p.GetCreateTime()),
ServiceAccount: dcl.StringOrNil(p.GetServiceAccount()),
DisableContainerLogging: dcl.Bool(p.GetDisableContainerLogging()),
EnableAccessLogging: dcl.Bool(p.GetEnableAccessLogging()),
PrivateEndpoints: ProtoToVertexaiBetaEndpointDeployedModelsPrivateEndpoints(p.GetPrivateEndpoints()),
SharedResources: dcl.StringOrNil(p.GetSharedResources()),
EnableContainerLogging: dcl.Bool(p.GetEnableContainerLogging()),
DedicatedResources: ProtoToVertexaiBetaEndpointDeployedModelsDedicatedResources(p.GetDedicatedResources()),
AutomaticResources: ProtoToVertexaiBetaEndpointDeployedModelsAutomaticResources(p.GetAutomaticResources()),
Id: dcl.StringOrNil(p.GetId()),
Model: dcl.StringOrNil(p.GetModel()),
ModelVersionId: dcl.StringOrNil(p.GetModelVersionId()),
DisplayName: dcl.StringOrNil(p.GetDisplayName()),
CreateTime: dcl.StringOrNil(p.GetCreateTime()),
ServiceAccount: dcl.StringOrNil(p.GetServiceAccount()),
EnableAccessLogging: dcl.Bool(p.GetEnableAccessLogging()),
PrivateEndpoints: ProtoToVertexaiBetaEndpointDeployedModelsPrivateEndpoints(p.GetPrivateEndpoints()),
SharedResources: dcl.StringOrNil(p.GetSharedResources()),
EnableContainerLogging: dcl.Bool(p.GetEnableContainerLogging()),
}
return obj
}
Expand Down Expand Up @@ -183,7 +182,6 @@ func VertexaiBetaEndpointDeployedModelsToProto(o *beta.EndpointDeployedModels) *
p.SetDisplayName(dcl.ValueOrEmptyString(o.DisplayName))
p.SetCreateTime(dcl.ValueOrEmptyString(o.CreateTime))
p.SetServiceAccount(dcl.ValueOrEmptyString(o.ServiceAccount))
p.SetDisableContainerLogging(dcl.ValueOrEmptyBool(o.DisableContainerLogging))
p.SetEnableAccessLogging(dcl.ValueOrEmptyBool(o.EnableAccessLogging))
p.SetPrivateEndpoints(VertexaiBetaEndpointDeployedModelsPrivateEndpointsToProto(o.PrivateEndpoints))
p.SetSharedResources(dcl.ValueOrEmptyString(o.SharedResources))
Expand Down
9 changes: 0 additions & 9 deletions python/services/vertexai/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def __init__(
display_name: str = None,
create_time: str = None,
service_account: str = None,
disable_container_logging: bool = None,
enable_access_logging: bool = None,
private_endpoints: dict = None,
):
Expand All @@ -193,7 +192,6 @@ def __init__(
self.display_name = display_name
self.create_time = create_time
self.service_account = service_account
self.disable_container_logging = disable_container_logging
self.enable_access_logging = enable_access_logging
self.private_endpoints = private_endpoints

Expand Down Expand Up @@ -235,10 +233,6 @@ def to_proto(self, resource):
res.create_time = Primitive.to_proto(resource.create_time)
if Primitive.to_proto(resource.service_account):
res.service_account = Primitive.to_proto(resource.service_account)
if Primitive.to_proto(resource.disable_container_logging):
res.disable_container_logging = Primitive.to_proto(
resource.disable_container_logging
)
if Primitive.to_proto(resource.enable_access_logging):
res.enable_access_logging = Primitive.to_proto(
resource.enable_access_logging
Expand Down Expand Up @@ -271,9 +265,6 @@ def from_proto(self, resource):
display_name=Primitive.from_proto(resource.display_name),
create_time=Primitive.from_proto(resource.create_time),
service_account=Primitive.from_proto(resource.service_account),
disable_container_logging=Primitive.from_proto(
resource.disable_container_logging
),
enable_access_logging=Primitive.from_proto(resource.enable_access_logging),
private_endpoints=EndpointDeployedModelsPrivateEndpoints.from_proto(
resource.private_endpoints
Expand Down
22 changes: 10 additions & 12 deletions python/services/vertexai/endpoint_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,16 @@ func ProtoToVertexaiEndpointDeployedModels(p *vertexaipb.VertexaiEndpointDeploye
return nil
}
obj := &vertexai.EndpointDeployedModels{
DedicatedResources: ProtoToVertexaiEndpointDeployedModelsDedicatedResources(p.GetDedicatedResources()),
AutomaticResources: ProtoToVertexaiEndpointDeployedModelsAutomaticResources(p.GetAutomaticResources()),
Id: dcl.StringOrNil(p.GetId()),
Model: dcl.StringOrNil(p.GetModel()),
ModelVersionId: dcl.StringOrNil(p.GetModelVersionId()),
DisplayName: dcl.StringOrNil(p.GetDisplayName()),
CreateTime: dcl.StringOrNil(p.GetCreateTime()),
ServiceAccount: dcl.StringOrNil(p.GetServiceAccount()),
DisableContainerLogging: dcl.Bool(p.GetDisableContainerLogging()),
EnableAccessLogging: dcl.Bool(p.GetEnableAccessLogging()),
PrivateEndpoints: ProtoToVertexaiEndpointDeployedModelsPrivateEndpoints(p.GetPrivateEndpoints()),
DedicatedResources: ProtoToVertexaiEndpointDeployedModelsDedicatedResources(p.GetDedicatedResources()),
AutomaticResources: ProtoToVertexaiEndpointDeployedModelsAutomaticResources(p.GetAutomaticResources()),
Id: dcl.StringOrNil(p.GetId()),
Model: dcl.StringOrNil(p.GetModel()),
ModelVersionId: dcl.StringOrNil(p.GetModelVersionId()),
DisplayName: dcl.StringOrNil(p.GetDisplayName()),
CreateTime: dcl.StringOrNil(p.GetCreateTime()),
ServiceAccount: dcl.StringOrNil(p.GetServiceAccount()),
EnableAccessLogging: dcl.Bool(p.GetEnableAccessLogging()),
PrivateEndpoints: ProtoToVertexaiEndpointDeployedModelsPrivateEndpoints(p.GetPrivateEndpoints()),
}
return obj
}
Expand Down Expand Up @@ -181,7 +180,6 @@ func VertexaiEndpointDeployedModelsToProto(o *vertexai.EndpointDeployedModels) *
p.SetDisplayName(dcl.ValueOrEmptyString(o.DisplayName))
p.SetCreateTime(dcl.ValueOrEmptyString(o.CreateTime))
p.SetServiceAccount(dcl.ValueOrEmptyString(o.ServiceAccount))
p.SetDisableContainerLogging(dcl.ValueOrEmptyBool(o.DisableContainerLogging))
p.SetEnableAccessLogging(dcl.ValueOrEmptyBool(o.EnableAccessLogging))
p.SetPrivateEndpoints(VertexaiEndpointDeployedModelsPrivateEndpointsToProto(o.PrivateEndpoints))
return p
Expand Down
Loading

0 comments on commit 094a3cb

Please sign in to comment.