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
0f2d363b
Commit
0f2d363b
authored
Jun 08, 2024
by
Wei Shoulin
Browse files
data to dict
parent
5c53ab5c
Changes
2
Show whitespace changes
Inline
Side-by-side
csst_dfs_api_cluster/common/utils.py
View file @
0f2d363b
...
...
@@ -121,7 +121,8 @@ def find_req(function, kwargs):
else
:
columns
.
append
(
col
)
return
Result
.
ok_data
(
data
=
records
).
append
(
"totalCount"
,
totalCount
)
\
data
=
Record
.
from_list
(
records
,
columns
)
return
Result
.
ok_data
(
data
=
data
).
append
(
"totalCount"
,
totalCount
)
\
.
append
(
"columns"
,
columns
)
except
grpc
.
RpcError
as
e
:
...
...
@@ -137,9 +138,18 @@ def get_req(function, kwargs):
)
if
resp
.
record
:
record
=
pickle
.
loads
(
resp
.
record
)
cols
=
resp
.
columns
columns
=
[]
for
col
in
cols
:
if
col
in
columns
:
columns
.
append
(
"%s_1"
%
(
col
,
))
else
:
columns
.
append
(
col
)
if
record
:
data
=
Record
.
from_tuple
(
record
,
resp
.
columns
)
return
Result
.
ok_data
(
data
=
data
)
.
append
(
"columns"
,
resp
.
columns
)
data
=
Record
.
from_tuple
(
record
,
columns
)
return
Result
.
ok_data
(
data
=
data
)
else
:
return
Result
.
error
(
message
=
f
"not found"
)
else
:
...
...
@@ -173,7 +183,16 @@ def write_req(function, kwargs):
if
resp
.
success
:
if
resp
.
record
:
record
=
pickle
.
loads
(
resp
.
record
)
return
Result
.
ok_data
(
data
=
record
).
append
(
"columns"
,
resp
.
columns
)
cols
=
resp
.
columns
columns
=
[]
for
col
in
cols
:
if
col
in
columns
:
columns
.
append
(
"%s_1"
%
(
col
,
))
else
:
columns
.
append
(
col
)
if
record
:
data
=
Record
.
from_tuple
(
record
,
columns
)
return
Result
.
ok_data
(
data
=
data
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
except
grpc
.
RpcError
as
e
:
...
...
@@ -197,7 +216,16 @@ def write_stream_req(function, byte_stream, kwargs):
if
resp
.
success
:
if
resp
.
record
:
record
=
pickle
.
loads
(
resp
.
record
)
return
Result
.
ok_data
(
data
=
record
).
append
(
"columns"
,
resp
.
columns
)
cols
=
resp
.
columns
columns
=
[]
for
col
in
cols
:
if
col
in
columns
:
columns
.
append
(
"%s_1"
%
(
col
,
))
else
:
columns
.
append
(
col
)
if
record
:
data
=
Record
.
from_tuple
(
record
,
columns
)
return
Result
.
ok_data
(
data
=
data
)
else
:
return
Result
.
error
(
message
=
str
(
resp
.
error
.
detail
))
except
grpc
.
RpcError
as
e
:
...
...
csst_dfs_api_cluster/facility/level0.py
View file @
0f2d363b
...
...
@@ -10,8 +10,6 @@ class Level0DataApi(object):
@
grpc_channel
def
find
(
self
,
**
kwargs
):
result
=
find_req
(
"Level0Servicer.Find"
,
kwargs
)
data
=
Record
.
from_list
(
result
[
"data"
],
result
[
"columns"
])
result
[
"data"
]
=
data
return
result
@
grpc_channel
def
get
(
self
,
**
kwargs
):
...
...
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