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-client
Commits
d5a88729
Commit
d5a88729
authored
Nov 11, 2025
by
Wei Shoulin
Browse files
refactor(catalog): update error handling and pandas import logic
parent
9ac0f71c
Pipeline
#11178
failed with stages
in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
csst_dfs_client/catalog.py
View file @
d5a88729
...
@@ -37,6 +37,7 @@ def search(ra: float,
...
@@ -37,6 +37,7 @@ def search(ra: float,
columns
=
[
'*'
]
columns
=
[
'*'
]
try
:
try
:
import
pandas
as
pd
datas
=
request
.
post
(
'/api/catalog'
,
{
datas
=
request
.
post
(
'/api/catalog'
,
{
'ra'
:
ra
,
'ra'
:
ra
,
'dec'
:
dec
,
'dec'
:
dec
,
...
@@ -74,6 +75,8 @@ def all_catalog_names() -> Result:
...
@@ -74,6 +75,8 @@ def all_catalog_names() -> Result:
return
datas
return
datas
records
=
pickle
.
loads
(
datas
.
_content
)
records
=
pickle
.
loads
(
datas
.
_content
)
return
Result
.
ok_data
(
data
=
records
)
return
Result
.
ok_data
(
data
=
records
)
except
ImportError
:
return
Result
.
error
(
"pandas is not installed"
)
except
Exception
as
e
:
except
Exception
as
e
:
return
Result
.
error
(
str
(
e
))
return
Result
.
error
(
str
(
e
))
...
@@ -89,10 +92,13 @@ def describe_catalog(catalog_name: str) -> Result:
...
@@ -89,10 +92,13 @@ def describe_catalog(catalog_name: str) -> Result:
"""
"""
try
:
try
:
import
pandas
as
pd
datas
=
request
.
get
(
f
'/api/catalog/describe/
{
catalog_name
}
'
)
datas
=
request
.
get
(
f
'/api/catalog/describe/
{
catalog_name
}
'
)
if
datas
and
isinstance
(
datas
,
Result
):
if
datas
and
isinstance
(
datas
,
Result
):
return
datas
return
datas
records
=
pickle
.
loads
(
datas
.
_content
)
records
=
pickle
.
loads
(
datas
.
_content
)
return
Result
.
ok_data
(
data
=
records
)
return
Result
.
ok_data
(
data
=
records
)
except
ImportError
:
return
Result
.
error
(
"pandas is not installed"
)
except
Exception
as
e
:
except
Exception
as
e
:
return
Result
.
error
(
str
(
e
))
return
Result
.
error
(
str
(
e
))
csst_dfs_client/common/__init__.py
View file @
d5a88729
...
@@ -30,9 +30,9 @@ class Result(dict):
...
@@ -30,9 +30,9 @@ class Result(dict):
return
str
(
self
[
"message"
])
return
str
(
self
[
"message"
])
@
staticmethod
@
staticmethod
def
error
(
code
:
int
=
500
,
message
:
str
=
""
)
->
"Result"
:
def
error
(
message
:
str
=
""
)
->
"Result"
:
r
=
Result
()
r
=
Result
()
r
[
"code"
]
=
code
r
[
"code"
]
=
500
r
[
"message"
]
=
message
r
[
"message"
]
=
message
return
r
return
r
...
...
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