Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-dfs
csst-dfs-api-cluster
Commits
735cb600
Commit
735cb600
authored
Jul 28, 2021
by
Wei Shoulin
Browse files
get latest cal
parent
0b416475
Changes
2
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_cluster/facility/calmerge.py
View file @
735cb600
...
...
@@ -13,6 +13,29 @@ class CalMergeApi(object):
def
__init__
(
self
):
self
.
stub
=
calmerge_pb2_grpc
.
CalMergeSrvStub
(
ServiceProxy
().
channel
())
def
get_latest_by_l0
(
self
,
**
kwargs
):
''' retrieve calibration merge records from database by level0 data
parameter kwargs:
level0_id: [str]
ref_type: [str]
return: csst_dfs_common.models.Result
'''
try
:
resp
,
_
=
self
.
stub
.
GetLatestByL0
.
with_call
(
calmerge_pb2
.
GetLatestByL0Req
(
level0_id
=
get_parameter
(
kwargs
,
"level0_id"
),
ref_type
=
get_parameter
(
kwargs
,
"ref_type"
)),
metadata
=
get_auth_headers
())
if
resp
.
record
.
id
==
0
:
return
Result
.
error
(
message
=
f
"not found"
)
return
Result
.
ok_data
(
data
=
CalMergeRecord
().
from_proto_model
(
resp
.
record
))
except
grpc
.
RpcError
as
e
:
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
def
find
(
self
,
**
kwargs
):
''' retrieve calibration merge records from database
...
...
tests/test_facility_cal_merge.py
View file @
735cb600
...
...
@@ -15,6 +15,10 @@ class CalMergeApiTestCase(unittest.TestCase):
obs_time
=
(
"2021-06-01 11:12:13"
,
"2021-06-08 11:12:13"
))
print
(
'find:'
,
recs
)
def
test_get_latest_by_l0
(
self
):
rec
=
self
.
api
.
get_latest_by_l0
(
level0_id
=
'000001102'
,
ref_type
=
"bias"
)
print
(
'get_latest_by_l0:'
,
rec
)
def
test_get
(
self
):
rec
=
self
.
api
.
get
(
id
=
4
)
print
(
'get:'
,
rec
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment