result1.py 1.35 KB
Newer Older
Wei Shoulin's avatar
Wei Shoulin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

from ..common.delegate import Delegate

class Result1Api(object):
    """
    Level 1 Operation Class of IFS
    """
    def __init__(self, sub_system="ifs"):
        self.sub_system = sub_system
        self.module = Delegate().load(sub_module = "ifs")
        self.stub = getattr(self.module, "Result1Api")()
        self.file_prefix = self.stub.root_dir

    def find(self, **kwargs):
        '''
        parameter kwargs:
            file_name = [str],
            proc_type = [str]

        return list of level 1 record
        '''
        return self.stub.find(**kwargs)

    def get(self, **kwargs):
        '''  query database, return a record as dict

        parameter kwargs:
            fits_id = [int] 

        return dict or None
        '''
        return self.stub.get(**kwargs)

    def read(self, **kwargs):
        ''' yield bytes of fits file

        parameter kwargs:
            fits_id = [int],
            file_path = [str], 
            chunk_size = [int] default 20480

        yield bytes of fits file
        '''
        return self.stub.read(**kwargs)

    def write(self, **kwargs):
        ''' copy a local level 1 file to file storage, and insert a record into database

        parameter kwargs:
            file_path = [str],
            proc_type = [str],
            result0_ids = [list]
        '''  
Wei Shoulin's avatar
Wei Shoulin committed
54
        return self.stub.write(**kwargs)
Wei Shoulin's avatar
Wei Shoulin committed
55