Loading csst_common/ccds/ccds.py +23 −16 Original line number Diff line number Diff line Loading @@ -16,16 +16,21 @@ from .slsconf import convert_slsconf class CCDS: def __init__(self, ccds_root="/ccds_root", ccds_cache="/pipeline/ccds_cache"): print("Setting CCDS root path ... ", end="") def __init__( self, ccds_root="/ccds_root", ccds_cache="/pipeline/ccds_cache", pmapname=None, ): print("[CCDS] Setting CCDS root path ... ", end="") self.ccds_root = ccds_root print(self.ccds_root) print("Setting CCDS cache path ... ", end="") print("[CCDS] Setting CCDS cache path ... ", end="") self.ccds_cache = ccds_cache print(self.ccds_cache) print("Setting CCDS environment variables ... ", end="") print("[CCDS] Setting CCDS environment variables ... ", end="") os.environ["CCDS_MODE"] = "remote" os.environ["CCDS_PATH"] = ccds_cache os.environ["CCDS_OBSERVATORY"] = "csst" Loading @@ -36,24 +41,26 @@ class CCDS: print(self.observatory) assert ( self.observatory == "csst" ), f"observatory [{self.observatory}] is not csst!" ), f"observatory [{self.observatory}] is not `csst`!" print("Query for operational_context ... ", end="") try: self.operational_context = client.get_default_context(self.observatory) print(f"[CCDS] Query for operational_context = {self.operational_context}... ") self.pmapname = pmapname if pmapname is not None else self.operational_context print(f"[CCDS] Setting pmapname = {self.pmapname}... ") try: # dump mappings client.dump_mappings(self.operational_context) client.dump_mappings(self.pmapname) self.is_available = True except BaseException as e: print("CCDS access failed! ", e.args) self.operational_context = "" print(f"[CCDS] Failed to get pmapname={self.pmapname}:", e.args) self.is_available = False print(self.operational_context) # assert self.operational_context != "", f"operational_context [{self.operational_context}] is empty!" print(f"[CCDS] operational_context = {self.operational_context}") print(f"[CCDS] pmapname = {self.pmapname}") def __repr__(self): return ( f"< CCDS url='{os.getenv('CCDS_SERVER_URL', default='')}' >\n" f"[CCDS] url='{os.getenv('CCDS_SERVER_URL', default='')}' >\n" f" - is_available={self.is_available}\n" f" - observatory='{self.observatory}'\n" f" - operational_context='{self.operational_context}'\n" Loading @@ -67,7 +74,7 @@ class CCDS: ): # print("get min header") hdrs = client.api.get_minimum_header( self.operational_context, file_path, ignore_cache=False self.pmapname, file_path, ignore_cache=False ) # {'CAMERA': 'MS', # 'CHIPID': '10', Loading @@ -76,7 +83,7 @@ class CCDS: # 'INSTRUME': 'MSC', # 'REFTYPE': 'UNDEFINED'} # print("get best ref") refs = client.api.get_best_references(self.operational_context, hdrs) refs = client.api.get_best_references(self.pmapname, hdrs) # {'bias': 'csst_msc_ms_bias_10_000001.fits', # 'dark': 'csst_msc_ms_dark_10_000001.fits', # 'ledflat': 'csst_msc_ms_ledflat_10_000001.fits', Loading @@ -86,7 +93,7 @@ class CCDS: # print("get file info") refs_fp = dict() for ref_type in refs.keys(): d = client.api.get_file_info(self.operational_context, refs[ref_type]) d = client.api.get_file_info(self.pmapname, refs[ref_type]) if d: fp = os.path.join(self.ccds_root, d["file_path"]) assert os.path.exists(fp), f"File path [{fp}] does not exist!" Loading Loading
csst_common/ccds/ccds.py +23 −16 Original line number Diff line number Diff line Loading @@ -16,16 +16,21 @@ from .slsconf import convert_slsconf class CCDS: def __init__(self, ccds_root="/ccds_root", ccds_cache="/pipeline/ccds_cache"): print("Setting CCDS root path ... ", end="") def __init__( self, ccds_root="/ccds_root", ccds_cache="/pipeline/ccds_cache", pmapname=None, ): print("[CCDS] Setting CCDS root path ... ", end="") self.ccds_root = ccds_root print(self.ccds_root) print("Setting CCDS cache path ... ", end="") print("[CCDS] Setting CCDS cache path ... ", end="") self.ccds_cache = ccds_cache print(self.ccds_cache) print("Setting CCDS environment variables ... ", end="") print("[CCDS] Setting CCDS environment variables ... ", end="") os.environ["CCDS_MODE"] = "remote" os.environ["CCDS_PATH"] = ccds_cache os.environ["CCDS_OBSERVATORY"] = "csst" Loading @@ -36,24 +41,26 @@ class CCDS: print(self.observatory) assert ( self.observatory == "csst" ), f"observatory [{self.observatory}] is not csst!" ), f"observatory [{self.observatory}] is not `csst`!" print("Query for operational_context ... ", end="") try: self.operational_context = client.get_default_context(self.observatory) print(f"[CCDS] Query for operational_context = {self.operational_context}... ") self.pmapname = pmapname if pmapname is not None else self.operational_context print(f"[CCDS] Setting pmapname = {self.pmapname}... ") try: # dump mappings client.dump_mappings(self.operational_context) client.dump_mappings(self.pmapname) self.is_available = True except BaseException as e: print("CCDS access failed! ", e.args) self.operational_context = "" print(f"[CCDS] Failed to get pmapname={self.pmapname}:", e.args) self.is_available = False print(self.operational_context) # assert self.operational_context != "", f"operational_context [{self.operational_context}] is empty!" print(f"[CCDS] operational_context = {self.operational_context}") print(f"[CCDS] pmapname = {self.pmapname}") def __repr__(self): return ( f"< CCDS url='{os.getenv('CCDS_SERVER_URL', default='')}' >\n" f"[CCDS] url='{os.getenv('CCDS_SERVER_URL', default='')}' >\n" f" - is_available={self.is_available}\n" f" - observatory='{self.observatory}'\n" f" - operational_context='{self.operational_context}'\n" Loading @@ -67,7 +74,7 @@ class CCDS: ): # print("get min header") hdrs = client.api.get_minimum_header( self.operational_context, file_path, ignore_cache=False self.pmapname, file_path, ignore_cache=False ) # {'CAMERA': 'MS', # 'CHIPID': '10', Loading @@ -76,7 +83,7 @@ class CCDS: # 'INSTRUME': 'MSC', # 'REFTYPE': 'UNDEFINED'} # print("get best ref") refs = client.api.get_best_references(self.operational_context, hdrs) refs = client.api.get_best_references(self.pmapname, hdrs) # {'bias': 'csst_msc_ms_bias_10_000001.fits', # 'dark': 'csst_msc_ms_dark_10_000001.fits', # 'ledflat': 'csst_msc_ms_ledflat_10_000001.fits', Loading @@ -86,7 +93,7 @@ class CCDS: # print("get file info") refs_fp = dict() for ref_type in refs.keys(): d = client.api.get_file_info(self.operational_context, refs[ref_type]) d = client.api.get_file_info(self.pmapname, refs[ref_type]) if d: fp = os.path.join(self.ccds_root, d["file_path"]) assert os.path.exists(fp), f"File path [{fp}] does not exist!" Loading