You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:11:37 UTC
[buildstream] 28/41: Add proto for BuildStream artifact cache
service
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch jmac/googlecas_and_virtual_directories_1
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 470f357643f3b858323f79cc35b4253c34b0bb4a
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Thu Mar 15 10:13:23 2018 +0100
Add proto for BuildStream artifact cache service
---
.coveragerc | 3 +
.pylintrc | 2 +-
buildstream/buildstream.proto | 78 +++++++++
buildstream/buildstream_pb2.py | 325 ++++++++++++++++++++++++++++++++++++
buildstream/buildstream_pb2_grpc.py | 87 ++++++++++
doc/Makefile | 2 +-
6 files changed, 495 insertions(+), 2 deletions(-)
diff --git a/.coveragerc b/.coveragerc
index 6014b7f..739d1d0 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -6,6 +6,9 @@ include =
omit =
# Omit profiling helper module
*/buildstream/_profile.py
+ # Omit generated code
+ */buildstream/*_pb2.py
+ */buildstream/*_pb2_grpc.py
*/.eggs/*
[report]
diff --git a/.pylintrc b/.pylintrc
index 7b53ecb..a70476a 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -190,7 +190,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local,contextlib.closing,
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
-ignored-modules=pkg_resources,gi.repository,grpc,google.*
+ignored-modules=pkg_resources,gi.repository,grpc,google.*,buildstream.buildstream_pb2,buildstream.buildstream_pb2_grpc
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
diff --git a/buildstream/buildstream.proto b/buildstream/buildstream.proto
new file mode 100644
index 0000000..3d2cb42
--- /dev/null
+++ b/buildstream/buildstream.proto
@@ -0,0 +1,78 @@
+syntax = "proto3";
+
+package buildstream;
+
+import "google/api/annotations.proto";
+import "google/devtools/remoteexecution/v1test/remote_execution.proto";
+
+service ArtifactCache {
+ // Retrieve a cached artifact.
+ //
+ // Errors:
+ // * `NOT_FOUND`: The requested `ActionResult` is not in the cache.
+ rpc GetArtifact(GetArtifactRequest) returns (GetArtifactResponse) {
+ option (google.api.http) = { get: "/v1test/{instance_name=**}/buildstream/artifacts/{key}" };
+ }
+
+ // Associate a cache key with a CAS build artifact.
+ //
+ // Errors:
+ // * `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the
+ // entry to the cache.
+ rpc UpdateArtifact(UpdateArtifactRequest) returns (UpdateArtifactResponse) {
+ option (google.api.http) = { put: "/v1test/{instance_name=**}/buildstream/artifacts/{key}" body: "artifact" };
+ }
+
+ rpc Status(StatusRequest) returns (StatusResponse) {
+ option (google.api.http) = { put: "/v1test/{instance_name=**}/buildstream/artifacts:status" };
+ }
+}
+
+message GetArtifactRequest {
+ // The instance of the execution system to operate against. A server may
+ // support multiple instances of the execution system (with their own workers,
+ // storage, caches, etc.). The server MAY require use of this field to select
+ // between them in an implementation-defined fashion, otherwise it can be
+ // omitted.
+ string instance_name = 1;
+
+ // The BuildStream cache key.
+ string key = 2;
+}
+
+message GetArtifactResponse {
+ // The digest of the artifact [Directory][google.devtools.remoteexecution.v1test.Directory].
+ google.devtools.remoteexecution.v1test.Digest artifact = 1;
+}
+
+message UpdateArtifactRequest {
+ // The instance of the execution system to operate against. A server may
+ // support multiple instances of the execution system (with their own workers,
+ // storage, caches, etc.). The server MAY require use of this field to select
+ // between them in an implementation-defined fashion, otherwise it can be
+ // omitted.
+ string instance_name = 1;
+
+ // The BuildStream cache key.
+ repeated string keys = 2;
+
+ // The digest of the artifact [Directory][google.devtools.remoteexecution.v1test.Directory]
+ // to store in the cache.
+ google.devtools.remoteexecution.v1test.Digest artifact = 3;
+}
+
+message UpdateArtifactResponse {
+}
+
+message StatusRequest {
+ // The instance of the execution system to operate against. A server may
+ // support multiple instances of the execution system (with their own workers,
+ // storage, caches, etc.). The server MAY require use of this field to select
+ // between them in an implementation-defined fashion, otherwise it can be
+ // omitted.
+ string instance_name = 1;
+}
+
+message StatusResponse {
+ bool allow_updates = 1;
+}
diff --git a/buildstream/buildstream_pb2.py b/buildstream/buildstream_pb2.py
new file mode 100644
index 0000000..8f10201
--- /dev/null
+++ b/buildstream/buildstream_pb2.py
@@ -0,0 +1,325 @@
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: buildstream/buildstream.proto
+
+import sys
+_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
+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 import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
+from google.devtools.remoteexecution.v1test import remote_execution_pb2 as google_dot_devtools_dot_remoteexecution_dot_v1test_dot_remote__execution__pb2
+
+
+DESCRIPTOR = _descriptor.FileDescriptor(
+ name='buildstream/buildstream.proto',
+ package='buildstream',
+ syntax='proto3',
+ serialized_pb=_b('\n\x1d\x62uildstream/buildstream.proto\x12\x0b\x62uildstream\x1a\x1cgoogle/api/annotations.proto\x1a=google/devtools/remoteexecution/v1test/remote_execution.proto\"8\n\x12GetArtifactRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12\x0b\n\x03key\x18\x02 \x01(\t\"W\n\x13GetArtifactResponse\x12@\n\x08\x61rtifact\x18\x01 \x01(\x0b\x32..google.devtools.remoteexecution.v1test.Digest\"~\n\x15UpdateArtifactRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12\x0c\n\x04keys\ [...]
+ ,
+ dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_devtools_dot_remoteexecution_dot_v1test_dot_remote__execution__pb2.DESCRIPTOR,])
+
+
+
+
+_GETARTIFACTREQUEST = _descriptor.Descriptor(
+ name='GetArtifactRequest',
+ full_name='buildstream.GetArtifactRequest',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='instance_name', full_name='buildstream.GetArtifactRequest.instance_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,
+ options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='key', full_name='buildstream.GetArtifactRequest.key', 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,
+ options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=139,
+ serialized_end=195,
+)
+
+
+_GETARTIFACTRESPONSE = _descriptor.Descriptor(
+ name='GetArtifactResponse',
+ full_name='buildstream.GetArtifactResponse',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='artifact', full_name='buildstream.GetArtifactResponse.artifact', 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,
+ options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=197,
+ serialized_end=284,
+)
+
+
+_UPDATEARTIFACTREQUEST = _descriptor.Descriptor(
+ name='UpdateArtifactRequest',
+ full_name='buildstream.UpdateArtifactRequest',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='instance_name', full_name='buildstream.UpdateArtifactRequest.instance_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,
+ options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='keys', full_name='buildstream.UpdateArtifactRequest.keys', index=1,
+ number=2, type=9, cpp_type=9, label=3,
+ has_default_value=False, default_value=[],
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='artifact', full_name='buildstream.UpdateArtifactRequest.artifact', index=2,
+ number=3, 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,
+ options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=286,
+ serialized_end=412,
+)
+
+
+_UPDATEARTIFACTRESPONSE = _descriptor.Descriptor(
+ name='UpdateArtifactResponse',
+ full_name='buildstream.UpdateArtifactResponse',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=414,
+ serialized_end=438,
+)
+
+
+_STATUSREQUEST = _descriptor.Descriptor(
+ name='StatusRequest',
+ full_name='buildstream.StatusRequest',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='instance_name', full_name='buildstream.StatusRequest.instance_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,
+ options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=440,
+ serialized_end=478,
+)
+
+
+_STATUSRESPONSE = _descriptor.Descriptor(
+ name='StatusResponse',
+ full_name='buildstream.StatusResponse',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='allow_updates', full_name='buildstream.StatusResponse.allow_updates', index=0,
+ number=1, 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,
+ options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=480,
+ serialized_end=519,
+)
+
+_GETARTIFACTRESPONSE.fields_by_name['artifact'].message_type = google_dot_devtools_dot_remoteexecution_dot_v1test_dot_remote__execution__pb2._DIGEST
+_UPDATEARTIFACTREQUEST.fields_by_name['artifact'].message_type = google_dot_devtools_dot_remoteexecution_dot_v1test_dot_remote__execution__pb2._DIGEST
+DESCRIPTOR.message_types_by_name['GetArtifactRequest'] = _GETARTIFACTREQUEST
+DESCRIPTOR.message_types_by_name['GetArtifactResponse'] = _GETARTIFACTRESPONSE
+DESCRIPTOR.message_types_by_name['UpdateArtifactRequest'] = _UPDATEARTIFACTREQUEST
+DESCRIPTOR.message_types_by_name['UpdateArtifactResponse'] = _UPDATEARTIFACTRESPONSE
+DESCRIPTOR.message_types_by_name['StatusRequest'] = _STATUSREQUEST
+DESCRIPTOR.message_types_by_name['StatusResponse'] = _STATUSRESPONSE
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
+
+GetArtifactRequest = _reflection.GeneratedProtocolMessageType('GetArtifactRequest', (_message.Message,), dict(
+ DESCRIPTOR = _GETARTIFACTREQUEST,
+ __module__ = 'buildstream.buildstream_pb2'
+ # @@protoc_insertion_point(class_scope:buildstream.GetArtifactRequest)
+ ))
+_sym_db.RegisterMessage(GetArtifactRequest)
+
+GetArtifactResponse = _reflection.GeneratedProtocolMessageType('GetArtifactResponse', (_message.Message,), dict(
+ DESCRIPTOR = _GETARTIFACTRESPONSE,
+ __module__ = 'buildstream.buildstream_pb2'
+ # @@protoc_insertion_point(class_scope:buildstream.GetArtifactResponse)
+ ))
+_sym_db.RegisterMessage(GetArtifactResponse)
+
+UpdateArtifactRequest = _reflection.GeneratedProtocolMessageType('UpdateArtifactRequest', (_message.Message,), dict(
+ DESCRIPTOR = _UPDATEARTIFACTREQUEST,
+ __module__ = 'buildstream.buildstream_pb2'
+ # @@protoc_insertion_point(class_scope:buildstream.UpdateArtifactRequest)
+ ))
+_sym_db.RegisterMessage(UpdateArtifactRequest)
+
+UpdateArtifactResponse = _reflection.GeneratedProtocolMessageType('UpdateArtifactResponse', (_message.Message,), dict(
+ DESCRIPTOR = _UPDATEARTIFACTRESPONSE,
+ __module__ = 'buildstream.buildstream_pb2'
+ # @@protoc_insertion_point(class_scope:buildstream.UpdateArtifactResponse)
+ ))
+_sym_db.RegisterMessage(UpdateArtifactResponse)
+
+StatusRequest = _reflection.GeneratedProtocolMessageType('StatusRequest', (_message.Message,), dict(
+ DESCRIPTOR = _STATUSREQUEST,
+ __module__ = 'buildstream.buildstream_pb2'
+ # @@protoc_insertion_point(class_scope:buildstream.StatusRequest)
+ ))
+_sym_db.RegisterMessage(StatusRequest)
+
+StatusResponse = _reflection.GeneratedProtocolMessageType('StatusResponse', (_message.Message,), dict(
+ DESCRIPTOR = _STATUSRESPONSE,
+ __module__ = 'buildstream.buildstream_pb2'
+ # @@protoc_insertion_point(class_scope:buildstream.StatusResponse)
+ ))
+_sym_db.RegisterMessage(StatusResponse)
+
+
+
+_ARTIFACTCACHE = _descriptor.ServiceDescriptor(
+ name='ArtifactCache',
+ full_name='buildstream.ArtifactCache',
+ file=DESCRIPTOR,
+ index=0,
+ options=None,
+ serialized_start=522,
+ serialized_end=983,
+ methods=[
+ _descriptor.MethodDescriptor(
+ name='GetArtifact',
+ full_name='buildstream.ArtifactCache.GetArtifact',
+ index=0,
+ containing_service=None,
+ input_type=_GETARTIFACTREQUEST,
+ output_type=_GETARTIFACTRESPONSE,
+ options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0028\0226/v1test/{instance_name=**}/buildstream/artifacts/{key}')),
+ ),
+ _descriptor.MethodDescriptor(
+ name='UpdateArtifact',
+ full_name='buildstream.ArtifactCache.UpdateArtifact',
+ index=1,
+ containing_service=None,
+ input_type=_UPDATEARTIFACTREQUEST,
+ output_type=_UPDATEARTIFACTRESPONSE,
+ options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002B\0326/v1test/{instance_name=**}/buildstream/artifacts/{key}:\010artifact')),
+ ),
+ _descriptor.MethodDescriptor(
+ name='Status',
+ full_name='buildstream.ArtifactCache.Status',
+ index=2,
+ containing_service=None,
+ input_type=_STATUSREQUEST,
+ output_type=_STATUSRESPONSE,
+ options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0029\0327/v1test/{instance_name=**}/buildstream/artifacts:status')),
+ ),
+])
+_sym_db.RegisterServiceDescriptor(_ARTIFACTCACHE)
+
+DESCRIPTOR.services_by_name['ArtifactCache'] = _ARTIFACTCACHE
+
+# @@protoc_insertion_point(module_scope)
diff --git a/buildstream/buildstream_pb2_grpc.py b/buildstream/buildstream_pb2_grpc.py
new file mode 100644
index 0000000..21d914a
--- /dev/null
+++ b/buildstream/buildstream_pb2_grpc.py
@@ -0,0 +1,87 @@
+# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
+import grpc
+
+from buildstream import buildstream_pb2 as buildstream_dot_buildstream__pb2
+
+
+class ArtifactCacheStub(object):
+ # missing associated documentation comment in .proto file
+ pass
+
+ def __init__(self, channel):
+ """Constructor.
+
+ Args:
+ channel: A grpc.Channel.
+ """
+ self.GetArtifact = channel.unary_unary(
+ '/buildstream.ArtifactCache/GetArtifact',
+ request_serializer=buildstream_dot_buildstream__pb2.GetArtifactRequest.SerializeToString,
+ response_deserializer=buildstream_dot_buildstream__pb2.GetArtifactResponse.FromString,
+ )
+ self.UpdateArtifact = channel.unary_unary(
+ '/buildstream.ArtifactCache/UpdateArtifact',
+ request_serializer=buildstream_dot_buildstream__pb2.UpdateArtifactRequest.SerializeToString,
+ response_deserializer=buildstream_dot_buildstream__pb2.UpdateArtifactResponse.FromString,
+ )
+ self.Status = channel.unary_unary(
+ '/buildstream.ArtifactCache/Status',
+ request_serializer=buildstream_dot_buildstream__pb2.StatusRequest.SerializeToString,
+ response_deserializer=buildstream_dot_buildstream__pb2.StatusResponse.FromString,
+ )
+
+
+class ArtifactCacheServicer(object):
+ # missing associated documentation comment in .proto file
+ pass
+
+ def GetArtifact(self, request, context):
+ """Retrieve a cached artifact.
+
+ Errors:
+ * `NOT_FOUND`: The requested `ActionResult` is not in the cache.
+ """
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details('Method not implemented!')
+ raise NotImplementedError('Method not implemented!')
+
+ def UpdateArtifact(self, request, context):
+ """Associate a cache key with a CAS build artifact.
+
+ Errors:
+ * `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the
+ entry to the cache.
+ """
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details('Method not implemented!')
+ raise NotImplementedError('Method not implemented!')
+
+ def Status(self, request, context):
+ # missing associated documentation comment in .proto file
+ pass
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details('Method not implemented!')
+ raise NotImplementedError('Method not implemented!')
+
+
+def add_ArtifactCacheServicer_to_server(servicer, server):
+ rpc_method_handlers = {
+ 'GetArtifact': grpc.unary_unary_rpc_method_handler(
+ servicer.GetArtifact,
+ request_deserializer=buildstream_dot_buildstream__pb2.GetArtifactRequest.FromString,
+ response_serializer=buildstream_dot_buildstream__pb2.GetArtifactResponse.SerializeToString,
+ ),
+ 'UpdateArtifact': grpc.unary_unary_rpc_method_handler(
+ servicer.UpdateArtifact,
+ request_deserializer=buildstream_dot_buildstream__pb2.UpdateArtifactRequest.FromString,
+ response_serializer=buildstream_dot_buildstream__pb2.UpdateArtifactResponse.SerializeToString,
+ ),
+ 'Status': grpc.unary_unary_rpc_method_handler(
+ servicer.Status,
+ request_deserializer=buildstream_dot_buildstream__pb2.StatusRequest.FromString,
+ response_serializer=buildstream_dot_buildstream__pb2.StatusResponse.SerializeToString,
+ ),
+ }
+ generic_handler = grpc.method_handlers_generic_handler(
+ 'buildstream.ArtifactCache', rpc_method_handlers)
+ server.add_generic_rpc_handlers((generic_handler,))
diff --git a/doc/Makefile b/doc/Makefile
index c894a13..557dc55 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -65,7 +65,7 @@ all: html devhelp
templates:
mkdir -p source/elements
mkdir -p source/sources
- $(SPHINXAPIDOC) --force --separate --module-first --no-headings -o source $(CURDIR)/../buildstream
+ $(SPHINXAPIDOC) --force --separate --module-first --no-headings -o source $(CURDIR)/../buildstream $(CURDIR)/../buildstream/*_pb2*.py
$(call plugin-doc-skeleton,$(CURDIR)/../buildstream/plugins/elements,elements)
$(call plugin-doc-skeleton,$(CURDIR)/../buildstream/plugins/sources,sources)