Loading csst_common/pipeline.py +13 −14 Original line number Diff line number Diff line Loading @@ -114,14 +114,10 @@ class Pipeline: self.kwargs: dict = kwargs # set logger self.pipeline_logger = get_logger( self.logger = get_logger( name="pipeline logger", 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 print(f"Change directory to {self.dir_output}") Loading Loading @@ -167,7 +163,7 @@ class Pipeline: """Summarize this run.""" t_stop: Time = Time.now() 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): """Clean output directory.""" Loading Loading @@ -223,12 +219,15 @@ class Pipeline: for file_path in file_paths: 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): self.pipeline_logger.info( f"=====================================================" ) self.logger.info(f"=====================================================") 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}") try: # if the module works well Loading @@ -241,7 +240,7 @@ class Pipeline: except Exception as e: # if the module raises error 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 status = CsstStatus.ERROR # default status if exceptions occur files = None Loading @@ -251,16 +250,16 @@ class Pipeline: t_cost: float = (t_stop - t_start).value * 86400 if isinstance(status, CsstStatus): # status is self.pipeline_logger.info( self.logger.info( f"Module finished: status={status} | cost={t_cost:.1f} sec" ) else: # invalid status self.pipeline_logger.error( self.logger.error( f"Invalid status: {status} is not a CsstResult object!" ) # record exception traceback info self.pipeline_logger.info( self.logger.info( f"ModuleResult: \n" f" - name: {func.__name__}\n" f" - status: {status}\n" Loading Loading
csst_common/pipeline.py +13 −14 Original line number Diff line number Diff line Loading @@ -114,14 +114,10 @@ class Pipeline: self.kwargs: dict = kwargs # set logger self.pipeline_logger = get_logger( self.logger = get_logger( name="pipeline logger", 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 print(f"Change directory to {self.dir_output}") Loading Loading @@ -167,7 +163,7 @@ class Pipeline: """Summarize this run.""" t_stop: Time = Time.now() 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): """Clean output directory.""" Loading Loading @@ -223,12 +219,15 @@ class Pipeline: for file_path in file_paths: 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): self.pipeline_logger.info( f"=====================================================" ) self.logger.info(f"=====================================================") 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}") try: # if the module works well Loading @@ -241,7 +240,7 @@ class Pipeline: except Exception as e: # if the module raises error 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 status = CsstStatus.ERROR # default status if exceptions occur files = None Loading @@ -251,16 +250,16 @@ class Pipeline: t_cost: float = (t_stop - t_start).value * 86400 if isinstance(status, CsstStatus): # status is self.pipeline_logger.info( self.logger.info( f"Module finished: status={status} | cost={t_cost:.1f} sec" ) else: # invalid status self.pipeline_logger.error( self.logger.error( f"Invalid status: {status} is not a CsstResult object!" ) # record exception traceback info self.pipeline_logger.info( self.logger.info( f"ModuleResult: \n" f" - name: {func.__name__}\n" f" - status: {status}\n" Loading