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
7275127f
Commit
7275127f
authored
Jun 07, 2021
by
Wei Shoulin
Browse files
to_model
parent
dfa8873a
Changes
8
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_cluster/common/catalog.py
View file @
7275127f
import
grpc
from
csst_dfs_commons.models
import
Result
from
csst_dfs_commons.models.common
import
from_proto_model_list
,
Gaia3Record
from
csst_dfs_proto.common.ephem
import
ephem_pb2
,
ephem_pb2_grpc
from
.service
import
ServiceProxy
from
.constants
import
*
...
...
@@ -34,7 +36,7 @@ class CatalogApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Gaia3Record
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
csst_dfs_api_cluster/facility/calmerge.py
View file @
7275127f
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
CalMergeRecord
from
csst_dfs_proto.facility.calmerge
import
calmerge_pb2
,
calmerge_pb2_grpc
from
..common.service
import
ServiceProxy
...
...
@@ -38,7 +41,7 @@ class CalMergeApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
CalMergeRecord
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
@@ -59,10 +62,10 @@ class CalMergeApi(object):
id
=
id
),
metadata
=
get_auth_headers
())
if
resp
.
record
is
None
:
if
resp
.
record
.
id
==
0
:
return
Result
.
error
(
message
=
f
"id:
{
id
}
not found"
)
return
Result
.
ok_data
(
data
=
resp
.
record
)
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
))
...
...
@@ -148,7 +151,7 @@ class CalMergeApi(object):
try
:
resp
,
_
=
self
.
stub
.
Write
.
with_call
(
req
,
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
CalMergeRecord
().
from_proto_model
(
resp
.
record
)
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
except
grpc
.
RpcError
as
e
:
...
...
csst_dfs_api_cluster/facility/detector.py
View file @
7275127f
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
Detector
,
DetectorStatus
from
csst_dfs_proto.facility.detector
import
detector_pb2
,
detector_pb2_grpc
from
..common.service
import
ServiceProxy
...
...
@@ -26,7 +29,7 @@ class DetectorApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Detector
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
@@ -50,7 +53,7 @@ class DetectorApi(object):
if
not
resp
.
record
.
no
:
return
Result
.
error
(
message
=
f
"no:
{
no
}
not found"
)
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Detector
().
from_proto_model
(
resp
.
record
)
)
except
grpc
.
RpcError
as
e
:
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
...
...
@@ -132,7 +135,7 @@ class DetectorApi(object):
try
:
resp
,
_
=
self
.
stub
.
Write
.
with_call
(
req
,
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Detector
().
from_proto_model
(
resp
.
record
)
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
except
grpc
.
RpcError
as
e
:
...
...
@@ -157,7 +160,7 @@ class DetectorApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
DetectorStatus
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
@@ -178,10 +181,10 @@ class DetectorApi(object):
id
=
id
),
metadata
=
get_auth_headers
())
if
resp
.
record
is
None
:
if
resp
.
record
==
0
:
return
Result
.
error
(
message
=
f
"id:
{
id
}
not found"
)
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
DetectorStatus
().
from_proto_model
(
resp
.
record
)
)
except
grpc
.
RpcError
as
e
:
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
...
...
@@ -206,7 +209,7 @@ class DetectorApi(object):
try
:
resp
,
_
=
self
.
stub
.
WriteStatus
.
with_call
(
req
,
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
DetectorStatus
().
from_proto_model
(
resp
.
record
)
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
except
grpc
.
RpcError
as
e
:
...
...
csst_dfs_api_cluster/facility/level0.py
View file @
7275127f
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
Level0Record
from
csst_dfs_proto.facility.level0
import
level0_pb2
,
level0_pb2_grpc
from
..common.service
import
ServiceProxy
...
...
@@ -40,7 +43,7 @@ class Level0DataApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Level0Record
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
@@ -61,10 +64,10 @@ class Level0DataApi(object):
id
=
fits_id
),
metadata
=
get_auth_headers
())
if
resp
.
record
is
None
:
if
resp
.
record
is
None
or
resp
.
record
.
id
==
0
:
return
Result
.
error
(
message
=
f
"fits_id:
{
fits_id
}
not found"
)
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Level0Record
.
from_proto_model
(
resp
.
record
)
)
except
grpc
.
RpcError
as
e
:
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
...
...
@@ -141,7 +144,7 @@ class Level0DataApi(object):
try
:
resp
,
_
=
self
.
stub
.
Write
.
with_call
(
req
,
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Level0Record
.
from_proto_model
(
resp
.
record
)
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
csst_dfs_api_cluster/facility/level0prc.py
View file @
7275127f
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
Level0PrcRecord
from
csst_dfs_proto.facility.level0prc
import
level0prc_pb2
,
level0prc_pb2_grpc
from
..common.service
import
ServiceProxy
...
...
@@ -31,7 +34,7 @@ class Level0PrcApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Level0PrcRecord
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
@@ -90,7 +93,7 @@ class Level0PrcApi(object):
try
:
resp
,
_
=
self
.
stub
.
Write
.
with_call
(
req
,
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Level0PrcRecord
.
from_proto_model
(
resp
.
record
)
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
except
grpc
.
RpcError
as
e
:
...
...
csst_dfs_api_cluster/facility/observation.py
View file @
7275127f
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
Observation
from
csst_dfs_proto.facility.observation
import
observation_pb2
,
observation_pb2_grpc
from
..common.service
import
ServiceProxy
...
...
@@ -40,7 +43,7 @@ class ObservationApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Observation
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
@@ -61,10 +64,10 @@ class ObservationApi(object):
obs_id
=
obs_id
),
metadata
=
get_auth_headers
())
if
resp
.
observation
is
None
:
if
resp
.
observation
is
None
or
resp
.
observation
.
id
==
0
:
return
Result
.
error
(
message
=
f
"obs_id:
{
obs_id
}
not found"
)
return
Result
.
ok_data
(
data
=
resp
.
observation
)
return
Result
.
ok_data
(
data
=
Observation
.
from_proto_model
(
resp
.
observation
)
)
except
grpc
.
RpcError
as
e
:
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
...
...
@@ -138,7 +141,7 @@ class ObservationApi(object):
try
:
resp
,
_
=
self
.
stub
.
Write
.
with_call
(
req
,
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Observation
.
from_proto_model
(
resp
.
record
)
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
csst_dfs_api_cluster/ifs/level1.py
View file @
7275127f
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.ifs
import
Level1Record
from
csst_dfs_proto.ifs.level1
import
level1_pb2
,
level1_pb2_grpc
from
..common.service
import
ServiceProxy
...
...
@@ -42,7 +45,7 @@ class Level1DataApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Level1Record
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
@@ -63,10 +66,10 @@ class Level1DataApi(object):
id
=
fits_id
),
metadata
=
get_auth_headers
())
if
resp
.
record
is
None
:
if
resp
.
record
is
None
or
resp
.
record
.
id
==
0
:
return
Result
.
error
(
message
=
f
"id:
{
id
}
not found"
)
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Level1Record
.
from_proto_model
(
resp
.
record
)
)
except
grpc
.
RpcError
as
e
:
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
...
...
@@ -160,7 +163,7 @@ class Level1DataApi(object):
try
:
resp
,
_
=
self
.
stub
.
Write
.
with_call
(
req
,
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Level1Record
.
from_proto_model
(
resp
.
record
)
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
except
grpc
.
RpcError
as
e
:
...
...
csst_dfs_api_cluster/msc/level1.py
View file @
7275127f
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.msc
import
Level1Record
from
csst_dfs_proto.msc.level1
import
level1_pb2
,
level1_pb2_grpc
from
..common.service
import
ServiceProxy
...
...
@@ -42,7 +45,7 @@ class Level1DataApi(object):
),
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
records
).
append
(
"totalCount"
,
resp
.
totalCount
)
return
Result
.
ok_data
(
data
=
from_proto_model_list
(
Level1Record
,
resp
.
records
)
)
.
append
(
"totalCount"
,
resp
.
totalCount
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
...
...
@@ -63,10 +66,10 @@ class Level1DataApi(object):
id
=
fits_id
),
metadata
=
get_auth_headers
())
if
resp
.
record
is
None
:
if
resp
.
record
is
None
or
resp
.
record
.
id
==
0
:
return
Result
.
error
(
message
=
f
"id:
{
id
}
not found"
)
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Level1Record
.
from_proto_model
(
resp
.
record
)
)
except
grpc
.
RpcError
as
e
:
return
Result
.
error
(
message
=
"%s:%s"
%
(
e
.
code
().
value
,
e
.
details
))
...
...
@@ -154,7 +157,7 @@ class Level1DataApi(object):
try
:
resp
,
_
=
self
.
stub
.
Write
.
with_call
(
req
,
metadata
=
get_auth_headers
())
if
resp
.
success
:
return
Result
.
ok_data
(
data
=
resp
.
record
)
return
Result
.
ok_data
(
data
=
Level1Record
.
from_proto_model
(
resp
.
record
)
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
except
grpc
.
RpcError
as
e
:
...
...
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