QuLab 2.4.5__cp311-cp311-macosx_10_9_universal2.whl → 2.4.7__cp311-cp311-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.7
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-311-darwin.so,sha256=gK5w7gmeLxexg9CyWo-FGPnJruiy97t31j62aNj2Lfw,126848
5
- qulab/version.py,sha256=sAipLPNdb_IaH9sS_UwXSh0AgDCRTxME2hVBsZX2Dko,21
4
+ qulab/fun.cpython-311-darwin.so,sha256=z2DQchDlGZjIOSwd-6p0aC-GWVtZGpkMizIvCVH4Lk8,126848
5
+ qulab/version.py,sha256=hEWwdPkTm3-PwhJ6bXiKRaQw0V32r2z6903I897HSjE,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=zhRbSAsl1zAcTbrPSyH4FzfF6sr2438TcQSUWJcEiIA,9552
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=K10eKSN6_vzvMOgXxWbVOQNR7Orfl6gBTCpCI8bcYx4,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.7.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
93
+ QuLab-2.4.7.dist-info/METADATA,sha256=J8cjgoJKXK5L8-2ysWiNwnpGzlEfRNRr9KWwUUi-HCs,3698
94
+ QuLab-2.4.7.dist-info/WHEEL,sha256=K10eKSN6_vzvMOgXxWbVOQNR7Orfl6gBTCpCI8bcYx4,114
95
+ QuLab-2.4.7.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
96
+ QuLab-2.4.7.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
97
+ QuLab-2.4.7.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,22 @@ 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
+ @logger.catch()
79
+ def call_plot(node, result, check=False):
80
+ if hasattr(node, 'plot') and callable(node.plot):
81
+ state, params, other = transform.result_to_params(result)
82
+ node.plot(state, params, other)
83
+
84
+
76
85
  @functools.lru_cache(maxsize=128)
77
86
  def check_data(workflow: str, code_path: str | Path, state_path: str | Path,
78
- session_id: str) -> Result:
87
+ plot: bool, session_id: str) -> Result:
79
88
  """
80
89
  check data answers two questions:
81
90
  Is the parameter associated with this cal in spec,
@@ -109,7 +118,7 @@ def check_data(workflow: str, code_path: str | Path, state_path: str | Path,
109
118
  save_result(workflow, result, state_path)
110
119
 
111
120
  logger.debug(f'Checked "{workflow}" !')
112
- result = call_analyzer(node, data, history, check=True)
121
+ result = call_analyzer(node, data, history, check=True, plot=plot)
113
122
  if result.in_spec:
114
123
  logger.debug(f'"{workflow}": checked in spec, renewing result')
115
124
  renew_result(workflow, state_path)
@@ -124,7 +133,7 @@ def check_data(workflow: str, code_path: str | Path, state_path: str | Path,
124
133
  save_result(workflow, result, state_path)
125
134
 
126
135
  logger.debug(f'Calibrated "{workflow}" !')
127
- result = call_analyzer(node, data, history, check=False)
136
+ result = call_analyzer(node, data, history, check=False, plot=plot)
128
137
  save_result(workflow, result, state_path,
129
138
  get_head(workflow, state_path))
130
139
 
@@ -133,7 +142,7 @@ def check_data(workflow: str, code_path: str | Path, state_path: str | Path,
133
142
 
134
143
  @functools.lru_cache(maxsize=128)
135
144
  def calibrate(workflow, code_path: str | Path, state_path: str | Path,
136
- session_id: str) -> Result:
145
+ plot: bool, session_id: str) -> Result:
137
146
  node = load_workflow(workflow, code_path)
138
147
  history = find_result(workflow, state_path)
139
148
 
@@ -143,19 +152,19 @@ def calibrate(workflow, code_path: str | Path, state_path: str | Path,
143
152
  result.data = data
144
153
  save_result(workflow, result, state_path)
145
154
  logger.debug(f'Calibrated "{workflow}" !')
146
- result = call_analyzer(node, data, history, check=False)
155
+ result = call_analyzer(node, data, history, check=False, plot=plot)
147
156
  save_result(workflow, result, state_path, get_head(workflow, state_path))
148
157
  return result
149
158
 
150
159
 
151
- def diagnose(node, code_path: str | Path, state_path: str | Path,
160
+ def diagnose(node, code_path: str | Path, state_path: str | Path, plot: bool,
152
161
  session_id: str):
153
162
  '''
154
163
  Returns: True if node or dependent recalibrated.
155
164
  '''
156
165
  logger.debug(f'diagnose "{node}"')
157
166
  # check_data
158
- result = check_data(node, code_path, state_path, session_id)
167
+ result = check_data(node, code_path, state_path, plot, session_id)
159
168
  # in spec case
160
169
  if result.in_spec:
161
170
  logger.debug(f'"{node}": Checked! In spec, no need to diagnose')
@@ -164,7 +173,7 @@ def diagnose(node, code_path: str | Path, state_path: str | Path,
164
173
  recalibrated = []
165
174
  if result.bad_data:
166
175
  recalibrated = [
167
- diagnose(n, code_path, state_path, session_id)
176
+ diagnose(n, code_path, state_path, plot, session_id)
168
177
  for n in get_dependents(node, code_path)
169
178
  ]
170
179
  if not any(recalibrated) and recalibrated:
@@ -172,7 +181,7 @@ def diagnose(node, code_path: str | Path, state_path: str | Path,
172
181
  return False
173
182
  # calibrate
174
183
  logger.debug(f'recalibrate "{node}" because some dependents recalibrated')
175
- result = calibrate(node, code_path, state_path, session_id)
184
+ result = calibrate(node, code_path, state_path, plot, session_id)
176
185
  if result.bad_data or not result.in_spec:
177
186
  raise CalibrationFailedError(
178
187
  f'"{node}": All dependents passed, but calibration failed!')
@@ -189,14 +198,15 @@ def maintain(node,
189
198
  code_path: str | Path,
190
199
  state_path: str | Path,
191
200
  session_id: str | None = None,
192
- run: bool = False):
201
+ run: bool = False,
202
+ plot: bool = False):
193
203
  if session_id is None:
194
204
  session_id = uuid.uuid4().hex
195
205
  logger.debug(f'run "{node}"' if run else f'maintain "{node}"')
196
206
  # recursive maintain
197
207
  for n in get_dependents(node, code_path):
198
208
  logger.debug(f'maintain "{n}" because it is depended by "{node}"')
199
- maintain(n, code_path, state_path, session_id)
209
+ maintain(n, code_path, state_path, session_id, plot=plot)
200
210
  else:
201
211
  logger.debug(f'"{node}": All dependents maintained')
202
212
  # check_state
@@ -204,7 +214,7 @@ def maintain(node,
204
214
  logger.debug(f'"{node}": In spec, no need to maintain')
205
215
  return
206
216
  # check_data
207
- result = check_data(node, code_path, state_path, session_id)
217
+ result = check_data(node, code_path, state_path, plot, session_id)
208
218
  if result.in_spec:
209
219
  if not run:
210
220
  logger.debug(f'"{node}": In spec, no need to maintain')
@@ -213,12 +223,12 @@ def maintain(node,
213
223
  logger.debug(f'"{node}": Bad data, diagnosing dependents')
214
224
  for n in get_dependents(node, code_path):
215
225
  logger.debug(f'diagnose "{n}" because of "{node}" bad data')
216
- diagnose(n, code_path, state_path, session_id)
226
+ diagnose(n, code_path, state_path, plot, session_id)
217
227
  else:
218
228
  logger.debug(f'"{node}": All dependents diagnosed')
219
229
  # calibrate
220
230
  logger.debug(f'recalibrate "{node}"')
221
- result = calibrate(node, code_path, state_path, session_id)
231
+ result = calibrate(node, code_path, state_path, plot, session_id)
222
232
  if result.bad_data or not result.in_spec:
223
233
  raise CalibrationFailedError(
224
234
  f'"{node}": All dependents passed, but calibration failed!')
@@ -226,9 +236,12 @@ def maintain(node,
226
236
  return
227
237
 
228
238
 
229
- def run(node, code_path: str | Path, state_path: str | Path):
239
+ def run(node,
240
+ code_path: str | Path,
241
+ state_path: str | Path,
242
+ plot: bool = False):
230
243
  logger.debug(f'run "{node}" without dependences.')
231
- result = calibrate(node, code_path, state_path)
244
+ result = calibrate(node, code_path, state_path, plot)
232
245
  if result.bad_data or not result.in_spec:
233
246
  raise CalibrationFailedError(
234
247
  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.7"
File without changes
File without changes