Commit 790d8712 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

write add obs_id

parent 7275127f
......@@ -30,7 +30,7 @@ class Level0DataApi(object):
'''
try:
resp, _ = self.stub.Find.with_call(level0_pb2.FindLevel0DataReq(
obs_id = get_parameter(kwargs, "obs_id"),
obs_id = get_parameter(kwargs, "obs_id", 0),
detector_no = get_parameter(kwargs, "detector_no"),
obs_type = get_parameter(kwargs, "obs_type"),
exp_time_start = get_parameter(kwargs, "obs_time", [None, None])[0],
......@@ -67,7 +67,7 @@ class Level0DataApi(object):
if resp.record is None or resp.record.id == 0:
return Result.error(message=f"fits_id:{fits_id} not found")
return Result.ok_data(data = Level0Record.from_proto_model(resp.record))
return Result.ok_data(data = Level0Record().from_proto_model(resp.record))
except grpc.RpcError as e:
return Result.error(message="%s:%s" % (e.code().value, e.details))
......@@ -144,7 +144,7 @@ class Level0DataApi(object):
try:
resp,_ = self.stub.Write.with_call(req,metadata = get_auth_headers())
if resp.success:
return Result.ok_data(data = Level0Record.from_proto_model(resp.record))
return Result.ok_data(data = Level0Record().from_proto_model(resp.record))
else:
return Result.error(message = str(resp.error.detail))
......
......@@ -93,7 +93,7 @@ class Level0PrcApi(object):
try:
resp,_ = self.stub.Write.with_call(req,metadata = get_auth_headers())
if resp.success:
return Result.ok_data(data = Level0PrcRecord.from_proto_model(resp.record))
return Result.ok_data(data = Level0PrcRecord().from_proto_model(resp.record))
else:
return Result.error(message = str(resp.error.detail))
except grpc.RpcError as e:
......
......@@ -67,7 +67,7 @@ class ObservationApi(object):
if resp.observation is None or resp.observation.id == 0:
return Result.error(message=f"obs_id:{obs_id} not found")
return Result.ok_data(data=Observation.from_proto_model(resp.observation))
return Result.ok_data(data=Observation().from_proto_model(resp.observation))
except grpc.RpcError as e:
return Result.error(message="%s:%s" % (e.code().value, e.details))
......@@ -120,6 +120,7 @@ class ObservationApi(object):
''' insert a observational record into database
parameter kwargs:
obs_id = [int]
obs_time = [str]
exp_time = [int]
module_id = [str]
......@@ -130,6 +131,7 @@ class ObservationApi(object):
'''
rec = observation_pb2.Observation(
id = get_parameter(kwargs, "obs_id", 0),
obs_time = get_parameter(kwargs, "obs_time"),
exp_time = get_parameter(kwargs, "exp_time"),
module_id = get_parameter(kwargs, "module_id"),
......@@ -141,7 +143,7 @@ class ObservationApi(object):
try:
resp,_ = self.stub.Write.with_call(req,metadata = get_auth_headers())
if resp.success:
return Result.ok_data(data=Observation.from_proto_model(resp.record))
return Result.ok_data(data=Observation().from_proto_model(resp.record))
else:
return Result.error(message = str(resp.error.detail))
......
......@@ -69,7 +69,7 @@ class Level1DataApi(object):
if resp.record is None or resp.record.id == 0:
return Result.error(message=f"id:{id} not found")
return Result.ok_data(data=Level1Record.from_proto_model(resp.record))
return Result.ok_data(data=Level1Record().from_proto_model(resp.record))
except grpc.RpcError as e:
return Result.error(message="%s:%s" % (e.code().value, e.details))
......@@ -141,7 +141,7 @@ class Level1DataApi(object):
return csst_dfs_common.models.Result
'''
rec = level1_pb2.Level1Record(
rec = level1_pb2.Detector(
id = 0,
raw_id = get_parameter(kwargs, "raw_id"),
data_type = get_parameter(kwargs, "data_type"),
......@@ -163,7 +163,7 @@ class Level1DataApi(object):
try:
resp,_ = self.stub.Write.with_call(req,metadata = get_auth_headers())
if resp.success:
return Result.ok_data(data=Level1Record.from_proto_model(resp.record))
return Result.ok_data(data=Level1Record().from_proto_model(resp.record))
else:
return Result.error(message = str(resp.error.detail))
except grpc.RpcError as e:
......
......@@ -69,7 +69,7 @@ class Level1DataApi(object):
if resp.record is None or resp.record.id == 0:
return Result.error(message=f"id:{id} not found")
return Result.ok_data(data = Level1Record.from_proto_model(resp.record))
return Result.ok_data(data = Level1Record().from_proto_model(resp.record))
except grpc.RpcError as e:
return Result.error(message="%s:%s" % (e.code().value, e.details))
......@@ -157,7 +157,7 @@ class Level1DataApi(object):
try:
resp,_ = self.stub.Write.with_call(req,metadata = get_auth_headers())
if resp.success:
return Result.ok_data(data=Level1Record.from_proto_model(resp.record))
return Result.ok_data(data=Level1Record().from_proto_model(resp.record))
else:
return Result.error(message = str(resp.error.detail))
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