Loading csst_common/pipeline.py +7 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ from .logger import get_logger class Pipeline: def __init__( self, name="", dir_in="/pipeline/input", dir_out="/pipeline/output", dir_aux="/pipeline/aux", Loading @@ -28,7 +27,11 @@ class Pipeline: dfs=True, crds=False, ): self.name = name # get pipeline information from environ self.name = os.getenv("PIPELINE", "-") self.build = os.getenv("BUILD", "-") # set directory information self.dir_in = dir_in self.dir_out = dir_out self.dir_aux = dir_aux Loading @@ -37,10 +40,12 @@ class Pipeline: self.crds_cache = crds_cache self.clean = clean # set resource information self.n_jobs_cpu = n_jobs_cpu self.n_jobs_gpu = n_jobs_gpu self.device = device.upper() # set logger self.pipeline_logger = get_logger(name="pipeline", filename=os.path.join(self.dir_out, "pipeline.log")) self.module_logger = get_logger(name="module", filename=os.path.join(self.dir_out, "module.log")) Loading csst_common/time.py +0 −15 Original line number Diff line number Diff line import datetime from astropy import time def now(): """ Return ISOT8601 format datetime, for time stamps in data products. """ Loading @@ -11,16 +9,3 @@ def now(): def now_dfs(): """ Return ISOT8601 format datetime, for DFS usage only. """ return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') class TimeStamp: def __init__(self, file_path=""): self.file_path = file_path def truncate(self): with open(self.file_path, 'w') as file: file.truncate(0) def punch_in(self): with open(self.file_path, "a+") as f: f.write(f"{time.Time.now().isot}+00:00\n") csst_common/wrapper.py +5 −5 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ from csst_common.data_manager import CsstMsDataManager from csst_common.file_recorder import FileRecorder from csst_common.status import CsstStatus __all__ = ["ModuleResult", "l1ppl_module"] __all__ = ["ModuleResult", "l1ppl_module", "module_wrapper"] # module should return ModuleResult as result ModuleResult = namedtuple("ModuleResult", ["module", "timecost", "status", "fr", "output"]) Loading Loading @@ -100,6 +100,7 @@ def module_wrapper(func): if __name__ == "__main__": @l1ppl_module def call_add(dm, a, b): if isinstance(a, float) and isinstance(b, float): Loading @@ -107,7 +108,6 @@ if __name__ == "__main__": else: return ModuleResult(CsstStatus.ERROR, None, (a, b)) dm = CsstMsDataManager() print(call_add(dm, 1., 2.)) print(call_add(dm, 1., None)) # dm = CsstMsDataManager() # print(call_add(dm, 1., 2.)) # print(call_add(dm, 1., None)) Loading
csst_common/pipeline.py +7 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ from .logger import get_logger class Pipeline: def __init__( self, name="", dir_in="/pipeline/input", dir_out="/pipeline/output", dir_aux="/pipeline/aux", Loading @@ -28,7 +27,11 @@ class Pipeline: dfs=True, crds=False, ): self.name = name # get pipeline information from environ self.name = os.getenv("PIPELINE", "-") self.build = os.getenv("BUILD", "-") # set directory information self.dir_in = dir_in self.dir_out = dir_out self.dir_aux = dir_aux Loading @@ -37,10 +40,12 @@ class Pipeline: self.crds_cache = crds_cache self.clean = clean # set resource information self.n_jobs_cpu = n_jobs_cpu self.n_jobs_gpu = n_jobs_gpu self.device = device.upper() # set logger self.pipeline_logger = get_logger(name="pipeline", filename=os.path.join(self.dir_out, "pipeline.log")) self.module_logger = get_logger(name="module", filename=os.path.join(self.dir_out, "module.log")) Loading
csst_common/time.py +0 −15 Original line number Diff line number Diff line import datetime from astropy import time def now(): """ Return ISOT8601 format datetime, for time stamps in data products. """ Loading @@ -11,16 +9,3 @@ def now(): def now_dfs(): """ Return ISOT8601 format datetime, for DFS usage only. """ return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') class TimeStamp: def __init__(self, file_path=""): self.file_path = file_path def truncate(self): with open(self.file_path, 'w') as file: file.truncate(0) def punch_in(self): with open(self.file_path, "a+") as f: f.write(f"{time.Time.now().isot}+00:00\n")
csst_common/wrapper.py +5 −5 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ from csst_common.data_manager import CsstMsDataManager from csst_common.file_recorder import FileRecorder from csst_common.status import CsstStatus __all__ = ["ModuleResult", "l1ppl_module"] __all__ = ["ModuleResult", "l1ppl_module", "module_wrapper"] # module should return ModuleResult as result ModuleResult = namedtuple("ModuleResult", ["module", "timecost", "status", "fr", "output"]) Loading Loading @@ -100,6 +100,7 @@ def module_wrapper(func): if __name__ == "__main__": @l1ppl_module def call_add(dm, a, b): if isinstance(a, float) and isinstance(b, float): Loading @@ -107,7 +108,6 @@ if __name__ == "__main__": else: return ModuleResult(CsstStatus.ERROR, None, (a, b)) dm = CsstMsDataManager() print(call_add(dm, 1., 2.)) print(call_add(dm, 1., None)) # dm = CsstMsDataManager() # print(call_add(dm, 1., 2.)) # print(call_add(dm, 1., None))