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
1442575b
Commit
1442575b
authored
Apr 22, 2022
by
Wei Shoulin
Browse files
new test
parent
eef6321b
Changes
3
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_cluster/facility/__init__.py
View file @
1442575b
from
.brick
import
BrickApi
from
.brick
import
BrickApi
from
.detector
import
DetectorApi
from
.detector
import
DetectorApi
from
.level2producer
import
Level
1
Pr
c
Api
from
.level2producer
import
Level
2
Pr
oducer
Api
from
.observation
import
ObservationApi
from
.observation
import
ObservationApi
\ No newline at end of file
csst_dfs_api_cluster/facility/brick.py
View file @
1442575b
...
@@ -2,7 +2,7 @@ import grpc
...
@@ -2,7 +2,7 @@ import grpc
from
csst_dfs_commons.models
import
Result
from
csst_dfs_commons.models
import
Result
from
csst_dfs_commons.models.common
import
from_proto_model_list
from
csst_dfs_commons.models.common
import
from_proto_model_list
from
csst_dfs_commons.models.facility
import
Brick
,
Find
ObsStatus
,
BrickLevel1
from
csst_dfs_commons.models.facility
import
Brick
,
Brick
ObsStatus
,
BrickLevel1
from
csst_dfs_proto.facility.brick
import
brick_pb2
,
brick_pb2_grpc
from
csst_dfs_proto.facility.brick
import
brick_pb2
,
brick_pb2_grpc
...
@@ -53,7 +53,7 @@ class BrickApi(object):
...
@@ -53,7 +53,7 @@ class BrickApi(object):
id
=
brick_id
id
=
brick_id
),
metadata
=
get_auth_headers
())
),
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
.
error
(
message
=
f
"
{
brick_id
}
not found"
)
return
Result
.
ok_data
(
data
=
Brick
().
from_proto_model
(
resp
.
record
))
return
Result
.
ok_data
(
data
=
Brick
().
from_proto_model
(
resp
.
record
))
...
@@ -71,8 +71,8 @@ class BrickApi(object):
...
@@ -71,8 +71,8 @@ class BrickApi(object):
:returns: csst_dfs_common.models.Result
:returns: csst_dfs_common.models.Result
'''
'''
rec
=
brick_pb2
.
Brick
(
rec
=
brick_pb2
.
Brick
Record
(
id
=
get_parameter
(
kwargs
,
"id"
,
0
),
id
=
get_parameter
(
kwargs
,
"id"
,
-
1
),
ra
=
get_parameter
(
kwargs
,
"ra"
,
0.0
),
ra
=
get_parameter
(
kwargs
,
"ra"
,
0.0
),
dec
=
get_parameter
(
kwargs
,
"dec"
,
0.0
),
dec
=
get_parameter
(
kwargs
,
"dec"
,
0.0
),
boundingbox
=
get_parameter
(
kwargs
,
"boundingbox"
,
""
)
boundingbox
=
get_parameter
(
kwargs
,
"boundingbox"
,
""
)
...
@@ -93,18 +93,20 @@ class BrickApi(object):
...
@@ -93,18 +93,20 @@ class BrickApi(object):
:param kwargs:
:param kwargs:
brick_id = [int],
brick_id = [int],
band = [string]
band = [string],
limit = [int]
:returns: csst_dfs_common.models.Result
:returns: csst_dfs_common.models.Result
'''
'''
try
:
try
:
resp
,
_
=
self
.
stub
.
FindObsStatus
.
with_call
(
brick_pb2
.
FindObsStatusReq
(
resp
,
_
=
self
.
stub
.
FindObsStatus
.
with_call
(
brick_pb2
.
FindObsStatusReq
(
brick_id
=
get_parameter
(
kwargs
,
"brick_id"
,
-
1
),
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
())
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Find
ObsStatus
,
resp
.
records
)).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Brick
ObsStatus
,
resp
.
records
)).
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
@@ -117,7 +119,8 @@ class BrickApi(object):
...
@@ -117,7 +119,8 @@ class BrickApi(object):
:param kwargs: Parameter dictionary, support:
:param kwargs: Parameter dictionary, support:
brick_id = [int]
\n
brick_id = [int]
\n
level1_id = [int]
\n
level1_id = [int]
\n
module = [str]
module = [str],
limit = [int]
:returns: csst_dfs_common.models.Result
:returns: csst_dfs_common.models.Result
'''
'''
...
@@ -125,7 +128,8 @@ class BrickApi(object):
...
@@ -125,7 +128,8 @@ class BrickApi(object):
resp
,
_
=
self
.
stub
.
FindLevel1
.
with_call
(
brick_pb2
.
FindLevel1Req
(
resp
,
_
=
self
.
stub
.
FindLevel1
.
with_call
(
brick_pb2
.
FindLevel1Req
(
brick_id
=
get_parameter
(
kwargs
,
"brick_id"
,
-
1
),
brick_id
=
get_parameter
(
kwargs
,
"brick_id"
,
-
1
),
level1_id
=
get_parameter
(
kwargs
,
"level1_id"
,
0
),
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
())
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
if
resp
.
success
:
...
...
csst_dfs_api_cluster/facility/level2producer.py
View file @
1442575b
...
@@ -101,9 +101,8 @@ class Level2ProducerApi(object):
...
@@ -101,9 +101,8 @@ class Level2ProducerApi(object):
:returns: csst_dfs_common.models.Result
:returns: csst_dfs_common.models.Result
'''
'''
try
:
try
:
resp
,
_
=
self
.
stub
.
FindNexts
.
with_call
(
level2producer_pb2
.
FindNextsReq
(
resp
,
_
=
self
.
stub
.
FindNexts
.
with_call
(
level2producer_pb2
.
FindNextsReq
(
id
=
get_parameter
(
kwargs
,
"id"
)
id
=
get_parameter
(
kwargs
,
"id"
,
0
)
),
metadata
=
get_auth_headers
())
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
if
resp
.
success
:
...
@@ -150,15 +149,16 @@ class Level2ProducerApi(object):
...
@@ -150,15 +149,16 @@ class Level2ProducerApi(object):
:returns: csst_dfs_common.models.Result
:returns: csst_dfs_common.models.Result
'''
'''
try
:
try
:
resp
,
_
=
self
.
stub
.
Update
.
with_call
(
rec
=
level2producer_pb2
.
Level2ProducerRecord
(
level2producer_pb2
.
UpdateReq
(
id
=
get_parameter
(
kwargs
,
"id"
,
0
),
id
=
get_parameter
(
kwargs
,
"id"
,
0
),
name
=
get_parameter
(
kwargs
,
"name"
,
""
),
name
=
get_parameter
(
kwargs
,
"name"
,
""
),
gitlink
=
get_parameter
(
kwargs
,
"gitlink"
,
""
),
gitlink
=
get_parameter
(
kwargs
,
"gitlink"
,
""
),
paramfiles
=
get_parameter
(
kwargs
,
"paramfiles"
,
""
),
paramfiles
=
get_parameter
(
kwargs
,
"paramfiles"
,
""
),
priority
=
get_parameter
(
kwargs
,
"priority"
,
0
),
priority
=
get_parameter
(
kwargs
,
"priority"
,
0
),
pre_producers
=
get_parameter
(
kwargs
,
"pre_producers"
,[])
pre_producers
=
get_parameter
(
kwargs
,
"pre_producers"
,[])
),
)
resp
,
_
=
self
.
stub
.
Update
.
with_call
(
level2producer_pb2
.
UpdateReq
(
record
=
rec
),
metadata
=
get_auth_headers
()
metadata
=
get_auth_headers
()
)
)
if
resp
.
success
:
if
resp
.
success
:
...
@@ -244,6 +244,7 @@ class Level2ProducerApi(object):
...
@@ -244,6 +244,7 @@ class Level2ProducerApi(object):
:returns: csst_dfs_common.models.Result
:returns: csst_dfs_common.models.Result
'''
'''
rec
=
level2producer_pb2
.
Level2JobRecord
(
rec
=
level2producer_pb2
.
Level2JobRecord
(
id
=
get_parameter
(
kwargs
,
"id"
,
0
),
id
=
get_parameter
(
kwargs
,
"id"
,
0
),
dag
=
get_parameter
(
kwargs
,
"dag"
,
""
),
dag
=
get_parameter
(
kwargs
,
"dag"
,
""
),
...
@@ -316,7 +317,7 @@ class Level2ProducerApi(object):
...
@@ -316,7 +317,7 @@ class Level2ProducerApi(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
u
d
pate_running
(
self
,
**
kwargs
):
def
up
d
ate_running
(
self
,
**
kwargs
):
''' udpate a Level2ProducerRuningRecord data
''' udpate a Level2ProducerRuningRecord data
:param kwargs: Parameter dictionary, key items support:
:param kwargs: Parameter dictionary, key items support:
...
@@ -353,18 +354,18 @@ class Level2ProducerApi(object):
...
@@ -353,18 +354,18 @@ class Level2ProducerApi(object):
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
def
find_running
(
self
,
**
kwargs
):
def
find_running
(
self
,
**
kwargs
):
'''
udpate a
Level2ProducerRuningRecord data
'''
find
Level2ProducerRuningRecord data
:param kwargs: Parameter dictionary, key items support:
:param kwargs: Parameter dictionary, key items support:
job_id = [int]
\n
job_id = [int]
\n
producer_id = [int]
\n
producer_id = [int]
\n
brick_id = [int]
\n
brick_id = [int]
\n
create_time = (start, end),
\n
prc_status = [int]
\n
prc_status = [int]
\n
prc_result = [str]
create_time : (start, end)
\n
limit = [int]
:returns: csst_dfs_common.models.Result
:returns: csst_dfs_common.models.Result
'''
'''
req
=
level2producer_pb2
.
FindRunningReq
(
req
=
level2producer_pb2
.
FindRunningReq
(
job_id
=
get_parameter
(
kwargs
,
"job_id"
,
0
),
job_id
=
get_parameter
(
kwargs
,
"job_id"
,
0
),
producer_id
=
get_parameter
(
kwargs
,
"producer_id"
,
0
),
producer_id
=
get_parameter
(
kwargs
,
"producer_id"
,
0
),
...
...
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