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
061bf13a
Commit
061bf13a
authored
Dec 15, 2023
by
BO ZHANG
🏀
Browse files
refactor message and timestamp
parent
90ae3a25
Pipeline
#2432
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
csst_common/data_manager.py
View file @
061bf13a
...
...
@@ -880,7 +880,7 @@ class CsstMsDataManager:
self
.
logger_ppl
.
info
(
f
"Results from DFS CATAPI:
\n
"
f
" - code =
{
cat
[
'code'
]
}
\n
"
f
" - m
sg
=
{
cat
[
'm
sg
'
]
}
\n
"
f
" - m
essage
=
{
cat
[
'm
essage
'
]
}
\n
"
f
" - totalCount =
{
cat
[
'totalCount'
]
}
\n
"
f
" - columns =
{
cat
[
'columns'
]
}
"
)
...
...
@@ -889,7 +889,7 @@ class CsstMsDataManager:
self
.
logger_ppl
.
info
(
f
"Results from DFS CATAPI:
\n
"
f
" - code =
{
cat
[
'code'
]
}
\n
"
f
" - m
sg
=
{
cat
[
'm
sg
'
]
}
"
f
" - m
essage
=
{
cat
[
'm
essage
'
]
}
"
)
raise
ValueError
(
"Bad catalog query result!"
)
...
...
@@ -921,7 +921,7 @@ class CsstMsDataManager:
# query for L0 data
print
(
f
"Query obs_id=
{
obs_id
}
..."
,
end
=
""
)
recs
=
Level0DataApi
().
find
(
obs_id
=
obs_id
)
print
(
"Message
Writer
:
\n
"
,
recs
)
print
(
"Message:
\n
"
,
recs
)
print
(
f
"
{
recs
[
'totalCount'
]
}
records obtained!"
)
assert
recs
[
"code"
]
==
0
assert
recs
[
"totalCount"
]
>
0
...
...
csst_common/logger.py
View file @
061bf13a
...
...
@@ -51,7 +51,7 @@ def get_logger(name: str = "CSST pipeline", filename: Optional[str] = None):
# logging formatter
formatter
=
logging
.
Formatter
(
"%(asctime)s - %(levelname)s - %(module)s.py:%(lineno)d - %(m
sg
)s"
"%(asctime)s - %(levelname)s - %(module)s.py:%(lineno)d - %(m
essage
)s"
)
# stream handler
...
...
csst_common/pipeline.py
View file @
061bf13a
...
...
@@ -98,8 +98,8 @@ class Pipeline:
os
.
chdir
(
self
.
dir_output
)
# Frequently used files
self
.
m
sg
=
Message
Writer
(
os
.
path
.
join
(
self
.
dir_output
,
"message.txt"
))
self
.
t
sr
=
Timestamp
Recorder
(
os
.
path
.
join
(
self
.
dir_output
,
"timestamp.txt"
))
self
.
m
essage
=
Message
(
os
.
path
.
join
(
self
.
dir_output
,
"message.txt"
))
self
.
t
imestamp
=
Timestamp
(
os
.
path
.
join
(
self
.
dir_output
,
"timestamp.txt"
))
# self.exit_code = ExitCode(os.path.join(self.dir_output, "exit_code"))
# self.error_trace = ErrorTrace(os.path.join(self.dir_output, "error_trace"))
...
...
@@ -168,10 +168,10 @@ class Pipeline:
# f.write(s)
class
Message
Writer
:
class
Message
:
"""Write JSON format messages to file."""
def
__init__
(
self
,
file_path
=
""
):
def
__init__
(
self
,
file_path
:
str
=
""
):
self
.
file_path
=
file_path
def
__repr__
(
self
):
...
...
@@ -211,12 +211,12 @@ class MessageWriter:
# print(f"Exit with code {code} (written to '{self.file_path}')")
class
Timestamp
Recorder
:
def
__init__
(
self
,
file_path
:
str
=
"t
sr
.txt"
):
class
Timestamp
:
def
__init__
(
self
,
file_path
:
str
=
"t
imestamp
.txt"
):
"""
Timestamp
Recorder
Class.
Timestamp Class.
Initialize a Timestamp
Recorder
object anc connect it to `file_path`.
Initialize a Timestamp object anc connect it to `file_path`.
Parameters
----------
...
...
@@ -226,7 +226,7 @@ class TimestampRecorder:
self
.
file_path
=
file_path
def
__repr__
(
self
):
return
f
"< Timestamp
Recorder
[
{
self
.
file_path
}
] >"
return
f
"< Timestamp [
{
self
.
file_path
}
] >"
def
empty
(
self
):
"""Clean time stamp file."""
...
...
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