Commit b5df44c7 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

tweaks

parent eada2258
Pipeline #966 failed with stage
in 0 seconds
......@@ -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",
......@@ -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
......@@ -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"))
......
import datetime
from astropy import time
def now():
""" Return ISOT8601 format datetime, for time stamps in data products. """
......@@ -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")
......@@ -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"])
......@@ -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):
......@@ -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))
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