Commit 6774a8f4 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

remove module logger

parent 634b398a
Pipeline #11617 passed with stage
in 0 seconds
...@@ -114,14 +114,10 @@ class Pipeline: ...@@ -114,14 +114,10 @@ class Pipeline:
self.kwargs: dict = kwargs self.kwargs: dict = kwargs
# set logger # set logger
self.pipeline_logger = get_logger( self.logger = get_logger(
name="pipeline logger", name="pipeline logger",
filename=os.path.join(self.dir_output, pipeline_log), filename=os.path.join(self.dir_output, pipeline_log),
) )
self.module_logger = get_logger(
name="module logger",
filename=os.path.join(self.dir_output, module_log),
)
# change working directory # change working directory
print(f"Change directory to {self.dir_output}") print(f"Change directory to {self.dir_output}")
...@@ -167,7 +163,7 @@ class Pipeline: ...@@ -167,7 +163,7 @@ class Pipeline:
"""Summarize this run.""" """Summarize this run."""
t_stop: Time = Time.now() t_stop: Time = Time.now()
t_cost: float = (t_stop - self.t_start).value * 86400.0 t_cost: float = (t_stop - self.t_start).value * 86400.0
self.pipeline_logger.info(f"Total cost: {t_cost:.1f} sec") self.logger.info(f"Total cost: {t_cost:.1f} sec")
def clean_output(self): def clean_output(self):
"""Clean output directory.""" """Clean output directory."""
...@@ -223,12 +219,15 @@ class Pipeline: ...@@ -223,12 +219,15 @@ class Pipeline:
for file_path in file_paths: for file_path in file_paths:
pass pass
def download_oss_file(self, oss_file_path: str) -> None:
"""Download an OSS file from OSS to local path."""
# self.dfs.download_file(oss_file_path, local_path)
pass
def call(self, func: Callable, *args: Any, **kwargs: Any): def call(self, func: Callable, *args: Any, **kwargs: Any):
self.pipeline_logger.info( self.logger.info(f"=====================================================")
f"====================================================="
)
t_start: Time = Time.now() t_start: Time = Time.now()
self.pipeline_logger.info(f"Starting Module: **{func.__name__}**") self.logger.info(f"Starting Module: **{func.__name__}**")
# logger.info(f"Additional arguments: {args} {kwargs}") # logger.info(f"Additional arguments: {args} {kwargs}")
try: try:
# if the module works well # if the module works well
...@@ -241,7 +240,7 @@ class Pipeline: ...@@ -241,7 +240,7 @@ class Pipeline:
except Exception as e: except Exception as e:
# if the module raises error # if the module raises error
exc_info = traceback.format_exc() # traceback info exc_info = traceback.format_exc() # traceback info
self.pipeline_logger.error(f"Error occurs! \n{exc_info}") self.logger.error(f"Error occurs! \n{exc_info}")
# define results # define results
status = CsstStatus.ERROR # default status if exceptions occur status = CsstStatus.ERROR # default status if exceptions occur
files = None files = None
...@@ -251,16 +250,16 @@ class Pipeline: ...@@ -251,16 +250,16 @@ class Pipeline:
t_cost: float = (t_stop - t_start).value * 86400 t_cost: float = (t_stop - t_start).value * 86400
if isinstance(status, CsstStatus): if isinstance(status, CsstStatus):
# status is # status is
self.pipeline_logger.info( self.logger.info(
f"Module finished: status={status} | cost={t_cost:.1f} sec" f"Module finished: status={status} | cost={t_cost:.1f} sec"
) )
else: else:
# invalid status # invalid status
self.pipeline_logger.error( self.logger.error(
f"Invalid status: {status} is not a CsstResult object!" f"Invalid status: {status} is not a CsstResult object!"
) )
# record exception traceback info # record exception traceback info
self.pipeline_logger.info( self.logger.info(
f"ModuleResult: \n" f"ModuleResult: \n"
f" - name: {func.__name__}\n" f" - name: {func.__name__}\n"
f" - status: {status}\n" f" - status: {status}\n"
......
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