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