Commit 1442575b authored by Wei Shoulin's avatar Wei Shoulin
Browse files

new test

parent eef6321b
from .brick import BrickApi
from .detector import DetectorApi
from .level2producer import Level1PrcApi
from .level2producer import Level2ProducerApi
from .observation import ObservationApi
\ No newline at end of file
......@@ -2,7 +2,7 @@ import grpc
from csst_dfs_commons.models import Result
from csst_dfs_commons.models.common import from_proto_model_list
from csst_dfs_commons.models.facility import Brick, FindObsStatus, BrickLevel1
from csst_dfs_commons.models.facility import Brick, BrickObsStatus, BrickLevel1
from csst_dfs_proto.facility.brick import brick_pb2, brick_pb2_grpc
......@@ -53,7 +53,7 @@ class BrickApi(object):
id = brick_id
),metadata = get_auth_headers())
if resp.brick is None or resp.brick.id == -1:
if resp.record is None or (resp.record.id == 0 and resp.record.ra == 0.0 and resp.record.dec == 0.0):
return Result.error(message=f"{brick_id} not found")
return Result.ok_data(data=Brick().from_proto_model(resp.record))
......@@ -71,8 +71,8 @@ class BrickApi(object):
:returns: csst_dfs_common.models.Result
'''
rec = brick_pb2.Brick(
id = get_parameter(kwargs, "id", 0),
rec = brick_pb2.BrickRecord(
id = get_parameter(kwargs, "id", -1),
ra = get_parameter(kwargs, "ra", 0.0),
dec = get_parameter(kwargs, "dec", 0.0),
boundingbox = get_parameter(kwargs, "boundingbox", "")
......@@ -93,18 +93,20 @@ class BrickApi(object):
:param kwargs:
brick_id = [int],
band = [string]
band = [string],
limit = [int]
:returns: csst_dfs_common.models.Result
'''
try:
resp, _ = self.stub.FindObsStatus.with_call(brick_pb2.FindObsStatusReq(
brick_id = get_parameter(kwargs, "brick_id", -1),
band = get_parameter(kwargs, "band", "")
band = get_parameter(kwargs, "band", ""),
limit = get_parameter(kwargs, "limit", 0)
),metadata = get_auth_headers())
if resp.success:
return Result.ok_data(data = from_proto_model_list(FindObsStatus, resp.records)).append("totalCount", resp.totalCount)
return Result.ok_data(data = from_proto_model_list(BrickObsStatus, resp.records)).append("totalCount", resp.totalCount)
else:
return Result.error(message = str(resp.error.detail))
......@@ -117,7 +119,8 @@ class BrickApi(object):
:param kwargs: Parameter dictionary, support:
brick_id = [int]\n
level1_id = [int]\n
module = [str]
module = [str],
limit = [int]
:returns: csst_dfs_common.models.Result
'''
......@@ -125,7 +128,8 @@ class BrickApi(object):
resp, _ = self.stub.FindLevel1.with_call(brick_pb2.FindLevel1Req(
brick_id = get_parameter(kwargs, "brick_id", -1),
level1_id = get_parameter(kwargs, "level1_id", 0),
module = get_parameter(kwargs, "limit", "")
module = get_parameter(kwargs, "limit", ""),
limit = get_parameter(kwargs, "limit", 0)
),metadata = get_auth_headers())
if resp.success:
......
......@@ -101,9 +101,8 @@ class Level2ProducerApi(object):
:returns: csst_dfs_common.models.Result
'''
try:
resp, _ = self.stub.FindNexts.with_call(level2producer_pb2.FindNextsReq(
id = get_parameter(kwargs, "id")
id = get_parameter(kwargs, "id", 0)
),metadata = get_auth_headers())
if resp.success:
......@@ -150,15 +149,16 @@ class Level2ProducerApi(object):
:returns: csst_dfs_common.models.Result
'''
try:
resp,_ = self.stub.Update.with_call(
level2producer_pb2.UpdateReq(
rec = level2producer_pb2.Level2ProducerRecord(
id = get_parameter(kwargs, "id", 0),
name = get_parameter(kwargs, "name", ""),
gitlink = get_parameter(kwargs, "gitlink", ""),
paramfiles = get_parameter(kwargs, "paramfiles", ""),
priority = get_parameter(kwargs, "priority", 0),
pre_producers = get_parameter(kwargs, "pre_producers",[])
),
)
resp,_ = self.stub.Update.with_call(
level2producer_pb2.UpdateReq(record = rec),
metadata = get_auth_headers()
)
if resp.success:
......@@ -244,6 +244,7 @@ class Level2ProducerApi(object):
:returns: csst_dfs_common.models.Result
'''
rec = level2producer_pb2.Level2JobRecord(
id = get_parameter(kwargs, "id", 0),
dag = get_parameter(kwargs, "dag", ""),
......@@ -316,7 +317,7 @@ class Level2ProducerApi(object):
except grpc.RpcError as e:
return Result.error(message="%s:%s" % (e.code().value, e.details))
def udpate_running(self, **kwargs):
def update_running(self, **kwargs):
''' udpate a Level2ProducerRuningRecord data
:param kwargs: Parameter dictionary, key items support:
......@@ -353,18 +354,18 @@ class Level2ProducerApi(object):
return Result.error(message="%s:%s" % (e.code().value, e.details))
def find_running(self, **kwargs):
''' udpate a Level2ProducerRuningRecord data
''' find Level2ProducerRuningRecord data
:param kwargs: Parameter dictionary, key items support:
job_id = [int]\n
producer_id = [int]\n
brick_id = [int]\n
create_time = (start, end),\n
prc_status = [int]\n
prc_result = [str]
create_time : (start, end)\n
limit = [int]
:returns: csst_dfs_common.models.Result
'''
'''
req = level2producer_pb2.FindRunningReq(
job_id = get_parameter(kwargs, "job_id", 0),
producer_id = get_parameter(kwargs, "producer_id", 0),
......
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