QuLab 2.4.5__cp310-cp310-macosx_10_9_universal2.whl → 2.4.6__cp310-cp310-macosx_10_9_universal2.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: QuLab
3
- Version: 2.4.5
3
+ Version: 2.4.6
4
4
  Summary: contral instruments and manage data
5
5
  Author-email: feihoo87 <feihoo87@gmail.com>
6
6
  Maintainer-email: feihoo87 <feihoo87@gmail.com>
@@ -1,15 +1,15 @@
1
1
  qulab/__init__.py,sha256=P-Mx2p4TVmL91SoxoeXcj8Qm0x4xUf5Q_FLk0Yc_gIQ,138
2
2
  qulab/__main__.py,sha256=V5jIyfuCSi5dI6jvqgH_BpXG0URd6bgneDdVCM1dGSA,545
3
3
  qulab/dicttree.py,sha256=tRRMpGZYVOLw0TEByE3_2Ss8FdOmzuGL9e1DWbs8qoY,13684
4
- qulab/fun.cpython-310-darwin.so,sha256=ymUR8H6CWSJHkk8_EyeyMnUHnTwHu4125kSXe4FDl08,126864
5
- qulab/version.py,sha256=sAipLPNdb_IaH9sS_UwXSh0AgDCRTxME2hVBsZX2Dko,21
4
+ qulab/fun.cpython-310-darwin.so,sha256=oLUWuxDOrYz8Tc1V2wPdhBRD1ur-WsR9sHGpZQd2bDk,126864
5
+ qulab/version.py,sha256=jzWsJzFuYAnC9Fllul1PYEIxXD-Lspqc6-IMg65EXLc,21
6
6
  qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
7
- qulab/executor/__main__.py,sha256=soBde_CbTJvvzIU1r2W2DCfQQY4fXMiwtzsXwTfohqw,2273
7
+ qulab/executor/__main__.py,sha256=1Mg5fJ0dYSWQnP6wgTa0s6U_WH7NT2lCnCQOHyx_I7c,2430
8
8
  qulab/executor/load.py,sha256=jZHkEzFF8ufFAIajkRDKmHYYJxbxI3RcEbAFIbl9VQ0,6208
9
- qulab/executor/schedule.py,sha256=spevmrktVE4KQo79l9Dj9rq2cs1bPW4gxHpSxc2MHcc,9055
9
+ qulab/executor/schedule.py,sha256=blxX1wYEjbJcV6Su3ftQma8fGoMMQ_1t276PPoDjhfU,9524
10
10
  qulab/executor/storage.py,sha256=M66Q5_Uc5MMfc_QAuuaaexwAz7wxBPMkeleB5nRpQmI,4621
11
11
  qulab/executor/transform.py,sha256=inaOn6eqCs22ZZ0xAQl8s8YCoEACaXSwFNNu7jqdwAk,2148
12
- qulab/executor/utils.py,sha256=vrwk2fAfSp3YLVZfrYPvxsVPpeuE2n-4G2Ae0eqdT4s,3080
12
+ qulab/executor/utils.py,sha256=n3uCSKh-qdDFFeNvOpj7_es2_B4AaC-ASAlV9gPmSO0,3086
13
13
  qulab/monitor/__init__.py,sha256=nTHelnDpxRS_fl_B38TsN0njgq8eVTEz9IAnN3NbDlM,42
14
14
  qulab/monitor/__main__.py,sha256=w3yUcqq195LzSnXTkQcuC1RSFRhy4oQ_PEBmucXguME,97
15
15
  qulab/monitor/config.py,sha256=fQ5JcsMApKc1UwANEnIvbDQZl8uYW0tle92SaYtX9lI,744
@@ -89,9 +89,9 @@ qulab/visualization/plot_seq.py,sha256=UWTS6p9nfX_7B8ehcYo6UnSTUCjkBsNU9jiOeW2ca
89
89
  qulab/visualization/qdat.py,sha256=ZeevBYWkzbww4xZnsjHhw7wRorJCBzbG0iEu-XQB4EA,5735
90
90
  qulab/visualization/rot3d.py,sha256=lMrEJlRLwYe6NMBlGkKYpp_V9CTipOAuDy6QW_cQK00,734
91
91
  qulab/visualization/widgets.py,sha256=6KkiTyQ8J-ei70LbPQZAK35wjktY47w2IveOa682ftA,3180
92
- QuLab-2.4.5.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
93
- QuLab-2.4.5.dist-info/METADATA,sha256=s5W3328ohKilulDSJ7uj4yWBC3hSdxK1vrTmIfBIoME,3698
94
- QuLab-2.4.5.dist-info/WHEEL,sha256=Yd3eJSBM2hj8W-ouaiMfFUwQYAS-D6P73Ob9yN5MZd0,114
95
- QuLab-2.4.5.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
96
- QuLab-2.4.5.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
97
- QuLab-2.4.5.dist-info/RECORD,,
92
+ QuLab-2.4.6.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
93
+ QuLab-2.4.6.dist-info/METADATA,sha256=xcG5D2k2LSHdq1VqLFx2isvhwkmWO-j72g0wyl2rLKY,3698
94
+ QuLab-2.4.6.dist-info/WHEEL,sha256=Yd3eJSBM2hj8W-ouaiMfFUwQYAS-D6P73Ob9yN5MZd0,114
95
+ QuLab-2.4.6.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
96
+ QuLab-2.4.6.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
97
+ QuLab-2.4.6.dist-info/RECORD,,
@@ -4,7 +4,8 @@ from pathlib import Path
4
4
  import click
5
5
 
6
6
  from .load import find_unreferenced_workflows
7
- from .schedule import maintain as maintain_workflow, run as run_workflow
7
+ from .schedule import maintain as maintain_workflow
8
+ from .schedule import run as run_workflow
8
9
  from .transform import set_config_api
9
10
  from .utils import workflow_template
10
11
 
@@ -41,9 +42,10 @@ def create(workflow, code):
41
42
  @click.argument('workflow')
42
43
  @click.option('--code', '-c', default=None)
43
44
  @click.option('--data', '-d', default=None)
44
- @click.option('--api', '-g', default=None)
45
+ @click.option('--api', '-a', default=None)
46
+ @click.option('--plot', '-p', is_flag=True)
45
47
  @click.option('--no-dependents', '-n', is_flag=True)
46
- def run(workflow, code, data, api, no_dependents):
48
+ def run(workflow, code, data, api, plot, no_dependents):
47
49
  """
48
50
  Run a workflow.
49
51
  """
@@ -56,17 +58,18 @@ def run(workflow, code, data, api, no_dependents):
56
58
  data = Path(code) / 'logs'
57
59
 
58
60
  if no_dependents:
59
- run_workflow(workflow, code, data)
61
+ run_workflow(workflow, code, data, plot=plot)
60
62
  else:
61
- maintain_workflow(workflow, code, data, run=True)
63
+ maintain_workflow(workflow, code, data, run=True, plot=plot)
62
64
 
63
65
 
64
66
  @click.command()
65
67
  @click.argument('workflow')
66
68
  @click.option('--code', '-c', default=None)
67
69
  @click.option('--data', '-d', default=None)
68
- @click.option('--api', '-g', default=None)
69
- def maintain(workflow, code, data, api):
70
+ @click.option('--api', '-a', default=None)
71
+ @click.option('--plot', '-p', is_flag=True)
72
+ def maintain(workflow, code, data, api, plot):
70
73
  """
71
74
  Maintain a workflow.
72
75
  """
@@ -78,7 +81,7 @@ def maintain(workflow, code, data, api):
78
81
  if data is None:
79
82
  data = Path(code) / 'logs'
80
83
 
81
- maintain_workflow(workflow, code, data, run=False)
84
+ maintain_workflow(workflow, code, data, run=False, plot=plot)
82
85
 
83
86
 
84
87
  cli.add_command(maintain)
@@ -59,7 +59,7 @@ def check_state(workflow: str, code_path: str | Path,
59
59
  return True
60
60
 
61
61
 
62
- def call_analyzer(node, data, history, check=False):
62
+ def call_analyzer(node, data, history, check=False, plot=False):
63
63
  if check:
64
64
  result = transform.params_to_result(
65
65
  node.check_analyze(*data,
@@ -69,13 +69,21 @@ def call_analyzer(node, data, history, check=False):
69
69
  result = transform.params_to_result(
70
70
  node.analyze(*data, history=transform.result_to_params(history)))
71
71
  result.fully_calibrated = True
72
+ if plot:
73
+ call_plot(node, result)
72
74
  result.data = data
73
75
  return result
74
76
 
75
77
 
78
+ def call_plot(node, result, check=False):
79
+ if hasattr(node, 'plot') and callable(node.plot):
80
+ state, params, other = transform.result_to_params(result)
81
+ node.plot(state, params, other)
82
+
83
+
76
84
  @functools.lru_cache(maxsize=128)
77
85
  def check_data(workflow: str, code_path: str | Path, state_path: str | Path,
78
- session_id: str) -> Result:
86
+ plot: bool, session_id: str) -> Result:
79
87
  """
80
88
  check data answers two questions:
81
89
  Is the parameter associated with this cal in spec,
@@ -109,7 +117,7 @@ def check_data(workflow: str, code_path: str | Path, state_path: str | Path,
109
117
  save_result(workflow, result, state_path)
110
118
 
111
119
  logger.debug(f'Checked "{workflow}" !')
112
- result = call_analyzer(node, data, history, check=True)
120
+ result = call_analyzer(node, data, history, check=True, plot=plot)
113
121
  if result.in_spec:
114
122
  logger.debug(f'"{workflow}": checked in spec, renewing result')
115
123
  renew_result(workflow, state_path)
@@ -124,7 +132,7 @@ def check_data(workflow: str, code_path: str | Path, state_path: str | Path,
124
132
  save_result(workflow, result, state_path)
125
133
 
126
134
  logger.debug(f'Calibrated "{workflow}" !')
127
- result = call_analyzer(node, data, history, check=False)
135
+ result = call_analyzer(node, data, history, check=False, plot=plot)
128
136
  save_result(workflow, result, state_path,
129
137
  get_head(workflow, state_path))
130
138
 
@@ -133,7 +141,7 @@ def check_data(workflow: str, code_path: str | Path, state_path: str | Path,
133
141
 
134
142
  @functools.lru_cache(maxsize=128)
135
143
  def calibrate(workflow, code_path: str | Path, state_path: str | Path,
136
- session_id: str) -> Result:
144
+ plot: bool, session_id: str) -> Result:
137
145
  node = load_workflow(workflow, code_path)
138
146
  history = find_result(workflow, state_path)
139
147
 
@@ -143,19 +151,19 @@ def calibrate(workflow, code_path: str | Path, state_path: str | Path,
143
151
  result.data = data
144
152
  save_result(workflow, result, state_path)
145
153
  logger.debug(f'Calibrated "{workflow}" !')
146
- result = call_analyzer(node, data, history, check=False)
154
+ result = call_analyzer(node, data, history, check=False, plot=plot)
147
155
  save_result(workflow, result, state_path, get_head(workflow, state_path))
148
156
  return result
149
157
 
150
158
 
151
- def diagnose(node, code_path: str | Path, state_path: str | Path,
159
+ def diagnose(node, code_path: str | Path, state_path: str | Path, plot: bool,
152
160
  session_id: str):
153
161
  '''
154
162
  Returns: True if node or dependent recalibrated.
155
163
  '''
156
164
  logger.debug(f'diagnose "{node}"')
157
165
  # check_data
158
- result = check_data(node, code_path, state_path, session_id)
166
+ result = check_data(node, code_path, state_path, plot, session_id)
159
167
  # in spec case
160
168
  if result.in_spec:
161
169
  logger.debug(f'"{node}": Checked! In spec, no need to diagnose')
@@ -164,7 +172,7 @@ def diagnose(node, code_path: str | Path, state_path: str | Path,
164
172
  recalibrated = []
165
173
  if result.bad_data:
166
174
  recalibrated = [
167
- diagnose(n, code_path, state_path, session_id)
175
+ diagnose(n, code_path, state_path, plot, session_id)
168
176
  for n in get_dependents(node, code_path)
169
177
  ]
170
178
  if not any(recalibrated) and recalibrated:
@@ -172,7 +180,7 @@ def diagnose(node, code_path: str | Path, state_path: str | Path,
172
180
  return False
173
181
  # calibrate
174
182
  logger.debug(f'recalibrate "{node}" because some dependents recalibrated')
175
- result = calibrate(node, code_path, state_path, session_id)
183
+ result = calibrate(node, code_path, state_path, plot, session_id)
176
184
  if result.bad_data or not result.in_spec:
177
185
  raise CalibrationFailedError(
178
186
  f'"{node}": All dependents passed, but calibration failed!')
@@ -189,7 +197,8 @@ def maintain(node,
189
197
  code_path: str | Path,
190
198
  state_path: str | Path,
191
199
  session_id: str | None = None,
192
- run: bool = False):
200
+ run: bool = False,
201
+ plot: bool = False):
193
202
  if session_id is None:
194
203
  session_id = uuid.uuid4().hex
195
204
  logger.debug(f'run "{node}"' if run else f'maintain "{node}"')
@@ -204,7 +213,7 @@ def maintain(node,
204
213
  logger.debug(f'"{node}": In spec, no need to maintain')
205
214
  return
206
215
  # check_data
207
- result = check_data(node, code_path, state_path, session_id)
216
+ result = check_data(node, code_path, state_path, plot, session_id)
208
217
  if result.in_spec:
209
218
  if not run:
210
219
  logger.debug(f'"{node}": In spec, no need to maintain')
@@ -213,12 +222,12 @@ def maintain(node,
213
222
  logger.debug(f'"{node}": Bad data, diagnosing dependents')
214
223
  for n in get_dependents(node, code_path):
215
224
  logger.debug(f'diagnose "{n}" because of "{node}" bad data')
216
- diagnose(n, code_path, state_path, session_id)
225
+ diagnose(n, code_path, state_path, plot, session_id)
217
226
  else:
218
227
  logger.debug(f'"{node}": All dependents diagnosed')
219
228
  # calibrate
220
229
  logger.debug(f'recalibrate "{node}"')
221
- result = calibrate(node, code_path, state_path, session_id)
230
+ result = calibrate(node, code_path, state_path, plot, session_id)
222
231
  if result.bad_data or not result.in_spec:
223
232
  raise CalibrationFailedError(
224
233
  f'"{node}": All dependents passed, but calibration failed!')
@@ -226,9 +235,12 @@ def maintain(node,
226
235
  return
227
236
 
228
237
 
229
- def run(node, code_path: str | Path, state_path: str | Path):
238
+ def run(node,
239
+ code_path: str | Path,
240
+ state_path: str | Path,
241
+ plot: bool = False):
230
242
  logger.debug(f'run "{node}" without dependences.')
231
- result = calibrate(node, code_path, state_path)
243
+ result = calibrate(node, code_path, state_path, plot)
232
244
  if result.bad_data or not result.in_spec:
233
245
  raise CalibrationFailedError(
234
246
  f'"{node}": All dependents passed, but calibration failed!')
qulab/executor/utils.py CHANGED
@@ -38,7 +38,7 @@ import numpy as np
38
38
 
39
39
 
40
40
  # 多长时间应该检查一次校准实验,单位是秒。
41
- __timeout__ = 200
41
+ __timeout__ = 7*24*3600
42
42
 
43
43
  def depends():
44
44
  return [{deps!r}]
Binary file
qulab/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.4.5"
1
+ __version__ = "2.4.6"
File without changes
File without changes