Commit 061bf13a authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

refactor message and timestamp

parent 90ae3a25
Pipeline #2432 failed with stage
......@@ -880,7 +880,7 @@ class CsstMsDataManager:
self.logger_ppl.info(
f"Results from DFS CATAPI:\n"
f" - code = {cat['code']}\n"
f" - msg = {cat['msg']}\n"
f" - message = {cat['message']}\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" - msg = {cat['msg']}"
f" - message = {cat['message']}"
)
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("MessageWriter: \n", recs)
print("Message: \n", recs)
print(f"{recs['totalCount']} records obtained!")
assert recs["code"] == 0
assert recs["totalCount"] > 0
......
......@@ -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 - %(msg)s"
"%(asctime)s - %(levelname)s - %(module)s.py:%(lineno)d - %(message)s"
)
# stream handler
......
......@@ -98,8 +98,8 @@ class Pipeline:
os.chdir(self.dir_output)
# Frequently used files
self.msg = MessageWriter(os.path.join(self.dir_output, "message.txt"))
self.tsr = TimestampRecorder(os.path.join(self.dir_output, "timestamp.txt"))
self.message = Message(os.path.join(self.dir_output, "message.txt"))
self.timestamp = 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 MessageWriter:
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 TimestampRecorder:
def __init__(self, file_path: str = "tsr.txt"):
class Timestamp:
def __init__(self, file_path: str = "timestamp.txt"):
"""
TimestampRecorder Class.
Timestamp Class.
Initialize a TimestampRecorder 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"< TimestampRecorder [{self.file_path}] >"
return f"< Timestamp [{self.file_path}] >"
def empty(self):
"""Clean time stamp file."""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment