# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: config.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.text_format import Merge
try:
    from fileio.src import get_pathlike
except:
    from fileio import get_pathlike

from ._base import TFSModelConfig, TFSModelVersion, List,  Union, Optional, Any, Dict
from ._base import dataclass, lazyclass
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()


from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2


DESCRIPTOR = _descriptor.FileDescriptor(
  name='config.proto',
  package='serving_config',
  syntax='proto3',
  serialized_options=None,
  create_key=_descriptor._internal_create_key,
  serialized_pb=b'\n\x0c\x63onfig.proto\x12\x0eserving_config\x1a\x19google/protobuf/any.proto\"\xa6\x06\n!FileSystemStoragePathSourceConfig\x12V\n\tservables\x18\x05 \x03(\x0b\x32\x43.serving_config.FileSystemStoragePathSourceConfig.ServableToMonitor\x12\x19\n\rservable_name\x18\x01 \x01(\tB\x02\x18\x01\x12\x15\n\tbase_path\x18\x02 \x01(\tB\x02\x18\x01\x12%\n\x1d\x66ile_system_poll_wait_seconds\x18\x03 \x01(\x03\x12,\n fail_if_zero_versions_at_startup\x18\x04 \x01(\x08\x42\x02\x18\x01\x12(\n servable_versions_always_present\x18\x06 \x01(\x08\x1a\x91\x03\n\x15ServableVersionPolicy\x12`\n\x06latest\x18\x64 \x01(\x0b\x32N.serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.LatestH\x00\x12Z\n\x03\x61ll\x18\x65 \x01(\x0b\x32K.serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.AllH\x00\x12\x64\n\x08specific\x18\x66 \x01(\x0b\x32P.serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.SpecificH\x00\x1a\x1e\n\x06Latest\x12\x14\n\x0cnum_versions\x18\x01 \x01(\r\x1a\x05\n\x03\x41ll\x1a\x1c\n\x08Specific\x12\x10\n\x08versions\x18\x01 \x03(\x03\x42\x0f\n\rpolicy_choice\x1a\x64\n\x11ServableToMonitor\x12\x15\n\rservable_name\x18\x01 \x01(\t\x12\x11\n\tbase_path\x18\x02 \x01(\t\x12\x1f\n\x17servable_version_policy\x18\x04 \x01(\tJ\x04\x08\x03\x10\x04\"\xea\x02\n\x0bModelConfig\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tbase_path\x18\x02 \x01(\t\x12\x31\n\nmodel_type\x18\x03 \x01(\x0e\x32\x19.serving_config.ModelTypeB\x02\x18\x01\x12\x16\n\x0emodel_platform\x18\x04 \x01(\t\x12\x65\n\x14model_version_policy\x18\x07 \x01(\x0b\x32G.serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy\x12\x46\n\x0eversion_labels\x18\x08 \x03(\x0b\x32..serving_config.ModelConfig.VersionLabelsEntry\x1a\x34\n\x12VersionLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x03:\x02\x38\x01J\x04\x08\x05\x10\x06J\x04\x08\t\x10\n\">\n\x0fModelConfigList\x12+\n\x06\x63onfig\x18\x01 \x03(\x0b\x32\x1b.serving_config.ModelConfig\"\x90\x01\n\x11ModelServerConfig\x12<\n\x11model_config_list\x18\x01 \x01(\x0b\x32\x1f.serving_config.ModelConfigListH\x00\x12\x33\n\x13\x63ustom_model_config\x18\x02 \x01(\x0b\x32\x14.google.protobuf.AnyH\x00\x42\x08\n\x06\x63onfig*N\n\tModelType\x12\x1e\n\x16MODEL_TYPE_UNSPECIFIED\x10\x00\x1a\x02\x08\x01\x12\x12\n\nTENSORFLOW\x10\x01\x1a\x02\x08\x01\x12\r\n\x05OTHER\x10\x02\x1a\x02\x08\x01\x62\x06proto3'
  ,
  dependencies=[google_dot_protobuf_dot_any__pb2.DESCRIPTOR,])

_MODELTYPE = _descriptor.EnumDescriptor(
  name='ModelType',
  full_name='serving_config.ModelType',
  filename=None,
  file=DESCRIPTOR,
  create_key=_descriptor._internal_create_key,
  values=[
    _descriptor.EnumValueDescriptor(
      name='MODEL_TYPE_UNSPECIFIED', index=0, number=0,
      serialized_options=b'\010\001',
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='TENSORFLOW', index=1, number=1,
      serialized_options=b'\010\001',
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='OTHER', index=2, number=2,
      serialized_options=b'\010\001',
      type=None,
      create_key=_descriptor._internal_create_key),
  ],
  containing_type=None,
  serialized_options=None,
  serialized_start=1444,
  serialized_end=1522,
)
_sym_db.RegisterEnumDescriptor(_MODELTYPE)

ModelType = enum_type_wrapper.EnumTypeWrapper(_MODELTYPE)
MODEL_TYPE_UNSPECIFIED = 0
TENSORFLOW = 1
OTHER = 2



_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_LATEST = _descriptor.Descriptor(
  name='Latest',
  full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.Latest',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='num_versions', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.Latest.num_versions', index=0,
      number=1, type=13, cpp_type=3, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=680,
  serialized_end=710,
)

_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_ALL = _descriptor.Descriptor(
  name='All',
  full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.All',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=712,
  serialized_end=717,
)

_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_SPECIFIC = _descriptor.Descriptor(
  name='Specific',
  full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.Specific',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='versions', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.Specific.versions', index=0,
      number=1, type=3, cpp_type=2, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=719,
  serialized_end=747,
)

_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY = _descriptor.Descriptor(
  name='ServableVersionPolicy',
  full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='latest', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.latest', index=0,
      number=100, type=11, cpp_type=10, label=1,
      has_default_value=False, default_value=None,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='all', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.all', index=1,
      number=101, type=11, cpp_type=10, label=1,
      has_default_value=False, default_value=None,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='specific', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.specific', index=2,
      number=102, type=11, cpp_type=10, label=1,
      has_default_value=False, default_value=None,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_LATEST, _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_ALL, _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_SPECIFIC, ],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
    _descriptor.OneofDescriptor(
      name='policy_choice', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.policy_choice',
      index=0, containing_type=None,
      create_key=_descriptor._internal_create_key,
    fields=[]),
  ],
  serialized_start=363,
  serialized_end=764,
)

_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLETOMONITOR = _descriptor.Descriptor(
  name='ServableToMonitor',
  full_name='serving_config.FileSystemStoragePathSourceConfig.ServableToMonitor',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='servable_name', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableToMonitor.servable_name', index=0,
      number=1, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='base_path', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableToMonitor.base_path', index=1,
      number=2, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='servable_version_policy', full_name='serving_config.FileSystemStoragePathSourceConfig.ServableToMonitor.servable_version_policy', index=2,
      number=4, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=766,
  serialized_end=866,
)

_FILESYSTEMSTORAGEPATHSOURCECONFIG = _descriptor.Descriptor(
  name='FileSystemStoragePathSourceConfig',
  full_name='serving_config.FileSystemStoragePathSourceConfig',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='servables', full_name='serving_config.FileSystemStoragePathSourceConfig.servables', index=0,
      number=5, type=11, cpp_type=10, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='servable_name', full_name='serving_config.FileSystemStoragePathSourceConfig.servable_name', index=1,
      number=1, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=b'\030\001', file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='base_path', full_name='serving_config.FileSystemStoragePathSourceConfig.base_path', index=2,
      number=2, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=b'\030\001', file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='file_system_poll_wait_seconds', full_name='serving_config.FileSystemStoragePathSourceConfig.file_system_poll_wait_seconds', index=3,
      number=3, type=3, cpp_type=2, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='fail_if_zero_versions_at_startup', full_name='serving_config.FileSystemStoragePathSourceConfig.fail_if_zero_versions_at_startup', index=4,
      number=4, type=8, cpp_type=7, label=1,
      has_default_value=False, default_value=False,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=b'\030\001', file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='servable_versions_always_present', full_name='serving_config.FileSystemStoragePathSourceConfig.servable_versions_always_present', index=5,
      number=6, type=8, cpp_type=7, label=1,
      has_default_value=False, default_value=False,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY, _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLETOMONITOR, ],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=60,
  serialized_end=866,
)


_MODELCONFIG_VERSIONLABELSENTRY = _descriptor.Descriptor(
  name='VersionLabelsEntry',
  full_name='serving_config.ModelConfig.VersionLabelsEntry',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='key', full_name='serving_config.ModelConfig.VersionLabelsEntry.key', index=0,
      number=1, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='value', full_name='serving_config.ModelConfig.VersionLabelsEntry.value', index=1,
      number=2, type=3, cpp_type=2, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  serialized_options=b'8\001',
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=1167,
  serialized_end=1219,
)

_MODELCONFIG = _descriptor.Descriptor(
  name='ModelConfig',
  full_name='serving_config.ModelConfig',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='name', full_name='serving_config.ModelConfig.name', index=0,
      number=1, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='base_path', full_name='serving_config.ModelConfig.base_path', index=1,
      number=2, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='model_type', full_name='serving_config.ModelConfig.model_type', index=2,
      number=3, type=14, cpp_type=8, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=b'\030\001', file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='model_platform', full_name='serving_config.ModelConfig.model_platform', index=3,
      number=4, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=b"".decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='model_version_policy', full_name='serving_config.ModelConfig.model_version_policy', index=4,
      number=7, type=11, cpp_type=10, label=1,
      has_default_value=False, default_value=None,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='version_labels', full_name='serving_config.ModelConfig.version_labels', index=5,
      number=8, type=11, cpp_type=10, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[_MODELCONFIG_VERSIONLABELSENTRY, ],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=869,
  serialized_end=1231,
)


_MODELCONFIGLIST = _descriptor.Descriptor(
  name='ModelConfigList',
  full_name='serving_config.ModelConfigList',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='config', full_name='serving_config.ModelConfigList.config', index=0,
      number=1, type=11, cpp_type=10, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=1233,
  serialized_end=1295,
)


_MODELSERVERCONFIG = _descriptor.Descriptor(
  name='ModelServerConfig',
  full_name='serving_config.ModelServerConfig',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='model_config_list', full_name='serving_config.ModelServerConfig.model_config_list', index=0,
      number=1, type=11, cpp_type=10, label=1,
      has_default_value=False, default_value=None,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='custom_model_config', full_name='serving_config.ModelServerConfig.custom_model_config', index=1,
      number=2, type=11, cpp_type=10, label=1,
      has_default_value=False, default_value=None,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto3',
  extension_ranges=[],
  oneofs=[
    _descriptor.OneofDescriptor(
      name='config', full_name='serving_config.ModelServerConfig.config',
      index=0, containing_type=None,
      create_key=_descriptor._internal_create_key,
    fields=[]),
  ],
  serialized_start=1298,
  serialized_end=1442,
)

_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_LATEST.containing_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_ALL.containing_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_SPECIFIC.containing_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['latest'].message_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_LATEST
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['all'].message_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_ALL
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['specific'].message_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_SPECIFIC
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.containing_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.oneofs_by_name['policy_choice'].fields.append(
  _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['latest'])
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['latest'].containing_oneof = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.oneofs_by_name['policy_choice']
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.oneofs_by_name['policy_choice'].fields.append(
  _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['all'])
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['all'].containing_oneof = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.oneofs_by_name['policy_choice']
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.oneofs_by_name['policy_choice'].fields.append(
  _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['specific'])
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.fields_by_name['specific'].containing_oneof = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY.oneofs_by_name['policy_choice']
_FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLETOMONITOR.containing_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG
_FILESYSTEMSTORAGEPATHSOURCECONFIG.fields_by_name['servables'].message_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLETOMONITOR
_MODELCONFIG_VERSIONLABELSENTRY.containing_type = _MODELCONFIG
_MODELCONFIG.fields_by_name['model_type'].enum_type = _MODELTYPE
_MODELCONFIG.fields_by_name['model_version_policy'].message_type = _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY
_MODELCONFIG.fields_by_name['version_labels'].message_type = _MODELCONFIG_VERSIONLABELSENTRY
_MODELCONFIGLIST.fields_by_name['config'].message_type = _MODELCONFIG
_MODELSERVERCONFIG.fields_by_name['model_config_list'].message_type = _MODELCONFIGLIST
_MODELSERVERCONFIG.fields_by_name['custom_model_config'].message_type = google_dot_protobuf_dot_any__pb2._ANY
_MODELSERVERCONFIG.oneofs_by_name['config'].fields.append(
  _MODELSERVERCONFIG.fields_by_name['model_config_list'])
_MODELSERVERCONFIG.fields_by_name['model_config_list'].containing_oneof = _MODELSERVERCONFIG.oneofs_by_name['config']
_MODELSERVERCONFIG.oneofs_by_name['config'].fields.append(
  _MODELSERVERCONFIG.fields_by_name['custom_model_config'])
_MODELSERVERCONFIG.fields_by_name['custom_model_config'].containing_oneof = _MODELSERVERCONFIG.oneofs_by_name['config']
DESCRIPTOR.message_types_by_name['FileSystemStoragePathSourceConfig'] = _FILESYSTEMSTORAGEPATHSOURCECONFIG
DESCRIPTOR.message_types_by_name['ModelConfig'] = _MODELCONFIG
DESCRIPTOR.message_types_by_name['ModelConfigList'] = _MODELCONFIGLIST
DESCRIPTOR.message_types_by_name['ModelServerConfig'] = _MODELSERVERCONFIG
DESCRIPTOR.enum_types_by_name['ModelType'] = _MODELTYPE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)

FileSystemStoragePathSourceConfig = _reflection.GeneratedProtocolMessageType('FileSystemStoragePathSourceConfig', (_message.Message,), {

  'ServableVersionPolicy' : _reflection.GeneratedProtocolMessageType('ServableVersionPolicy', (_message.Message,), {

    'Latest' : _reflection.GeneratedProtocolMessageType('Latest', (_message.Message,), {
      'DESCRIPTOR' : _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_LATEST,
      '__module__' : 'config_pb2'
      # @@protoc_insertion_point(class_scope:serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.Latest)
      })
    ,

    'All' : _reflection.GeneratedProtocolMessageType('All', (_message.Message,), {
      'DESCRIPTOR' : _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_ALL,
      '__module__' : 'config_pb2'
      # @@protoc_insertion_point(class_scope:serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.All)
      })
    ,

    'Specific' : _reflection.GeneratedProtocolMessageType('Specific', (_message.Message,), {
      'DESCRIPTOR' : _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY_SPECIFIC,
      '__module__' : 'config_pb2'
      # @@protoc_insertion_point(class_scope:serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy.Specific)
      })
    ,
    'DESCRIPTOR' : _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLEVERSIONPOLICY,
    '__module__' : 'config_pb2'
    # @@protoc_insertion_point(class_scope:serving_config.FileSystemStoragePathSourceConfig.ServableVersionPolicy)
    })
  ,

  'ServableToMonitor' : _reflection.GeneratedProtocolMessageType('ServableToMonitor', (_message.Message,), {
    'DESCRIPTOR' : _FILESYSTEMSTORAGEPATHSOURCECONFIG_SERVABLETOMONITOR,
    '__module__' : 'config_pb2'
    # @@protoc_insertion_point(class_scope:serving_config.FileSystemStoragePathSourceConfig.ServableToMonitor)
    })
  ,
  'DESCRIPTOR' : _FILESYSTEMSTORAGEPATHSOURCECONFIG,
  '__module__' : 'config_pb2'
  # @@protoc_insertion_point(class_scope:serving_config.FileSystemStoragePathSourceConfig)
  })
_sym_db.RegisterMessage(FileSystemStoragePathSourceConfig)
_sym_db.RegisterMessage(FileSystemStoragePathSourceConfig.ServableVersionPolicy)
_sym_db.RegisterMessage(FileSystemStoragePathSourceConfig.ServableVersionPolicy.Latest)
_sym_db.RegisterMessage(FileSystemStoragePathSourceConfig.ServableVersionPolicy.All)
_sym_db.RegisterMessage(FileSystemStoragePathSourceConfig.ServableVersionPolicy.Specific)
_sym_db.RegisterMessage(FileSystemStoragePathSourceConfig.ServableToMonitor)

ModelConfig = _reflection.GeneratedProtocolMessageType('ModelConfig', (_message.Message,), {

  'VersionLabelsEntry' : _reflection.GeneratedProtocolMessageType('VersionLabelsEntry', (_message.Message,), {
    'DESCRIPTOR' : _MODELCONFIG_VERSIONLABELSENTRY,
    '__module__' : 'config_pb2'
    # @@protoc_insertion_point(class_scope:serving_config.ModelConfig.VersionLabelsEntry)
    })
  ,
  'DESCRIPTOR' : _MODELCONFIG,
  '__module__' : 'config_pb2'
  # @@protoc_insertion_point(class_scope:serving_config.ModelConfig)
  })
_sym_db.RegisterMessage(ModelConfig)
_sym_db.RegisterMessage(ModelConfig.VersionLabelsEntry)

ModelConfigList = _reflection.GeneratedProtocolMessageType('ModelConfigList', (_message.Message,), {
  'DESCRIPTOR' : _MODELCONFIGLIST,
  '__module__' : 'config_pb2'
  # @@protoc_insertion_point(class_scope:serving_config.ModelConfigList)
  })
_sym_db.RegisterMessage(ModelConfigList)

ModelServerConfig = _reflection.GeneratedProtocolMessageType('ModelServerConfig', (_message.Message,), {
  'DESCRIPTOR' : _MODELSERVERCONFIG,
  '__module__' : 'config_pb2'
  # @@protoc_insertion_point(class_scope:serving_config.ModelServerConfig)
  })
_sym_db.RegisterMessage(ModelServerConfig)


_MODELTYPE.values_by_name["MODEL_TYPE_UNSPECIFIED"]._options = None
_MODELTYPE.values_by_name["TENSORFLOW"]._options = None
_MODELTYPE.values_by_name["OTHER"]._options = None
_FILESYSTEMSTORAGEPATHSOURCECONFIG.fields_by_name['servable_name']._options = None
_FILESYSTEMSTORAGEPATHSOURCECONFIG.fields_by_name['base_path']._options = None
_FILESYSTEMSTORAGEPATHSOURCECONFIG.fields_by_name['fail_if_zero_versions_at_startup']._options = None
_MODELCONFIG_VERSIONLABELSENTRY._options = None
_MODELCONFIG.fields_by_name['model_type']._options = None
# @@protoc_insertion_point(module_scope)


class TFSConfig:

    @classmethod
    def from_model_configs(cls, model_configs: List[TFSModelConfig]) -> ModelServerConfig:
        serv_config = ModelServerConfig()
        model_config_list = serv_config.model_config_list
        for config in model_configs:
            model = model_config_list.config.add()
            model.name = config.name
            model.base_path = config.base_path
            model.model_platform = config.model_platform
            if config.model_versions:
                labels = model.version_labels
                policy = model.model_version_policy
                versions = policy.specific.versions
                for model_version in config.model_versions:
                    versions.append(model_version.step)
                    labels[model_version.label] = model_version.step
        return serv_config

    @classmethod
    def from_config_file(cls, filepath: str, as_obj: bool = True, **kwargs) -> Union[ModelServerConfig, List[TFSModelConfig]]:
        filepath = get_pathlike(filepath)
        assert filepath.exists()    
        serv_config = ModelServerConfig()
        serv_config = Merge(filepath.read_bytes(), serv_config)
        if not as_obj:
            return serv_config
    
        model_configs = []
        for model in serv_config.model_config_list.config:
            versions = [TFSModelVersion(step=v, label=k) for k,v in model.version_labels.items()]
            model_config = TFSModelConfig(name=model.name, base_path=model.base_path, model_platform=model.model_platform, model_versions=versions)
            model_configs.append(model_config)
        return model_configs
    
    @classmethod
    def from_protobuf(cls, filepath: str, as_obj: bool = True, **kwargs) -> Union[ModelServerConfig, List[TFSModelConfig]]:
        filepath = get_pathlike(filepath)
        assert filepath.exists()    
        serv_config = ModelServerConfig()
        serv_config.FromString(filepath.read_bytes())
        if not as_obj:
            return serv_config
        model_configs = []
        for model in serv_config.model_config_list.config:
            versions = [TFSModelVersion(step=v, label=k) for k,v in model.version_labels.items()]
            model_config = TFSModelConfig(name=model.name, base_path=model.base_path, model_platform=model.model_platform, model_versions=versions)
            model_configs.append(model_config)
        return model_configs


    @classmethod
    def from_dict(cls, configs: List[Dict[str, Any]], exclude=[], include=[], only_latest=False, return_tfconfig=False) -> Union[ModelServerConfig, List[TFSModelConfig]]:
        if exclude: configs = [c for c in configs if c.get('name', '') not in exclude]
        if include: configs = [c for c in configs if c.get('name', '') in include]
        model_configs = [ModelConfig.from_dict(config) for config in configs]
        if only_latest:
            for config in model_configs:
                config.set_only_latest()
        if not return_tfconfig:
            return model_configs
        return TFSConfig.from_model_configs(model_configs)
    
    @classmethod
    def to_config_file(cls, save_path: str, configs: List[Dict[str, Any]] = None, model_configs: Union[ModelServerConfig, List[TFSModelConfig]] = None, as_protobuf: bool = False, **kwargs):
        assert configs or model_configs, 'Configs or ModelConfigs must be provided'
        filepath = get_pathlike(save_path)
        srv_config = model_configs
        if configs:
            srv_config = TFSConfig.from_dict(configs, **kwargs)
        elif not isinstance(model_configs, ModelServerConfig):
            srv_config = TFSConfig.from_model_configs(model_configs, **kwargs)
        
        filepath.write_bytes(srv_config.SerializeToString()) if as_protobuf else filepath.write_text(str(srv_config))
        return {'config': srv_config, 'file': filepath}












