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

hstdm

parent 1be038fd
......@@ -28,4 +28,3 @@ enviroment variables
- CSST_DFS_API_MODE = local or cluster # default: local
- CSST_LOCAL_FILE_ROOT = [a local file directory] # required if DFS_API_MODE = local, default: /opt/temp/csst
- CSST_DFS_GATEWAY = [gateway server's address] # required if DFS_API_MODE = cluster
wsl123
\ No newline at end of file
from .catalog import CatalogApi
\ No newline at end of file
......@@ -31,6 +31,15 @@ class Level0DataApi(object):
'''
return self.stub.find(**kwargs)
def find_by_brick_ids(self, **kwargs):
''' retrieve level0 records by brick_ids like [1,2,3,4]
:param kwargs: Parameter dictionary, key items support:
brick_ids: [list]
:returns: csst_dfs_common.models.Result
'''
return self.stub.find_by_brick_ids(**kwargs)
def get(self, **kwargs):
''' fetch a record from database
......
from .level1 import Level1DataApi
from .level1prc import Level1PrcApi
\ No newline at end of file
from ..common.delegate import Delegate
class Level1DataApi(object):
"""
IFS Level1 Data Operation Class
"""
def __init__(self):
self.pymodule = Delegate().load(sub_module = "hstdm")
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 QC0
: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)
from ..common.delegate import Delegate
class Level1PrcApi(object):
"""
Level 0 Data Operation API
"""
def __init__(self):
self.pymodule = Delegate().load(sub_module = "mci")
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)
......@@ -25,6 +25,15 @@ class Level1DataApi(object):
'''
return self.stub.find(**kwargs)
def find_by_brick_ids(self, **kwargs):
''' retrieve level1 records by brick_ids like [1,2,3,4]
:param kwargs: Parameter dictionary, key items support:
brick_ids: [list]
:returns: csst_dfs_common.models.Result
'''
return self.stub.find_by_brick_ids(**kwargs)
def get(self, **kwargs):
''' fetch a record from database
......
......@@ -24,6 +24,15 @@ class Level1DataApi(object):
:returns: csst_dfs_common.models.Result
'''
return self.stub.find(**kwargs)
def find_by_brick_ids(self, **kwargs):
''' retrieve level1 records by brick_ids like [1,2,3,4]
:param kwargs: Parameter dictionary, key items support:
brick_ids: [list]
:returns: csst_dfs_common.models.Result
'''
return self.stub.find_by_brick_ids(**kwargs)
def find_by_prc_status(self, **kwargs):
''' retrieve level1 records from database
......
......@@ -11,6 +11,10 @@ class Level0DataTestCase(unittest.TestCase):
recs = self.api.find(obs_id = '0000011', obs_type = 'sci', limit = 0)
print('find:', recs)
def test_find_by_brick_ids(self):
recs = self.api.find_by_brick_ids(brick_ids = [1,2,3,4])
print('find:', recs)
def test_get(self):
rec = self.api.get(id = 3)
print('get:', rec)
......
import unittest
from csst_dfs_api.hstdm import Level1DataApi
class HSTDMLevel1TestCase(unittest.TestCase):
def setUp(self):
self.api = Level1DataApi()
def test_find(self):
recs = self.api.find(
level0_id='50002981600',
create_time = ("2021-06-01 11:12:13","2021-06-08 11:12:13")
)
print('find:', recs)
def test_get(self):
rec = self.api.get(id = 1)
print('get:', rec)
def test_update_proc_status(self):
rec = self.api.update_proc_status(id = 1, status = 4)
print('update_proc_status:', rec)
def test_update_qc1_status(self):
rec = self.api.update_qc1_status(id = 1, status = 7)
print('update_qc1_status:', rec)
def test_write(self):
rec = self.api.write(
level0_id='50002981600',
data_type = "sci",
prc_params = "/opt/dddasd.params",
prc_status = 3,
prc_time = '2021-10-22 11:12:13',
filename = "MSC_MS_210525121500_100000001_09_raw",
file_path = "/opt/temp/csst/MSC_MS_210525121500_100000001_09_raw.fits",
pipeline_id = "P2",
refs = {'dark': 1, 'bias': 2, 'flat': 3 })
print('write:', rec)
\ No newline at end of file
import unittest
from csst_dfs_api.hstdm.level1prc import Level1PrcApi
class HSTDMLevel1PrcTestCase(unittest.TestCase):
def setUp(self):
self.api = Level1PrcApi()
def test_find(self):
recs = self.api.find(level1_id=1)
print('find:', recs)
def test_update_proc_status(self):
rec = self.api.update_proc_status(id = 1, status = 4)
print('update_proc_status:', rec)
def test_write(self):
rec = self.api.write(level1_id=1,
pipeline_id = "P1",
prc_module = "QC0",
params_file_path = "/opt/dddasd.params",
prc_status = 3,
prc_time = '2021-06-04 11:12:13',
result_file_path = "/opt/dddasd.header")
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