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-pipeline
csst_common
Commits
91385fb7
Commit
91385fb7
authored
Dec 20, 2023
by
BO ZHANG
🏀
Browse files
move retry to utils
parent
5f412905
Pipeline
#2595
running with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
csst_common/__init__.py
View file @
91385fb7
...
...
@@ -10,11 +10,13 @@ Modified-History:
2023-12-15, Bo Zhang, add module header
"""
from
.decorator
import
parameterized_module_decorator
from
.file
import
File
from
.pipeline
import
Pipeline
from
.status
import
CsstResult
,
CsstStatus
from
.time
import
now
from
.dfs
import
DFS
from
.ccds
import
CCDS
from
.utils
import
retry
__version__
=
"0.0.2"
...
...
@@ -22,5 +24,4 @@ __all__ = [
"Pipeline"
,
"File"
,
"CsstResult"
,
"parameterized_module_decorator"
,
]
csst_common/ccds/ccds.py
View file @
91385fb7
...
...
@@ -97,29 +97,6 @@ class CCDS:
# 'ledflat': '/ccds_root/references/msc/csst_msc_ms_ledflat_10_000001.fits'}
return
refs_fp
@
staticmethod
def
retry
(
func
,
n
,
*
args
,
**
kwargs
):
for
attempt
in
range
(
1
,
n
+
1
):
try
:
res
=
func
(
*
args
,
**
kwargs
)
# assert res["code"] == 0, res
return
res
except
BaseException
as
e
:
print
(
f
"Error occurs:
{
e
.
__repr__
()
}
"
)
raise
RuntimeError
(
f
"All
{
n
}
attempts failed."
)
def
retry
(
func
,
n
=
3
):
@
functools
.
wraps
(
func
)
def
wrapper
(
*
args
,
**
kwargs
):
for
attempt
in
range
(
1
,
n
+
1
):
try
:
result
=
func
(
*
args
,
**
kwargs
)
return
result
except
Exception
as
e
:
print
(
f
"尝试
{
attempt
}
/
{
n
}
失败:
{
e
}
"
)
raise
RuntimeError
(
"All attempts failed."
)
"""
file_path="/dfsroot/L0/MSC/SCIE/62030/10160000105/MS/CSST_MSC_MS_SCIE_20280916072059_20280916072329_10160000105_10_L0_V01.fits"
...
...
csst_common/dfs.py
View file @
91385fb7
...
...
@@ -25,16 +25,6 @@ class DFS:
def
__init__
(
self
,
n_try
=
5
):
self
.
n_try
=
n_try
def
retry
(
self
,
func
,
*
args
,
**
kwargs
):
for
attempt
in
range
(
self
.
n_try
):
try
:
res
=
func
(
*
args
,
**
kwargs
)
assert
res
[
"code"
]
==
0
,
res
return
res
except
BaseException
as
e
:
print
(
f
"Error occurs:
{
e
.
__repr__
()
}
"
)
raise
RuntimeError
(
"All attempts failed."
)
# DFS APIs
@
property
def
L0DataApi
(
self
):
...
...
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