diff --git a/Makefile b/Makefile index b860841..3c36da6 100755 --- a/Makefile +++ b/Makefile @@ -42,20 +42,8 @@ BUF_VERSION_URL := https://raw.githubusercontent.com/vdaas/vald/main/versions/BU SHADOW_ROOT = vald SHADOW_PROTO_ROOT = $(SHADOW_ROOT)/$(SHADOW_ROOT) -PROTOS = \ - v1/agent/core/agent.proto \ - v1/filter/egress/egress_filter.proto \ - v1/filter/ingress/ingress_filter.proto \ - v1/vald/filter.proto \ - v1/vald/insert.proto \ - v1/vald/object.proto \ - v1/vald/index.proto \ - v1/vald/remove.proto \ - v1/vald/search.proto \ - v1/vald/update.proto \ - v1/vald/upsert.proto \ - v1/payload/payload.proto -PROTOS := $(PROTOS:%=$(PROTO_ROOT)/%) +TARGET_PROTOS = agent/core filter payload rpc vald +PROTOS = $(foreach proto,$(TARGET_PROTOS),$(shell find $(PROTO_ROOT)/v1/$(proto) -name '*.proto')) SHADOWS = $(PROTOS:$(PROTO_ROOT)/%.proto=$(SHADOW_PROTO_ROOT)/%.proto) PB2PYS = $(PROTOS:$(PROTO_ROOT)/%.proto=$(PB2DIR_ROOT)/$(SHADOW_ROOT)/%_pb2.py) @@ -73,7 +61,7 @@ cyan = /bin/echo -e "\x1b[36m\#\# $1\x1b[0m" .PHONY: all ## execute clean and proto -all: clean proto +all: clean vald-origin proto .PHONY: help ## print all available commands @@ -210,4 +198,4 @@ sync/k3d/mk: Makefile.d rm -rf $(K3D_MAKEFILE) curl -fsSLo $(K3D_MAKEFILE) $(K3D_MAKEFILE_URL) -include $(K3D_MAKEFILE) +include $(K3D_MAKEFILE) \ No newline at end of file diff --git a/README.md b/README.md index f978f43..ffa1f3b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ from vald.v1.vald import insert_pb2_grpc from vald.v1.vald import search_pb2_grpc from vald.v1.vald import update_pb2_grpc from vald.v1.vald import remove_pb2_grpc +from vald.v1.vald import flush_pb2_grpc from vald.v1.payload import payload_pb2 ## create a channel by passing "{host}:{port}" @@ -34,6 +35,7 @@ istub = insert_pb2_grpc.InsertStub(channel) sstub = search_pb2_grpc.SearchStub(channel) ustub = update_pb2_grpc.UpdateStub(channel) rstub = remove_pb2_grpc.RemoveStub(channel) +fstub = flush_pb2_grpc.FlushStub(channel) ## call RPCs: Insert vec = payload_pb2.Object.Vector(id='vector_id_1', vector=[0.1, 0.2, 0.3]) @@ -59,6 +61,9 @@ rcfg = payload_pb2.Remove.Config(skip_strict_exist_check=True) rid = payload_pb2.Object.ID(id='vector_id_1') rstub.Remove(payload_pb2.Remove.Request(id=rid, config=rcfg)) +## call RPCs: Flush +fstub.Flush(payload_pb2.Flush.Request()) + ## close channel channel.close() ``` diff --git a/src/tests/test_e2e.py b/src/tests/test_e2e.py index bc44ca8..6b69c08 100644 --- a/src/tests/test_e2e.py +++ b/src/tests/test_e2e.py @@ -9,6 +9,7 @@ from vald.v1.vald import update_pb2_grpc from vald.v1.vald import upsert_pb2_grpc from vald.v1.vald import remove_pb2_grpc +from vald.v1.vald import flush_pb2_grpc from vald.v1.vald import object_pb2_grpc from vald.v1.vald import index_pb2_grpc from vald.v1.payload import payload_pb2 @@ -286,3 +287,9 @@ def test_stream_remove(self): for result in results: self.assertIsInstance(result, payload_pb2.Object.StreamLocation) self.assertEqual(result.status.code, 0) + + def test_flush(self): + stub = flush_pb2_grpc.FlushStub(self.channel) + request = payload_pb2.Flush.Request() + results = stub.Flush(request) + self.assertIsInstance(results, payload_pb2.Info.Index.Count) diff --git a/src/vald/v1/rpc/errdetails/error_details_pb2.py b/src/vald/v1/rpc/errdetails/error_details_pb2.py new file mode 100644 index 0000000..bf2832d --- /dev/null +++ b/src/vald/v1/rpc/errdetails/error_details_pb2.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: vald/v1/rpc/errdetails/error_details.proto +# Protobuf Python Version: 5.28.3 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 3, + '', + 'vald/v1/rpc/errdetails/error_details.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n*vald/v1/rpc/errdetails/error_details.proto\x12\x06rpc.v1\x1a\x1egoogle/protobuf/duration.proto\"\xb5\x01\n\tErrorInfo\x12\x16\n\x06reason\x18\x01 \x01(\tR\x06reason\x12\x16\n\x06\x64omain\x18\x02 \x01(\tR\x06\x64omain\x12;\n\x08metadata\x18\x03 \x03(\x0b\x32\x1f.rpc.v1.ErrorInfo.MetadataEntryR\x08metadata\x1a;\n\rMetadataEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\"G\n\tRetryInfo\x12:\n\x0bretry_delay\x18\x01 \x01(\x0b\x32\x19.google.protobuf.DurationR\nretryDelay\"H\n\tDebugInfo\x12#\n\rstack_entries\x18\x01 \x03(\tR\x0cstackEntries\x12\x16\n\x06\x64\x65tail\x18\x02 \x01(\tR\x06\x64\x65tail\"\x97\x01\n\x0cQuotaFailure\x12>\n\nviolations\x18\x01 \x03(\x0b\x32\x1e.rpc.v1.QuotaFailure.ViolationR\nviolations\x1aG\n\tViolation\x12\x18\n\x07subject\x18\x01 \x01(\tR\x07subject\x12 \n\x0b\x64\x65scription\x18\x02 \x01(\tR\x0b\x64\x65scription\"\xb9\x01\n\x13PreconditionFailure\x12\x45\n\nviolations\x18\x01 \x03(\x0b\x32%.rpc.v1.PreconditionFailure.ViolationR\nviolations\x1a[\n\tViolation\x12\x12\n\x04type\x18\x01 \x01(\tR\x04type\x12\x18\n\x07subject\x18\x02 \x01(\tR\x07subject\x12 \n\x0b\x64\x65scription\x18\x03 \x01(\tR\x0b\x64\x65scription\"\xa4\x01\n\nBadRequest\x12L\n\x10\x66ield_violations\x18\x01 \x03(\x0b\x32!.rpc.v1.BadRequest.FieldViolationR\x0f\x66ieldViolations\x1aH\n\x0e\x46ieldViolation\x12\x14\n\x05\x66ield\x18\x01 \x01(\tR\x05\x66ield\x12 \n\x0b\x64\x65scription\x18\x02 \x01(\tR\x0b\x64\x65scription\"O\n\x0bRequestInfo\x12\x1d\n\nrequest_id\x18\x01 \x01(\tR\trequestId\x12!\n\x0cserving_data\x18\x02 \x01(\tR\x0bservingData\"\x90\x01\n\x0cResourceInfo\x12#\n\rresource_type\x18\x01 \x01(\tR\x0cresourceType\x12#\n\rresource_name\x18\x02 \x01(\tR\x0cresourceName\x12\x14\n\x05owner\x18\x03 \x01(\tR\x05owner\x12 \n\x0b\x64\x65scription\x18\x04 \x01(\tR\x0b\x64\x65scription\"k\n\x04Help\x12\'\n\x05links\x18\x01 \x03(\x0b\x32\x11.rpc.v1.Help.LinkR\x05links\x1a:\n\x04Link\x12 \n\x0b\x64\x65scription\x18\x01 \x01(\tR\x0b\x64\x65scription\x12\x10\n\x03url\x18\x02 \x01(\tR\x03url\"D\n\x10LocalizedMessage\x12\x16\n\x06locale\x18\x01 \x01(\tR\x06locale\x12\x18\n\x07message\x18\x02 \x01(\tR\x07messageBi\n\x19org.vdaas.vald.api.v1.rpcB\x11\x45rrorDetailsProtoP\x01Z1github.com/vdaas/vald/apis/grpc/v1/rpc/errdetails\xa2\x02\x03RPCb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'vald.v1.rpc.errdetails.error_details_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\031org.vdaas.vald.api.v1.rpcB\021ErrorDetailsProtoP\001Z1github.com/vdaas/vald/apis/grpc/v1/rpc/errdetails\242\002\003RPC' + _globals['_ERRORINFO_METADATAENTRY']._loaded_options = None + _globals['_ERRORINFO_METADATAENTRY']._serialized_options = b'8\001' + _globals['_ERRORINFO']._serialized_start=87 + _globals['_ERRORINFO']._serialized_end=268 + _globals['_ERRORINFO_METADATAENTRY']._serialized_start=209 + _globals['_ERRORINFO_METADATAENTRY']._serialized_end=268 + _globals['_RETRYINFO']._serialized_start=270 + _globals['_RETRYINFO']._serialized_end=341 + _globals['_DEBUGINFO']._serialized_start=343 + _globals['_DEBUGINFO']._serialized_end=415 + _globals['_QUOTAFAILURE']._serialized_start=418 + _globals['_QUOTAFAILURE']._serialized_end=569 + _globals['_QUOTAFAILURE_VIOLATION']._serialized_start=498 + _globals['_QUOTAFAILURE_VIOLATION']._serialized_end=569 + _globals['_PRECONDITIONFAILURE']._serialized_start=572 + _globals['_PRECONDITIONFAILURE']._serialized_end=757 + _globals['_PRECONDITIONFAILURE_VIOLATION']._serialized_start=666 + _globals['_PRECONDITIONFAILURE_VIOLATION']._serialized_end=757 + _globals['_BADREQUEST']._serialized_start=760 + _globals['_BADREQUEST']._serialized_end=924 + _globals['_BADREQUEST_FIELDVIOLATION']._serialized_start=852 + _globals['_BADREQUEST_FIELDVIOLATION']._serialized_end=924 + _globals['_REQUESTINFO']._serialized_start=926 + _globals['_REQUESTINFO']._serialized_end=1005 + _globals['_RESOURCEINFO']._serialized_start=1008 + _globals['_RESOURCEINFO']._serialized_end=1152 + _globals['_HELP']._serialized_start=1154 + _globals['_HELP']._serialized_end=1261 + _globals['_HELP_LINK']._serialized_start=1203 + _globals['_HELP_LINK']._serialized_end=1261 + _globals['_LOCALIZEDMESSAGE']._serialized_start=1263 + _globals['_LOCALIZEDMESSAGE']._serialized_end=1331 +# @@protoc_insertion_point(module_scope) diff --git a/src/vald/v1/rpc/errdetails/error_details_pb2_grpc.py b/src/vald/v1/rpc/errdetails/error_details_pb2_grpc.py new file mode 100644 index 0000000..2daafff --- /dev/null +++ b/src/vald/v1/rpc/errdetails/error_details_pb2_grpc.py @@ -0,0 +1,4 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + diff --git a/src/vald/v1/vald/flush_pb2.py b/src/vald/v1/vald/flush_pb2.py new file mode 100644 index 0000000..d754a32 --- /dev/null +++ b/src/vald/v1/vald/flush_pb2.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: vald/v1/vald/flush.proto +# Protobuf Python Version: 5.28.3 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 3, + '', + 'vald/v1/vald/flush.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from vald.v1.payload import payload_pb2 as vald_dot_v1_dot_payload_dot_payload__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x18vald/v1/vald/flush.proto\x12\x07vald.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1dvald/v1/payload/payload.proto2Y\n\x05\x46lush\x12P\n\x05\x46lush\x12\x19.payload.v1.Flush.Request\x1a\x1c.payload.v1.Info.Index.Count\"\x0e\x82\xd3\xe4\x93\x02\x08*\x06/flushBR\n\x1aorg.vdaas.vald.api.v1.valdB\tValdFlushP\x01Z\'github.com/vdaas/vald/apis/grpc/v1/valdb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'vald.v1.vald.flush_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\032org.vdaas.vald.api.v1.valdB\tValdFlushP\001Z\'github.com/vdaas/vald/apis/grpc/v1/vald' + _globals['_FLUSH'].methods_by_name['Flush']._loaded_options = None + _globals['_FLUSH'].methods_by_name['Flush']._serialized_options = b'\202\323\344\223\002\010*\006/flush' + _globals['_FLUSH']._serialized_start=98 + _globals['_FLUSH']._serialized_end=187 +# @@protoc_insertion_point(module_scope) diff --git a/src/vald/v1/vald/flush_pb2_grpc.py b/src/vald/v1/vald/flush_pb2_grpc.py new file mode 100644 index 0000000..5a58447 --- /dev/null +++ b/src/vald/v1/vald/flush_pb2_grpc.py @@ -0,0 +1,81 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + +from vald.v1.payload import payload_pb2 as vald_dot_v1_dot_payload_dot_payload__pb2 + + +class FlushStub(object): + """Flush service provides ways to flush all indexed vectors. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.Flush = channel.unary_unary( + '/vald.v1.Flush/Flush', + request_serializer=vald_dot_v1_dot_payload_dot_payload__pb2.Flush.Request.SerializeToString, + response_deserializer=vald_dot_v1_dot_payload_dot_payload__pb2.Info.Index.Count.FromString, + _registered_method=True) + + +class FlushServicer(object): + """Flush service provides ways to flush all indexed vectors. + """ + + def Flush(self, request, context): + """A method to flush all indexed vector. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_FlushServicer_to_server(servicer, server): + rpc_method_handlers = { + 'Flush': grpc.unary_unary_rpc_method_handler( + servicer.Flush, + request_deserializer=vald_dot_v1_dot_payload_dot_payload__pb2.Flush.Request.FromString, + response_serializer=vald_dot_v1_dot_payload_dot_payload__pb2.Info.Index.Count.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'vald.v1.Flush', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('vald.v1.Flush', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class Flush(object): + """Flush service provides ways to flush all indexed vectors. + """ + + @staticmethod + def Flush(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/vald.v1.Flush/Flush', + vald_dot_v1_dot_payload_dot_payload__pb2.Flush.Request.SerializeToString, + vald_dot_v1_dot_payload_dot_payload__pb2.Info.Index.Count.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True)