Commit ccfbdd8c authored by Wei Shoulin's avatar Wei Shoulin
Browse files

add other data

parent 5d44851f
......@@ -88,7 +88,7 @@ class Level1DataApi(object):
def write(self, **kwargs):
''' insert a level1 record into database
:param kwargs: Parameter dictionary, key items support:
level0_id: [str]
data_type : [str]
......
from ..common.delegate import Delegate
class OtherDataApi(object):
"""
Other Data Operation Class
"""
def __init__(self):
self.pymodule = Delegate().load(sub_module = "facility")
self.stub = getattr(self.pymodule, "OtherDataApi")()
def find(self, **kwargs):
''' retrieve other data records from database
:param kwargs: Parameter dictionary, key items support:
obs_id: [str]
detector_no: [str]
module_id: [str]
data_type: [str]
create_time : (start, end)
filename: [str]
pipeline_id: [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 write(self, **kwargs):
''' insert a other data record into database
:param kwargs: Parameter dictionary, key items support:
obs_id: [str]
detector_no : [str]
module_id : [str]
file_type : [str]
filename : [str]
file_path : [str]
pipeline_id : [str]
:returns: csst_dfs_common.models.Result
'''
return self.stub.write(**kwargs)
import unittest
from csst_dfs_api.facility.otherdata import OtherDataApi
class OtherDataTestCase(unittest.TestCase):
def setUp(self):
self.api = OtherDataApi()
def test_find(self):
recs = self.api.find(
module_id='MSC',
create_time = ("2023-06-27 11:12:13","2023-06-27 23:12:13"))
print('find:', recs)
def test_get(self):
rec = self.api.get(id = 1)
print('get:', rec)
def test_write(self):
rec = self.api.write(
obs_id='10000012001',
file_type = "sci",
module_id = "MSC",
detector_no = "01",
filename = "CSST_MSC_MS_SCI_20270810142128_20270810142358_100000101_20_img_L1.fits",
file_path = "/opt/temp/csst/CSST_MSC_MS_SCI_20270810142128_20270810142358_100000101_20_img_L1.fits",
pipeline_id = "P1")
print('write:', rec)
\ No newline at end of file
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