Skip to content

router ¤

Functions:

Name Description
cronjob

Execute pre-set scheduled jobs

postprocess

Send result back to cloud or whatever you wanna do

cronjob() ¤

Execute pre-set scheduled jobs

the scheduling rules are specified by etc.server.cronjob using
key type note
year int, str 4-digit number
month int, str 1-12
day int, str 1-31
week int, str 1-53
day_of_week int, str 0-6 or mon, tue, wed, thu, fri, stat, sun
hour int, str 0-24
minute int, str 0-59
second int, str 0-59
Source code in quark/runtime/router.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def cronjob():
    """Execute pre-set scheduled jobs

    Example: the scheduling rules are specified by `etc.server.cronjob` using
        |key|type|note|
        |---|---|---|
        |year|int, str|4-digit number|
        |month|int, str|1-12|
        |day|int, str|1-31|
        |week|int, str|1-53|
        |day_of_week|int, str|0-6 or mon, tue, wed, thu, fri, stat, sun|
        |hour|int, str|0-24|
        |minute|int, str|0-59|
        |second|int, str|0-59|

    """
    # dst = shutil.move(Path('../../home/dat/144v3-swj-221013-normalJJ_2023-03-01-22-37-23.hdf5'),Path.home())
    # for path in sorted(Path('../../home/dat').glob('**/*.hdf5')):
    #     print((time.time() - path.stat().st_mtime)/(24*60*60),shutil.disk_usage(path))
    def test1():
        print(time.strftime('%Y-%m-%d %H:%M:%S'), 'do something1 ...')

    def test2():
        print(time.strftime('%Y-%m-%d %H:%M:%S'), 'do something2 ...')

    return {}  # {'job1': test1,'job2': test2}

postprocess(result: dict) ¤

Send result back to cloud or whatever you wanna do

Parameters:

Name Type Description Default
result dict

task result

required
result
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{'data': {'iq_avg': array([[ 6.98367485 +3.05121544j, 17.98372871+14.02688919j],
                           [14.9855748 +16.99029603j, 12.00005981+10.98745889j],
                           [ 5.05074742 +0.96293022j, 18.00112126 +5.98929904j]])},
 'meta': {'tid': 202403122306141782,
          'name': 'testtask:/PowerRabi1D',
          'user': 'baqis',
          'priority': 1,
          'system': 'checkpoint144',
          'status': 'Finished',
          'other': {'shots': 1024,
                    'signal': 'iq_avg',
                    'standby': True,
                    'autorun': True,
                    'filesize': 4000.0},
          'axis': {'amps': {'amps_Q1001': array([0.1, 0.3, 0.5]),
                            'amps_Q1101': array([0.1, 0.3, 0.5])}},
          'committed': 'bbd5533a5863fb88dbb7eba5109ed624abda8e4c',
          'created': '2024-03-12-23-06-15',
          'finished': '2024-03-12-23-06-17'}
}
Source code in quark/runtime/router.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
def postprocess(result: dict):
    """Send result back to cloud or whatever you wanna do

    Args:
        result (dict): task result

    Example: result
        ``` {.py3 linenums="1"}
        {'data': {'iq_avg': array([[ 6.98367485 +3.05121544j, 17.98372871+14.02688919j],
                                   [14.9855748 +16.99029603j, 12.00005981+10.98745889j],
                                   [ 5.05074742 +0.96293022j, 18.00112126 +5.98929904j]])},
         'meta': {'tid': 202403122306141782,
                  'name': 'testtask:/PowerRabi1D',
                  'user': 'baqis',
                  'priority': 1,
                  'system': 'checkpoint144',
                  'status': 'Finished',
                  'other': {'shots': 1024,
                            'signal': 'iq_avg',
                            'standby': True,
                            'autorun': True,
                            'filesize': 4000.0},
                  'axis': {'amps': {'amps_Q1001': array([0.1, 0.3, 0.5]),
                                    'amps_Q1101': array([0.1, 0.3, 0.5])}},
                  'committed': 'bbd5533a5863fb88dbb7eba5109ed624abda8e4c',
                  'created': '2024-03-12-23-06-15',
                  'finished': '2024-03-12-23-06-17'}
        }
        ``` 
    """

    return QuarkProxy.process(result)