diff --git a/csst_dfs_api/common/utils.py b/csst_dfs_api/common/utils.py index 3666d757f272ac078cc4ea1b1cf00b7a5453b169..8bf83b4ad5426606e1dcfb9da98fd318196e4e93 100644 --- a/csst_dfs_api/common/utils.py +++ b/csst_dfs_api/common/utils.py @@ -41,6 +41,12 @@ def to_int(s, default_value = 0): except: return default_value +def to_float(s, default_value = 0): + try: + return float(s) + except: + return default_value + def singleton(cls): _instance = {} @@ -119,6 +125,6 @@ def object_list_to_table(query_result): t.add_row(tuple([rec.__getattribute__(k) for k in fields])) return t -def get_nextId_by_prefix(prefix): +def get_nextId_by_prefix(prefix: str): pymodule = Delegate().load(sub_module = "common.utils") return getattr(pymodule, "get_nextId_by_prefix")(prefix) \ No newline at end of file diff --git a/csst_dfs_api/ifs/__init__.py b/csst_dfs_api/ifs/__init__.py index d4f4fff7fdb72d3beea91326dd06efa144dfc5cb..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/csst_dfs_api/ifs/__init__.py +++ b/csst_dfs_api/ifs/__init__.py @@ -1,2 +0,0 @@ -from .level1 import Level1DataApi -from .level1prc import Level1PrcApi \ No newline at end of file diff --git a/csst_dfs_api/ifs/level1.py b/csst_dfs_api/ifs/level1.py deleted file mode 100644 index 7d13f4f584b0aabb2daf4f265ac2c1fd0df3419b..0000000000000000000000000000000000000000 --- a/csst_dfs_api/ifs/level1.py +++ /dev/null @@ -1,79 +0,0 @@ - -from ..common.delegate import Delegate - -class Level1DataApi(object): - """ - IFS Level1 Data Operation Class - """ - def __init__(self): - self.pymodule = Delegate().load(sub_module = "ifs") - self.stub = getattr(self.pymodule, "Level1DataApi")() - - def find(self, **kwargs): - ''' retrieve level1 records from database - - :param kwargs: Parameter dictionary, key items support: - level0_id: [str], - data_type: [str], - create_time : (start, end), - qc1_status : [int], - prc_status : [int], - filename: [str] - limit: limits returns the number of records,default 0:no-limit - - :returns: csst_dfs_common.models.Result - ''' - return self.stub.find(**kwargs) - - def get(self, **kwargs): - ''' fetch a record from database - - :param kwargs: Parameter dictionary, key items support: - id : [int] - - :returns: csst_dfs_common.models.Result - ''' - return self.stub.get(**kwargs) - - - def update_proc_status(self, **kwargs): - ''' update the status of reduction - - :param kwargs: Parameter dictionary, key items support: - id = [int], - status = [int] - - :returns: csst_dfs_common.models.Result - ''' - return self.stub.update_proc_status(**kwargs) - - def update_qc1_status(self, **kwargs): - ''' update the status of QC1 - - :param kwargs: Parameter dictionary, key items support: - id = [int], - status = [int] - - :returns: csst_dfs_common.models.Result - ''' - return self.stub.update_qc1_status(**kwargs) - - def write(self, **kwargs): - ''' insert a level1 record into database - - :param kwargs: Parameter dictionary, key items support: - level0_id : [str] - data_type : [str] - cor_sci_id : [int] - prc_params : [str] - filename : [str] - file_path : [str] - prc_status : [int] - prc_time : [str] - pipeline_id : [str] - refs: [dict] - - :returns: csst_dfs_common.models.Result - ''' - return self.stub.write(**kwargs) - diff --git a/csst_dfs_api/ifs/level1prc.py b/csst_dfs_api/ifs/level1prc.py deleted file mode 100644 index 0c0d92617dc7a350b1c81fb791a072374b99c8c1..0000000000000000000000000000000000000000 --- a/csst_dfs_api/ifs/level1prc.py +++ /dev/null @@ -1,51 +0,0 @@ - -from ..common.delegate import Delegate - -class Level1PrcApi(object): - """ - Level 0 Data Operation API - """ - def __init__(self): - self.pymodule = Delegate().load(sub_module = "ifs") - self.stub = getattr(self.pymodule, "Level1PrcApi")() - - def find(self, **kwargs): - ''' retrieve level1 procedure records from database - - :param kwargs: Parameter dictionary, key items support: - level1_id: [int] - pipeline_id: [str] - prc_module: [str] - prc_status : [int] - - :returns: csst_dfs_common.models.Result - ''' - return self.stub.find(**kwargs) - - def update_proc_status(self, **kwargs): - ''' update the status of reduction - - :param kwargs: Parameter dictionary, key items support: - id : [int], - status : [int] - - :returns: csst_dfs_common.models.Result - ''' - return self.stub.update_proc_status(**kwargs) - - def write(self, **kwargs): - ''' insert a level1 procedure record into database - - :param kwargs: Parameter dictionary, key items support: - level1_id : [int] - pipeline_id : [str] - prc_module : [str] - params_file_path : [str] - prc_status : [int] - prc_time : [str] - result_file_path : [str] - - :returns: csst_dfs_common.models.Result - ''' - return self.stub.write(**kwargs) - diff --git a/csst_dfs_api/sls/level2spectra.py b/csst_dfs_api/sls/level2spectra.py index 202a54a747563e303d0724ca75db94527420f3f6..3e6529019bbb1a82e328c1f6d7c9ebf00678fc1c 100644 --- a/csst_dfs_api/sls/level2spectra.py +++ b/csst_dfs_api/sls/level2spectra.py @@ -17,7 +17,7 @@ class Level2SpectraApi(object): level1_id: [int] spectra_id: [str] create_time : (start, end), - qc1_status : [int], + qc2_status : [int], prc_status : [int], filename: [str] limit: limits returns the number of records,default 0:no-limit @@ -48,8 +48,8 @@ class Level2SpectraApi(object): ''' return self.stub.update_proc_status(**kwargs) - def update_qc1_status(self, **kwargs): - ''' update the status of QC1 + def update_qc2_status(self, **kwargs): + ''' update the status of QC2 :param kwargs: Parameter dictionary, key items support: id = [int], @@ -57,10 +57,10 @@ class Level2SpectraApi(object): :returns: csst_dfs_common.models.Result ''' - return self.stub.update_qc1_status(**kwargs) + return self.stub.update_qc2_status(**kwargs) def write(self, **kwargs): - ''' insert a level1 record into database + ''' insert a level2 record into database :param kwargs: Parameter dictionary, key items support: level0_id: [str] diff --git a/tests/facility/test_facility_cal_merge.py b/tests/facility/test_facility_cal_merge.py deleted file mode 100644 index 2cbfb50586668f38c9a1a5f9416e6e496b7b4204..0000000000000000000000000000000000000000 --- a/tests/facility/test_facility_cal_merge.py +++ /dev/null @@ -1,46 +0,0 @@ -import unittest - -from csst_dfs_api.facility.calmerge import CalMergeApi - -class MSCCalMergeApiTestCase(unittest.TestCase): - - def setUp(self): - self.api = CalMergeApi() - - def test_find(self): - recs = self.api.find(detector_no='01', - ref_type = "bias", - obs_time = ("2021-06-01 11:12:13","2021-06-08 11:12:13")) - print('find:', recs) - - def test_get_latest_by_l0(self): - rec = self.api.get_latest_by_l0(level0_id='000001102', ref_type = "bias") - print('get_latest_by_l0:', rec) - - def test_get(self): - rec = self.api.get(id = 2) - print('get by id:', rec) - rec = self.api.get(cal_id = '2') - print('get by cal_id:', rec) - - def test_update_proc_status(self): - rec = self.api.update_proc_status(id = 3, status = 1) - print('update_proc_status:', rec) - - def test_update_qc1_status(self): - rec = self.api.update_qc1_status(id = 3, status = 2) - print('update_qc1_status:', rec) - - def test_write(self): - rec = self.api.write( - cal_id = '00002', - detector_no = '01', - ref_type = "bias", - obs_time = "2021-06-04 11:12:13", - exp_time = 150, - filename = "/opt/dddasd1.params", - file_path = "/opt/dddasd1.fits", - prc_status = 3, - prc_time = '2021-06-04 11:12:13', - level0_ids = ['1','2','3','4']) - print('write:', rec) \ No newline at end of file