Commit 90e8faa7 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

️ log line

parent 5e0687e4
import grpc import grpc
import pickle import pickle
from collections import deque
import logging import logging
import io import io
import time
from csst_dfs_commons.models import Result from csst_dfs_commons.models import Result
from csst_dfs_commons.models.common import from_proto_model_list, Gaia3Record
from csst_dfs_proto.common.ephem import ephem_pb2, ephem_pb2_grpc from csst_dfs_proto.common.ephem import ephem_pb2, ephem_pb2_grpc
from .service import ServiceProxy from .service import ServiceProxy
...@@ -34,7 +31,6 @@ class CatalogApi(object): ...@@ -34,7 +31,6 @@ class CatalogApi(object):
try: try:
datas = io.BytesIO() datas = io.BytesIO()
totalCount = 0 totalCount = 0
t_start = time.time()
resps = self.stub.Gaia3Search(ephem_pb2.EphemSearchRequest( resps = self.stub.Gaia3Search(ephem_pb2.EphemSearchRequest(
ra = ra, ra = ra,
dec = dec, dec = dec,
...@@ -47,16 +43,12 @@ class CatalogApi(object): ...@@ -47,16 +43,12 @@ class CatalogApi(object):
),metadata = get_auth_headers()) ),metadata = get_auth_headers())
for resp in resps: for resp in resps:
if resp.success: if resp.success:
# data = from_proto_model_list(Gaia3Record, resp.records)
datas.write(resp.records) datas.write(resp.records)
totalCount = resp.totalCount totalCount = resp.totalCount
else: else:
return Result.error(message = str(resp.error.detail)) return Result.error(message = str(resp.error.detail))
datas.flush() datas.flush()
log.info("received used: %.6f's" %(time.time() - t_start,))
t_start = time.time()
records = pickle.loads(datas.getvalue()) records = pickle.loads(datas.getvalue())
log.info("unserialization used: %.6f's" %(time.time() - t_start,))
return Result.ok_data(data = records).append("totalCount", totalCount).append("columns", columns) return Result.ok_data(data = records).append("totalCount", totalCount).append("columns", columns)
except grpc.RpcError as e: except grpc.RpcError as e:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment