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
7c94a360
Commit
7c94a360
authored
Nov 23, 2022
by
Wei Shoulin
Browse files
add catalog_query_file
parent
1294df3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_cluster/common/service.py
View file @
7c94a360
...
@@ -6,11 +6,9 @@ class ServiceProxy:
...
@@ -6,11 +6,9 @@ class ServiceProxy:
self
.
gateway
=
os
.
getenv
(
"CSST_DFS_GATEWAY"
,
'172.31.248.218:30880'
)
self
.
gateway
=
os
.
getenv
(
"CSST_DFS_GATEWAY"
,
'172.31.248.218:30880'
)
def
channel
(
self
):
def
channel
(
self
):
options
=
[(
'grpc.max_send_message_length'
,
1000
*
1024
*
1024
),
options
=
((
'grpc.max_send_message_length'
,
1000
*
1024
*
1024
),
(
'grpc.max_receive_message_length'
,
1000
*
1024
*
1024
),
(
'grpc.max_receive_message_length'
,
1000
*
1024
*
1024
))
(
'grpc.enable_retries'
,
1
),
channel
=
grpc
.
insecure_channel
(
self
.
gateway
,
options
=
options
,
compression
=
grpc
.
Compression
.
Gzip
)
(
'grpc.service_config'
,
'{ "retryPolicy":{ "maxAttempts": 4, "initialBackoff": "0.1s", "maxBackoff": "1s", "backoffMutiplier": 2, "retryableStatusCodes": [ "UNAVAILABLE" ] } }'
)]
channel
=
grpc
.
insecure_channel
(
self
.
gateway
,
options
=
options
)
try
:
try
:
grpc
.
channel_ready_future
(
channel
).
result
(
timeout
=
10
)
grpc
.
channel_ready_future
(
channel
).
result
(
timeout
=
10
)
except
grpc
.
FutureTimeoutError
:
except
grpc
.
FutureTimeoutError
:
...
...
csst_dfs_api_cluster/msc/level2.py
View file @
7c94a360
...
@@ -64,8 +64,6 @@ class Level2DataApi(object):
...
@@ -64,8 +64,6 @@ class Level2DataApi(object):
ra: [float] in deg
ra: [float] in deg
dec: [float] in deg
dec: [float] in deg
radius: [float] in deg
radius: [float] in deg
min_mag: [float]
max_mag: [float]
obs_time: (start, end),
obs_time: (start, end),
limit: limits returns the number of records,default 0:no-limit
limit: limits returns the number of records,default 0:no-limit
...
@@ -93,6 +91,42 @@ class Level2DataApi(object):
...
@@ -93,6 +91,42 @@ class Level2DataApi(object):
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
()))
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
):
def
get
(
self
,
**
kwargs
):
''' fetch a record from database
''' fetch a record from database
...
...
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