From 3b5d5d791e40b59e302b6c8d4ffe6f6e42a3ac13 Mon Sep 17 00:00:00 2001 From: Geoffrey Yu Date: Thu, 26 Sep 2024 13:55:06 -0400 Subject: [PATCH] Add new interface definitions (#514) --- config/vdbes/quickflix.yml | 50 +++++++++++++++++ proto/interface.proto | 20 +++++++ proto/interface/blueprint.proto | 43 +++++++++++++++ proto/interface/schema.proto | 26 +++++++++ proto/interface/vdbe.proto | 33 ++++++++++++ src/brad/proto_gen/interface/blueprint_pb2.py | 34 ++++++++++++ .../proto_gen/interface/blueprint_pb2.pyi | 54 +++++++++++++++++++ src/brad/proto_gen/interface/schema_pb2.py | 30 +++++++++++ src/brad/proto_gen/interface/schema_pb2.pyi | 36 +++++++++++++ src/brad/proto_gen/interface/vdbe_pb2.py | 30 +++++++++++ src/brad/proto_gen/interface/vdbe_pb2.pyi | 40 ++++++++++++++ src/brad/proto_gen/interface_pb2.py | 29 ++++++++++ src/brad/proto_gen/interface_pb2.pyi | 21 ++++++++ tools/generate_proto.sh | 14 +++++ 14 files changed, 460 insertions(+) create mode 100644 config/vdbes/quickflix.yml create mode 100644 proto/interface.proto create mode 100644 proto/interface/blueprint.proto create mode 100644 proto/interface/schema.proto create mode 100644 proto/interface/vdbe.proto create mode 100644 src/brad/proto_gen/interface/blueprint_pb2.py create mode 100644 src/brad/proto_gen/interface/blueprint_pb2.pyi create mode 100644 src/brad/proto_gen/interface/schema_pb2.py create mode 100644 src/brad/proto_gen/interface/schema_pb2.pyi create mode 100644 src/brad/proto_gen/interface/vdbe_pb2.py create mode 100644 src/brad/proto_gen/interface/vdbe_pb2.pyi create mode 100644 src/brad/proto_gen/interface_pb2.py create mode 100644 src/brad/proto_gen/interface_pb2.pyi diff --git a/config/vdbes/quickflix.yml b/config/vdbes/quickflix.yml new file mode 100644 index 00000000..0665247a --- /dev/null +++ b/config/vdbes/quickflix.yml @@ -0,0 +1,50 @@ +schema_name: quickflix + +vdbes: + - name: order_flow + tables: + - name: tickets + writable: true + - name: customers + writable: true + max_staleness_ms: 0 + query_interface: SQL_POSTGRESQL + + - name: transform + tables: + - name: tickets + - name: customers + - name: sales_history + writable: true + max_staleness_ms: 3600000 # 1 hour + query_interface: SQL_AWS_REDSHIFT + + - name: analysis + tables: + - name: sales_history + max_staleness_ms: 0 + query_interface: SQL_AWS_REDSHIFT + +tables: + - name: tickets + columns: + - name: t_customer_id + type: INT_64 + - name: t_movie_id + type: INT_64 + + - name: customers + columns: + - name: c_customer_id + type: INT_64 + - name: c_name + type: STRING + + - name: sales_history + columns: + - name: sh_customer_id + type: INT_64 + - name: sh_movie_id + type: INT_64 + - name: sh_name + type: STRING diff --git a/proto/interface.proto b/proto/interface.proto new file mode 100644 index 00000000..32705505 --- /dev/null +++ b/proto/interface.proto @@ -0,0 +1,20 @@ +// This file is the entrypoint for the virtual database engine (VDBE) interface +// definitions. We have split the definitions across multiple files to make them +// managable to read. + +syntax = "proto3"; + +package vdbe; + +import "interface/blueprint.proto"; +import "interface/schema.proto"; +import "interface/vdbe.proto"; + +// All the information needed to describe a data infrastructure deployment. +message SystemState { + // Used to uniquely identify the system state. + string schema_name = 1; + repeated Table tables = 2; + repeated VirtualEngine vdbes = 3; + Blueprint blueprint = 4; +} diff --git a/proto/interface/blueprint.proto b/proto/interface/blueprint.proto new file mode 100644 index 00000000..daa21835 --- /dev/null +++ b/proto/interface/blueprint.proto @@ -0,0 +1,43 @@ +// This file contains definitions for the blueprint (physical realization of a +// set of VDBEs). + +syntax = "proto3"; + +package vdbe; + +message Blueprint { + Provisioning aurora = 101; + Provisioning redshift = 102; + RoutingPolicy policy = 201; + repeated PhysicalSnapshot snapshots = 301; +} + +message RoutingPolicy { + // A serialized form of the routing policy. + bytes policy = 1; +} + +message PhysicalSnapshot { + // The VDBEs that are mapped to this physical snapshot. + repeated string vdbes = 1; + // The tables in this physical snapshot. + repeated string tables = 2; + // Where the data in this physical snapshot resides. + Engine location = 3; +} + +// Used to indicate the location of data. +enum Engine { + ENGINE_UNKNOWN = 0; + // The data is stored in Aurora. + ENGINE_AURORA = 1; + // The data is stored in Redshift. + ENGINE_REDSHIFT = 2; + // The data is stored on S3 in an Iceberg table and registered with Athena. + ENGINE_ATHENA = 3; +} + +message Provisioning { + string instance_type = 1; + uint32 num_nodes = 2; +} diff --git a/proto/interface/schema.proto b/proto/interface/schema.proto new file mode 100644 index 00000000..776d2ab9 --- /dev/null +++ b/proto/interface/schema.proto @@ -0,0 +1,26 @@ +// This file contains definitions for table schema information. + +syntax = "proto3"; + +package vdbe; + +// Represents a relational table. +message Table { + string name = 1; + repeated TableColumn columns = 2; +} + +// Represents a column in a relational table. +message TableColumn { + string name = 1; + DataType type = 2; + bool nullable = 3; +} + +// The data types we currently support. +enum DataType { + DT_UNKNOWN = 0; + DT_INT_32 = 1; + DT_INT_64 = 2; + DT_STRING = 3; +} diff --git a/proto/interface/vdbe.proto b/proto/interface/vdbe.proto new file mode 100644 index 00000000..eb6b4569 --- /dev/null +++ b/proto/interface/vdbe.proto @@ -0,0 +1,33 @@ +// This file contains definitions for virtual database engines (VDBEs). + +syntax = "proto3"; + +package vdbe; + +message VirtualEngine { + string name = 1; + QueryInterface qi = 2; + repeated VirtualTable tables = 3; + uint64 max_staleness_ms = 4; + // TODO: Meaningful representation for performance properties. + // TODO: Flag set for feature support. +} + +message VirtualTable { + // Name must reference a table that has a schema definition. + string name = 1; + bool writable = 2; +} + +// These are the query interfaces we currently support. +enum QueryInterface { + QI_UNKNOWN = 0; + + // 1xx - Open source SQL DBMSes. + QI_SQL_POSTGRESQL = 101; + QI_SQL_MYSQL = 102; + + // 2xx - AWS SQL DBMSes. + QI_SQL_AWS_REDSHIFT = 201; + QI_SQL_AWS_ATHENA = 202; +} diff --git a/src/brad/proto_gen/interface/blueprint_pb2.py b/src/brad/proto_gen/interface/blueprint_pb2.py new file mode 100644 index 00000000..b1037462 --- /dev/null +++ b/src/brad/proto_gen/interface/blueprint_pb2.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: interface/blueprint.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19interface/blueprint.proto\x12\x04vdbe\"\xa7\x01\n\tBlueprint\x12\"\n\x06\x61urora\x18\x65 \x01(\x0b\x32\x12.vdbe.Provisioning\x12$\n\x08redshift\x18\x66 \x01(\x0b\x32\x12.vdbe.Provisioning\x12$\n\x06policy\x18\xc9\x01 \x01(\x0b\x32\x13.vdbe.RoutingPolicy\x12*\n\tsnapshots\x18\xad\x02 \x03(\x0b\x32\x16.vdbe.PhysicalSnapshot\"\x1f\n\rRoutingPolicy\x12\x0e\n\x06policy\x18\x01 \x01(\x0c\"Q\n\x10PhysicalSnapshot\x12\r\n\x05vdbes\x18\x01 \x03(\t\x12\x0e\n\x06tables\x18\x02 \x03(\t\x12\x1e\n\x08location\x18\x03 \x01(\x0e\x32\x0c.vdbe.Engine\"8\n\x0cProvisioning\x12\x15\n\rinstance_type\x18\x01 \x01(\t\x12\x11\n\tnum_nodes\x18\x02 \x01(\r*W\n\x06\x45ngine\x12\x12\n\x0e\x45NGINE_UNKNOWN\x10\x00\x12\x11\n\rENGINE_AURORA\x10\x01\x12\x13\n\x0f\x45NGINE_REDSHIFT\x10\x02\x12\x11\n\rENGINE_ATHENA\x10\x03\x62\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'interface.blueprint_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_ENGINE']._serialized_start=379 + _globals['_ENGINE']._serialized_end=466 + _globals['_BLUEPRINT']._serialized_start=36 + _globals['_BLUEPRINT']._serialized_end=203 + _globals['_ROUTINGPOLICY']._serialized_start=205 + _globals['_ROUTINGPOLICY']._serialized_end=236 + _globals['_PHYSICALSNAPSHOT']._serialized_start=238 + _globals['_PHYSICALSNAPSHOT']._serialized_end=319 + _globals['_PROVISIONING']._serialized_start=321 + _globals['_PROVISIONING']._serialized_end=377 +# @@protoc_insertion_point(module_scope) diff --git a/src/brad/proto_gen/interface/blueprint_pb2.pyi b/src/brad/proto_gen/interface/blueprint_pb2.pyi new file mode 100644 index 00000000..975f3ef3 --- /dev/null +++ b/src/brad/proto_gen/interface/blueprint_pb2.pyi @@ -0,0 +1,54 @@ +from google.protobuf.internal import containers as _containers +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class Engine(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = [] # type: ignore + ENGINE_UNKNOWN: _ClassVar[Engine] + ENGINE_AURORA: _ClassVar[Engine] + ENGINE_REDSHIFT: _ClassVar[Engine] + ENGINE_ATHENA: _ClassVar[Engine] +ENGINE_UNKNOWN: Engine +ENGINE_AURORA: Engine +ENGINE_REDSHIFT: Engine +ENGINE_ATHENA: Engine + +class Blueprint(_message.Message): + __slots__ = ["aurora", "redshift", "policy", "snapshots"] + AURORA_FIELD_NUMBER: _ClassVar[int] + REDSHIFT_FIELD_NUMBER: _ClassVar[int] + POLICY_FIELD_NUMBER: _ClassVar[int] + SNAPSHOTS_FIELD_NUMBER: _ClassVar[int] + aurora: Provisioning + redshift: Provisioning + policy: RoutingPolicy + snapshots: _containers.RepeatedCompositeFieldContainer[PhysicalSnapshot] + def __init__(self, aurora: _Optional[_Union[Provisioning, _Mapping]] = ..., redshift: _Optional[_Union[Provisioning, _Mapping]] = ..., policy: _Optional[_Union[RoutingPolicy, _Mapping]] = ..., snapshots: _Optional[_Iterable[_Union[PhysicalSnapshot, _Mapping]]] = ...) -> None: ... + +class RoutingPolicy(_message.Message): + __slots__ = ["policy"] + POLICY_FIELD_NUMBER: _ClassVar[int] + policy: bytes + def __init__(self, policy: _Optional[bytes] = ...) -> None: ... + +class PhysicalSnapshot(_message.Message): + __slots__ = ["vdbes", "tables", "location"] + VDBES_FIELD_NUMBER: _ClassVar[int] + TABLES_FIELD_NUMBER: _ClassVar[int] + LOCATION_FIELD_NUMBER: _ClassVar[int] + vdbes: _containers.RepeatedScalarFieldContainer[str] + tables: _containers.RepeatedScalarFieldContainer[str] + location: Engine + def __init__(self, vdbes: _Optional[_Iterable[str]] = ..., tables: _Optional[_Iterable[str]] = ..., location: _Optional[_Union[Engine, str]] = ...) -> None: ... + +class Provisioning(_message.Message): + __slots__ = ["instance_type", "num_nodes"] + INSTANCE_TYPE_FIELD_NUMBER: _ClassVar[int] + NUM_NODES_FIELD_NUMBER: _ClassVar[int] + instance_type: str + num_nodes: int + def __init__(self, instance_type: _Optional[str] = ..., num_nodes: _Optional[int] = ...) -> None: ... diff --git a/src/brad/proto_gen/interface/schema_pb2.py b/src/brad/proto_gen/interface/schema_pb2.py new file mode 100644 index 00000000..3fe5a7ae --- /dev/null +++ b/src/brad/proto_gen/interface/schema_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: interface/schema.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16interface/schema.proto\x12\x04vdbe\"9\n\x05Table\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\"\n\x07\x63olumns\x18\x02 \x03(\x0b\x32\x11.vdbe.TableColumn\"K\n\x0bTableColumn\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1c\n\x04type\x18\x02 \x01(\x0e\x32\x0e.vdbe.DataType\x12\x10\n\x08nullable\x18\x03 \x01(\x08*G\n\x08\x44\x61taType\x12\x0e\n\nDT_UNKNOWN\x10\x00\x12\r\n\tDT_INT_32\x10\x01\x12\r\n\tDT_INT_64\x10\x02\x12\r\n\tDT_STRING\x10\x03\x62\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'interface.schema_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_DATATYPE']._serialized_start=168 + _globals['_DATATYPE']._serialized_end=239 + _globals['_TABLE']._serialized_start=32 + _globals['_TABLE']._serialized_end=89 + _globals['_TABLECOLUMN']._serialized_start=91 + _globals['_TABLECOLUMN']._serialized_end=166 +# @@protoc_insertion_point(module_scope) diff --git a/src/brad/proto_gen/interface/schema_pb2.pyi b/src/brad/proto_gen/interface/schema_pb2.pyi new file mode 100644 index 00000000..c125c7d3 --- /dev/null +++ b/src/brad/proto_gen/interface/schema_pb2.pyi @@ -0,0 +1,36 @@ +from google.protobuf.internal import containers as _containers +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class DataType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = [] # type: ignore + DT_UNKNOWN: _ClassVar[DataType] + DT_INT_32: _ClassVar[DataType] + DT_INT_64: _ClassVar[DataType] + DT_STRING: _ClassVar[DataType] +DT_UNKNOWN: DataType +DT_INT_32: DataType +DT_INT_64: DataType +DT_STRING: DataType + +class Table(_message.Message): + __slots__ = ["name", "columns"] + NAME_FIELD_NUMBER: _ClassVar[int] + COLUMNS_FIELD_NUMBER: _ClassVar[int] + name: str + columns: _containers.RepeatedCompositeFieldContainer[TableColumn] + def __init__(self, name: _Optional[str] = ..., columns: _Optional[_Iterable[_Union[TableColumn, _Mapping]]] = ...) -> None: ... + +class TableColumn(_message.Message): + __slots__ = ["name", "type", "nullable"] + NAME_FIELD_NUMBER: _ClassVar[int] + TYPE_FIELD_NUMBER: _ClassVar[int] + NULLABLE_FIELD_NUMBER: _ClassVar[int] + name: str + type: DataType + nullable: bool + def __init__(self, name: _Optional[str] = ..., type: _Optional[_Union[DataType, str]] = ..., nullable: bool = ...) -> None: ... diff --git a/src/brad/proto_gen/interface/vdbe_pb2.py b/src/brad/proto_gen/interface/vdbe_pb2.py new file mode 100644 index 00000000..173c2976 --- /dev/null +++ b/src/brad/proto_gen/interface/vdbe_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: interface/vdbe.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14interface/vdbe.proto\x12\x04vdbe\"}\n\rVirtualEngine\x12\x0c\n\x04name\x18\x01 \x01(\t\x12 \n\x02qi\x18\x02 \x01(\x0e\x32\x14.vdbe.QueryInterface\x12\"\n\x06tables\x18\x03 \x03(\x0b\x32\x12.vdbe.VirtualTable\x12\x18\n\x10max_staleness_ms\x18\x04 \x01(\x04\".\n\x0cVirtualTable\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x10\n\x08writable\x18\x02 \x01(\x08*{\n\x0eQueryInterface\x12\x0e\n\nQI_UNKNOWN\x10\x00\x12\x15\n\x11QI_SQL_POSTGRESQL\x10\x65\x12\x10\n\x0cQI_SQL_MYSQL\x10\x66\x12\x18\n\x13QI_SQL_AWS_REDSHIFT\x10\xc9\x01\x12\x16\n\x11QI_SQL_AWS_ATHENA\x10\xca\x01\x62\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'interface.vdbe_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_QUERYINTERFACE']._serialized_start=205 + _globals['_QUERYINTERFACE']._serialized_end=328 + _globals['_VIRTUALENGINE']._serialized_start=30 + _globals['_VIRTUALENGINE']._serialized_end=155 + _globals['_VIRTUALTABLE']._serialized_start=157 + _globals['_VIRTUALTABLE']._serialized_end=203 +# @@protoc_insertion_point(module_scope) diff --git a/src/brad/proto_gen/interface/vdbe_pb2.pyi b/src/brad/proto_gen/interface/vdbe_pb2.pyi new file mode 100644 index 00000000..01107ed6 --- /dev/null +++ b/src/brad/proto_gen/interface/vdbe_pb2.pyi @@ -0,0 +1,40 @@ +from google.protobuf.internal import containers as _containers +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class QueryInterface(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = [] # type: ignore + QI_UNKNOWN: _ClassVar[QueryInterface] + QI_SQL_POSTGRESQL: _ClassVar[QueryInterface] + QI_SQL_MYSQL: _ClassVar[QueryInterface] + QI_SQL_AWS_REDSHIFT: _ClassVar[QueryInterface] + QI_SQL_AWS_ATHENA: _ClassVar[QueryInterface] +QI_UNKNOWN: QueryInterface +QI_SQL_POSTGRESQL: QueryInterface +QI_SQL_MYSQL: QueryInterface +QI_SQL_AWS_REDSHIFT: QueryInterface +QI_SQL_AWS_ATHENA: QueryInterface + +class VirtualEngine(_message.Message): + __slots__ = ["name", "qi", "tables", "max_staleness_ms"] + NAME_FIELD_NUMBER: _ClassVar[int] + QI_FIELD_NUMBER: _ClassVar[int] + TABLES_FIELD_NUMBER: _ClassVar[int] + MAX_STALENESS_MS_FIELD_NUMBER: _ClassVar[int] + name: str + qi: QueryInterface + tables: _containers.RepeatedCompositeFieldContainer[VirtualTable] + max_staleness_ms: int + def __init__(self, name: _Optional[str] = ..., qi: _Optional[_Union[QueryInterface, str]] = ..., tables: _Optional[_Iterable[_Union[VirtualTable, _Mapping]]] = ..., max_staleness_ms: _Optional[int] = ...) -> None: ... + +class VirtualTable(_message.Message): + __slots__ = ["name", "writable"] + NAME_FIELD_NUMBER: _ClassVar[int] + WRITABLE_FIELD_NUMBER: _ClassVar[int] + name: str + writable: bool + def __init__(self, name: _Optional[str] = ..., writable: bool = ...) -> None: ... diff --git a/src/brad/proto_gen/interface_pb2.py b/src/brad/proto_gen/interface_pb2.py new file mode 100644 index 00000000..dbd1dac2 --- /dev/null +++ b/src/brad/proto_gen/interface_pb2.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: interface.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from brad.proto_gen.interface import blueprint_pb2 as interface_dot_blueprint__pb2 +from brad.proto_gen.interface import schema_pb2 as interface_dot_schema__pb2 +from brad.proto_gen.interface import vdbe_pb2 as interface_dot_vdbe__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0finterface.proto\x12\x04vdbe\x1a\x19interface/blueprint.proto\x1a\x16interface/schema.proto\x1a\x14interface/vdbe.proto\"\x87\x01\n\x0bSystemState\x12\x13\n\x0bschema_name\x18\x01 \x01(\t\x12\x1b\n\x06tables\x18\x02 \x03(\x0b\x32\x0b.vdbe.Table\x12\"\n\x05vdbes\x18\x03 \x03(\x0b\x32\x13.vdbe.VirtualEngine\x12\"\n\tblueprint\x18\x04 \x01(\x0b\x32\x0f.vdbe.Blueprintb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'interface_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_SYSTEMSTATE']._serialized_start=99 + _globals['_SYSTEMSTATE']._serialized_end=234 +# @@protoc_insertion_point(module_scope) diff --git a/src/brad/proto_gen/interface_pb2.pyi b/src/brad/proto_gen/interface_pb2.pyi new file mode 100644 index 00000000..05ca2629 --- /dev/null +++ b/src/brad/proto_gen/interface_pb2.pyi @@ -0,0 +1,21 @@ +from interface import blueprint_pb2 as _blueprint_pb2 +from interface import schema_pb2 as _schema_pb2 +from interface import vdbe_pb2 as _vdbe_pb2 +from google.protobuf.internal import containers as _containers +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class SystemState(_message.Message): + __slots__ = ["schema_name", "tables", "vdbes", "blueprint"] + SCHEMA_NAME_FIELD_NUMBER: _ClassVar[int] + TABLES_FIELD_NUMBER: _ClassVar[int] + VDBES_FIELD_NUMBER: _ClassVar[int] + BLUEPRINT_FIELD_NUMBER: _ClassVar[int] + schema_name: str + tables: _containers.RepeatedCompositeFieldContainer[_schema_pb2.Table] + vdbes: _containers.RepeatedCompositeFieldContainer[_vdbe_pb2.VirtualEngine] + blueprint: _blueprint_pb2.Blueprint + def __init__(self, schema_name: _Optional[str] = ..., tables: _Optional[_Iterable[_Union[_schema_pb2.Table, _Mapping]]] = ..., vdbes: _Optional[_Iterable[_Union[_vdbe_pb2.VirtualEngine, _Mapping]]] = ..., blueprint: _Optional[_Union[_blueprint_pb2.Blueprint, _Mapping]] = ...) -> None: ... diff --git a/tools/generate_proto.sh b/tools/generate_proto.sh index 0c32bc86..13211666 100755 --- a/tools/generate_proto.sh +++ b/tools/generate_proto.sh @@ -4,6 +4,20 @@ SCRIPT_PATH=$(cd $(dirname $0) && pwd -P) cd $SCRIPT_PATH source shared.sh +# NOTE: You need to manually add `# type: ignore` to the .pyi stubs, since the +# generated code causes an error in mypy's type check. +python3 -m grpc_tools.protoc \ + -I../proto \ + --python_out=../src/brad/proto_gen \ + --pyi_out=../src/brad/proto_gen \ + ../proto/interface.proto \ + ../proto/interface/blueprint.proto \ + ../proto/interface/schema.proto \ + ../proto/interface/vdbe.proto + +# Fix the import path. +sed -i -e "s/from interface import/from brad.proto_gen.interface import/g" ../src/brad/proto_gen/interface_pb2.py + python3 -m grpc_tools.protoc \ -I../proto \ --python_out=../src/brad/proto_gen \