Commit 7c94a360 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

add catalog_query_file

parent 1294df3b
......@@ -6,11 +6,9 @@ class ServiceProxy:
self.gateway = os.getenv("CSST_DFS_GATEWAY",'172.31.248.218:30880')
def channel(self):
options = [('grpc.max_send_message_length', 1000 * 1024 * 1024),
('grpc.max_receive_message_length', 1000 * 1024 * 1024),
('grpc.enable_retries', 1),
('grpc.service_config', '{ "retryPolicy":{ "maxAttempts": 4, "initialBackoff": "0.1s", "maxBackoff": "1s", "backoffMutiplier": 2, "retryableStatusCodes": [ "UNAVAILABLE" ] } }')]
channel = grpc.insecure_channel(self.gateway, options=options)
options = (('grpc.max_send_message_length', 1000 * 1024 * 1024),
('grpc.max_receive_message_length', 1000 * 1024 * 1024))
channel = grpc.insecure_channel(self.gateway, options = options, compression = grpc.Compression.Gzip)
try:
grpc.channel_ready_future(channel).result(timeout=10)
except grpc.FutureTimeoutError:
......
......@@ -64,8 +64,6 @@ class Level2DataApi(object):
ra: [float] in deg
dec: [float] in deg
radius: [float] in deg
min_mag: [float]
max_mag: [float]
obs_time: (start, end),
limit: limits returns the number of records,default 0:no-limit
......@@ -93,6 +91,42 @@ class Level2DataApi(object):
except grpc.RpcError as e:
return Result.error(message="%s:%s" % (e.code().value, e.details()))
def catalog_query_file(self, **kwargs):
''' retrieve level2catalog records from database
parameter kwargs:
obs_id: [str]
detector_no: [str]
ra: [float] in deg
dec: [float] in deg
radius: [float] in deg
obs_time: (start, end),
limit: limits returns the number of records,default 0:no-limit
return: csst_dfs_common.models.Result
'''
try:
resp, _ = self.stub.FindCatalogFile.with_call(level2_pb2.FindLevel2CatalogReq(
obs_id = get_parameter(kwargs, "obs_id"),
detector_no = get_parameter(kwargs, "detector_no"),
obs_time_start = get_parameter(kwargs, "obs_time", [None, None])[0],
obs_time_end = get_parameter(kwargs, "obs_time", [None, None])[1],
ra = get_parameter(kwargs, "ra"),
dec = get_parameter(kwargs, "dec"),
radius = get_parameter(kwargs, "radius"),
minMag = get_parameter(kwargs, "min_mag"),
maxMag = get_parameter(kwargs, "max_mag"),
limit = get_parameter(kwargs, "limit", 0)
),metadata = get_auth_headers())
if resp.success:
return Result.ok_data(data=from_proto_model_list(Level2Record, resp.records)).append("totalCount", resp.totalCount)
else:
return Result.error(message = str(resp.error.detail))
except grpc.RpcError as e:
return Result.error(message="%s:%s" % (e.code().value, e.details()))
def get(self, **kwargs):
''' fetch a record from database
......
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