fix(proto): 修复包名不一致

This commit is contained in:
eson 2021-03-26 11:55:17 +08:00
parent bb90138620
commit fbcbeca35d
5 changed files with 54 additions and 50 deletions

View File

@ -1,5 +1,8 @@
syntax = "proto3"; syntax = "proto3";
package databoard;
option go_package = "learning/predict";
service Predict { service Predict {
rpc PayDay(RequestPay) returns (ReplyPay) {} rpc PayDay(RequestPay) returns (ReplyPay) {}
rpc GiftDay(RequestGift) returns (ReplyGift) {} rpc GiftDay(RequestGift) returns (ReplyGift) {}

View File

@ -10,7 +10,7 @@ import os
import numpy import numpy
import time, datetime import time, datetime
def get_collect(): def get_collect(region = "all"):
collect = {} collect = {}
loadfile = "./collect.pickle" loadfile = "./collect.pickle"
@ -26,7 +26,7 @@ def get_collect():
today = time.strftime("%Y-%m-%d", time.localtime()) today = time.strftime("%Y-%m-%d", time.localtime())
# 使用 execute() 方法执行 SQL 查询 # 使用 execute() 方法执行 SQL 查询
cursor.execute('''SELECT coin, extra_coins, pay_users, create_at from pay_items_hour pih where region = "all" and platform="all" and create_at <= %s''', today) cursor.execute('''SELECT coin, extra_coins, pay_users, create_at from pay_items_hour pih where region = "%s" and platform="all" and create_at <= %s''',region , today)
collect_pay = {} collect_pay = {}
for row in cursor.fetchall(): for row in cursor.fetchall():
# print(row) # print(row)
@ -83,7 +83,7 @@ def get_collect():
def load_pay_data(textNum = 80): def load_pay_data(textNum = 80, region = "all"):
collect = get_collect() collect = get_collect()

View File

@ -30,7 +30,7 @@ class Predict(predict_pb2_grpc.PredictServicer):
def server(): def server():
grpc_server = grpc.server(futures.ThreadPoolExecutor(max_workers=2)) grpc_server = grpc.server(futures.ThreadPoolExecutor(max_workers=2))
predict_pb2_grpc.add_PredictServicer_to_server(Predict(), grpc_server) predict_pb2_grpc.add_PredictServicer_to_server(Predict(), grpc_server)
grpc_server.add_insecure_port('[::]:50051') grpc_server.add_insecure_port('0.0.0.0:50051')
grpc_server.start() grpc_server.start()
grpc_server.wait_for_termination() grpc_server.wait_for_termination()

View File

@ -15,11 +15,11 @@ _sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor( DESCRIPTOR = _descriptor.FileDescriptor(
name='predict.proto', name='predict.proto',
package='', package='databoard',
syntax='proto3', syntax='proto3',
serialized_options=None, serialized_options=b'Z\020learning/predict',
create_key=_descriptor._internal_create_key, create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\rpredict.proto\"?\n\nRequestPay\x12\x0c\n\x04Hour\x18\x01 \x01(\x05\x12\x0c\n\x04\x43oin\x18\x02 \x01(\x03\x12\x15\n\rYesterdayCoin\x18\x03 \x01(\x03\"@\n\x0bRequestGift\x12\x0c\n\x04Hour\x18\x01 \x01(\x05\x12\x0c\n\x04\x43oin\x18\x02 \x01(\x03\x12\x15\n\rYesterdayCoin\x18\x03 \x01(\x03\",\n\x0bReplyHeader\x12\x0c\n\x04\x43ode\x18\x01 \x01(\x05\x12\x0f\n\x07Message\x18\x02 \x01(\t\"8\n\x08ReplyPay\x12\x1c\n\x06Header\x18\x01 \x01(\x0b\x32\x0c.ReplyHeader\x12\x0e\n\x06Result\x18\x02 \x01(\x03\"9\n\tReplyGift\x12\x1c\n\x06Header\x18\x01 \x01(\x0b\x32\x0c.ReplyHeader\x12\x0e\n\x06Result\x18\x02 \x01(\x03\x32T\n\x07Predict\x12\"\n\x06PayDay\x12\x0b.RequestPay\x1a\t.ReplyPay\"\x00\x12%\n\x07GiftDay\x12\x0c.RequestGift\x1a\n.ReplyGift\"\x00\x62\x06proto3' serialized_pb=b'\n\rpredict.proto\x12\tdataboard\"?\n\nRequestPay\x12\x0c\n\x04Hour\x18\x01 \x01(\x05\x12\x0c\n\x04\x43oin\x18\x02 \x01(\x03\x12\x15\n\rYesterdayCoin\x18\x03 \x01(\x03\"@\n\x0bRequestGift\x12\x0c\n\x04Hour\x18\x01 \x01(\x05\x12\x0c\n\x04\x43oin\x18\x02 \x01(\x03\x12\x15\n\rYesterdayCoin\x18\x03 \x01(\x03\",\n\x0bReplyHeader\x12\x0c\n\x04\x43ode\x18\x01 \x01(\x05\x12\x0f\n\x07Message\x18\x02 \x01(\t\"B\n\x08ReplyPay\x12&\n\x06Header\x18\x01 \x01(\x0b\x32\x16.databoard.ReplyHeader\x12\x0e\n\x06Result\x18\x02 \x01(\x03\"C\n\tReplyGift\x12&\n\x06Header\x18\x01 \x01(\x0b\x32\x16.databoard.ReplyHeader\x12\x0e\n\x06Result\x18\x02 \x01(\x03\x32|\n\x07Predict\x12\x36\n\x06PayDay\x12\x15.databoard.RequestPay\x1a\x13.databoard.ReplyPay\"\x00\x12\x39\n\x07GiftDay\x12\x16.databoard.RequestGift\x1a\x14.databoard.ReplyGift\"\x00\x42\x12Z\x10learning/predictb\x06proto3'
) )
@ -27,28 +27,28 @@ DESCRIPTOR = _descriptor.FileDescriptor(
_REQUESTPAY = _descriptor.Descriptor( _REQUESTPAY = _descriptor.Descriptor(
name='RequestPay', name='RequestPay',
full_name='RequestPay', full_name='databoard.RequestPay',
filename=None, filename=None,
file=DESCRIPTOR, file=DESCRIPTOR,
containing_type=None, containing_type=None,
create_key=_descriptor._internal_create_key, create_key=_descriptor._internal_create_key,
fields=[ fields=[
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Hour', full_name='RequestPay.Hour', index=0, name='Hour', full_name='databoard.RequestPay.Hour', index=0,
number=1, type=5, cpp_type=1, label=1, number=1, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Coin', full_name='RequestPay.Coin', index=1, name='Coin', full_name='databoard.RequestPay.Coin', index=1,
number=2, type=3, cpp_type=2, label=1, number=2, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='YesterdayCoin', full_name='RequestPay.YesterdayCoin', index=2, name='YesterdayCoin', full_name='databoard.RequestPay.YesterdayCoin', index=2,
number=3, type=3, cpp_type=2, label=1, number=3, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
@ -66,35 +66,35 @@ _REQUESTPAY = _descriptor.Descriptor(
extension_ranges=[], extension_ranges=[],
oneofs=[ oneofs=[
], ],
serialized_start=17, serialized_start=28,
serialized_end=80, serialized_end=91,
) )
_REQUESTGIFT = _descriptor.Descriptor( _REQUESTGIFT = _descriptor.Descriptor(
name='RequestGift', name='RequestGift',
full_name='RequestGift', full_name='databoard.RequestGift',
filename=None, filename=None,
file=DESCRIPTOR, file=DESCRIPTOR,
containing_type=None, containing_type=None,
create_key=_descriptor._internal_create_key, create_key=_descriptor._internal_create_key,
fields=[ fields=[
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Hour', full_name='RequestGift.Hour', index=0, name='Hour', full_name='databoard.RequestGift.Hour', index=0,
number=1, type=5, cpp_type=1, label=1, number=1, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Coin', full_name='RequestGift.Coin', index=1, name='Coin', full_name='databoard.RequestGift.Coin', index=1,
number=2, type=3, cpp_type=2, label=1, number=2, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='YesterdayCoin', full_name='RequestGift.YesterdayCoin', index=2, name='YesterdayCoin', full_name='databoard.RequestGift.YesterdayCoin', index=2,
number=3, type=3, cpp_type=2, label=1, number=3, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
@ -112,28 +112,28 @@ _REQUESTGIFT = _descriptor.Descriptor(
extension_ranges=[], extension_ranges=[],
oneofs=[ oneofs=[
], ],
serialized_start=82, serialized_start=93,
serialized_end=146, serialized_end=157,
) )
_REPLYHEADER = _descriptor.Descriptor( _REPLYHEADER = _descriptor.Descriptor(
name='ReplyHeader', name='ReplyHeader',
full_name='ReplyHeader', full_name='databoard.ReplyHeader',
filename=None, filename=None,
file=DESCRIPTOR, file=DESCRIPTOR,
containing_type=None, containing_type=None,
create_key=_descriptor._internal_create_key, create_key=_descriptor._internal_create_key,
fields=[ fields=[
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Code', full_name='ReplyHeader.Code', index=0, name='Code', full_name='databoard.ReplyHeader.Code', index=0,
number=1, type=5, cpp_type=1, label=1, number=1, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Message', full_name='ReplyHeader.Message', index=1, name='Message', full_name='databoard.ReplyHeader.Message', index=1,
number=2, type=9, cpp_type=9, label=1, number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'), has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
@ -151,28 +151,28 @@ _REPLYHEADER = _descriptor.Descriptor(
extension_ranges=[], extension_ranges=[],
oneofs=[ oneofs=[
], ],
serialized_start=148, serialized_start=159,
serialized_end=192, serialized_end=203,
) )
_REPLYPAY = _descriptor.Descriptor( _REPLYPAY = _descriptor.Descriptor(
name='ReplyPay', name='ReplyPay',
full_name='ReplyPay', full_name='databoard.ReplyPay',
filename=None, filename=None,
file=DESCRIPTOR, file=DESCRIPTOR,
containing_type=None, containing_type=None,
create_key=_descriptor._internal_create_key, create_key=_descriptor._internal_create_key,
fields=[ fields=[
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Header', full_name='ReplyPay.Header', index=0, name='Header', full_name='databoard.ReplyPay.Header', index=0,
number=1, type=11, cpp_type=10, label=1, number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None, has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Result', full_name='ReplyPay.Result', index=1, name='Result', full_name='databoard.ReplyPay.Result', index=1,
number=2, type=3, cpp_type=2, label=1, number=2, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
@ -190,28 +190,28 @@ _REPLYPAY = _descriptor.Descriptor(
extension_ranges=[], extension_ranges=[],
oneofs=[ oneofs=[
], ],
serialized_start=194, serialized_start=205,
serialized_end=250, serialized_end=271,
) )
_REPLYGIFT = _descriptor.Descriptor( _REPLYGIFT = _descriptor.Descriptor(
name='ReplyGift', name='ReplyGift',
full_name='ReplyGift', full_name='databoard.ReplyGift',
filename=None, filename=None,
file=DESCRIPTOR, file=DESCRIPTOR,
containing_type=None, containing_type=None,
create_key=_descriptor._internal_create_key, create_key=_descriptor._internal_create_key,
fields=[ fields=[
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Header', full_name='ReplyGift.Header', index=0, name='Header', full_name='databoard.ReplyGift.Header', index=0,
number=1, type=11, cpp_type=10, label=1, number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None, has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='Result', full_name='ReplyGift.Result', index=1, name='Result', full_name='databoard.ReplyGift.Result', index=1,
number=2, type=3, cpp_type=2, label=1, number=2, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0, has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
@ -229,8 +229,8 @@ _REPLYGIFT = _descriptor.Descriptor(
extension_ranges=[], extension_ranges=[],
oneofs=[ oneofs=[
], ],
serialized_start=252, serialized_start=273,
serialized_end=309, serialized_end=340,
) )
_REPLYPAY.fields_by_name['Header'].message_type = _REPLYHEADER _REPLYPAY.fields_by_name['Header'].message_type = _REPLYHEADER
@ -245,53 +245,54 @@ _sym_db.RegisterFileDescriptor(DESCRIPTOR)
RequestPay = _reflection.GeneratedProtocolMessageType('RequestPay', (_message.Message,), { RequestPay = _reflection.GeneratedProtocolMessageType('RequestPay', (_message.Message,), {
'DESCRIPTOR' : _REQUESTPAY, 'DESCRIPTOR' : _REQUESTPAY,
'__module__' : 'predict_pb2' '__module__' : 'predict_pb2'
# @@protoc_insertion_point(class_scope:RequestPay) # @@protoc_insertion_point(class_scope:databoard.RequestPay)
}) })
_sym_db.RegisterMessage(RequestPay) _sym_db.RegisterMessage(RequestPay)
RequestGift = _reflection.GeneratedProtocolMessageType('RequestGift', (_message.Message,), { RequestGift = _reflection.GeneratedProtocolMessageType('RequestGift', (_message.Message,), {
'DESCRIPTOR' : _REQUESTGIFT, 'DESCRIPTOR' : _REQUESTGIFT,
'__module__' : 'predict_pb2' '__module__' : 'predict_pb2'
# @@protoc_insertion_point(class_scope:RequestGift) # @@protoc_insertion_point(class_scope:databoard.RequestGift)
}) })
_sym_db.RegisterMessage(RequestGift) _sym_db.RegisterMessage(RequestGift)
ReplyHeader = _reflection.GeneratedProtocolMessageType('ReplyHeader', (_message.Message,), { ReplyHeader = _reflection.GeneratedProtocolMessageType('ReplyHeader', (_message.Message,), {
'DESCRIPTOR' : _REPLYHEADER, 'DESCRIPTOR' : _REPLYHEADER,
'__module__' : 'predict_pb2' '__module__' : 'predict_pb2'
# @@protoc_insertion_point(class_scope:ReplyHeader) # @@protoc_insertion_point(class_scope:databoard.ReplyHeader)
}) })
_sym_db.RegisterMessage(ReplyHeader) _sym_db.RegisterMessage(ReplyHeader)
ReplyPay = _reflection.GeneratedProtocolMessageType('ReplyPay', (_message.Message,), { ReplyPay = _reflection.GeneratedProtocolMessageType('ReplyPay', (_message.Message,), {
'DESCRIPTOR' : _REPLYPAY, 'DESCRIPTOR' : _REPLYPAY,
'__module__' : 'predict_pb2' '__module__' : 'predict_pb2'
# @@protoc_insertion_point(class_scope:ReplyPay) # @@protoc_insertion_point(class_scope:databoard.ReplyPay)
}) })
_sym_db.RegisterMessage(ReplyPay) _sym_db.RegisterMessage(ReplyPay)
ReplyGift = _reflection.GeneratedProtocolMessageType('ReplyGift', (_message.Message,), { ReplyGift = _reflection.GeneratedProtocolMessageType('ReplyGift', (_message.Message,), {
'DESCRIPTOR' : _REPLYGIFT, 'DESCRIPTOR' : _REPLYGIFT,
'__module__' : 'predict_pb2' '__module__' : 'predict_pb2'
# @@protoc_insertion_point(class_scope:ReplyGift) # @@protoc_insertion_point(class_scope:databoard.ReplyGift)
}) })
_sym_db.RegisterMessage(ReplyGift) _sym_db.RegisterMessage(ReplyGift)
DESCRIPTOR._options = None
_PREDICT = _descriptor.ServiceDescriptor( _PREDICT = _descriptor.ServiceDescriptor(
name='Predict', name='Predict',
full_name='Predict', full_name='databoard.Predict',
file=DESCRIPTOR, file=DESCRIPTOR,
index=0, index=0,
serialized_options=None, serialized_options=None,
create_key=_descriptor._internal_create_key, create_key=_descriptor._internal_create_key,
serialized_start=311, serialized_start=342,
serialized_end=395, serialized_end=466,
methods=[ methods=[
_descriptor.MethodDescriptor( _descriptor.MethodDescriptor(
name='PayDay', name='PayDay',
full_name='Predict.PayDay', full_name='databoard.Predict.PayDay',
index=0, index=0,
containing_service=None, containing_service=None,
input_type=_REQUESTPAY, input_type=_REQUESTPAY,
@ -301,7 +302,7 @@ _PREDICT = _descriptor.ServiceDescriptor(
), ),
_descriptor.MethodDescriptor( _descriptor.MethodDescriptor(
name='GiftDay', name='GiftDay',
full_name='Predict.GiftDay', full_name='databoard.Predict.GiftDay',
index=1, index=1,
containing_service=None, containing_service=None,
input_type=_REQUESTGIFT, input_type=_REQUESTGIFT,

View File

@ -15,12 +15,12 @@ class PredictStub(object):
channel: A grpc.Channel. channel: A grpc.Channel.
""" """
self.PayDay = channel.unary_unary( self.PayDay = channel.unary_unary(
'/Predict/PayDay', '/databoard.Predict/PayDay',
request_serializer=predict__pb2.RequestPay.SerializeToString, request_serializer=predict__pb2.RequestPay.SerializeToString,
response_deserializer=predict__pb2.ReplyPay.FromString, response_deserializer=predict__pb2.ReplyPay.FromString,
) )
self.GiftDay = channel.unary_unary( self.GiftDay = channel.unary_unary(
'/Predict/GiftDay', '/databoard.Predict/GiftDay',
request_serializer=predict__pb2.RequestGift.SerializeToString, request_serializer=predict__pb2.RequestGift.SerializeToString,
response_deserializer=predict__pb2.ReplyGift.FromString, response_deserializer=predict__pb2.ReplyGift.FromString,
) )
@ -56,7 +56,7 @@ def add_PredictServicer_to_server(servicer, server):
), ),
} }
generic_handler = grpc.method_handlers_generic_handler( generic_handler = grpc.method_handlers_generic_handler(
'Predict', rpc_method_handlers) 'databoard.Predict', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,)) server.add_generic_rpc_handlers((generic_handler,))
@ -75,7 +75,7 @@ class Predict(object):
wait_for_ready=None, wait_for_ready=None,
timeout=None, timeout=None,
metadata=None): metadata=None):
return grpc.experimental.unary_unary(request, target, '/Predict/PayDay', return grpc.experimental.unary_unary(request, target, '/databoard.Predict/PayDay',
predict__pb2.RequestPay.SerializeToString, predict__pb2.RequestPay.SerializeToString,
predict__pb2.ReplyPay.FromString, predict__pb2.ReplyPay.FromString,
options, channel_credentials, options, channel_credentials,
@ -92,7 +92,7 @@ class Predict(object):
wait_for_ready=None, wait_for_ready=None,
timeout=None, timeout=None,
metadata=None): metadata=None):
return grpc.experimental.unary_unary(request, target, '/Predict/GiftDay', return grpc.experimental.unary_unary(request, target, '/databoard.Predict/GiftDay',
predict__pb2.RequestGift.SerializeToString, predict__pb2.RequestGift.SerializeToString,
predict__pb2.ReplyGift.FromString, predict__pb2.ReplyGift.FromString,
options, channel_credentials, options, channel_credentials,