QuLab 2.7.7__cp312-cp312-macosx_10_13_universal2.whl → 2.7.8__cp312-cp312-macosx_10_13_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.7.7
3
+ Version: 2.7.8
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,18 +1,18 @@
1
1
  qulab/__init__.py,sha256=KJcUcZ5qXY6wlAoirzK_B-dgtDjsLmOE671v3gcXO_c,286
2
2
  qulab/__main__.py,sha256=fjaRSL_uUjNIzBGNgjlGswb9TJ2VD5qnkZHW3hItrD4,68
3
3
  qulab/dicttree.py,sha256=tRRMpGZYVOLw0TEByE3_2Ss8FdOmzuGL9e1DWbs8qoY,13684
4
- qulab/fun.cpython-312-darwin.so,sha256=gEBUeklF6wQLlMcI447XeUAR0E4gTTaV0ImeSv_Aodw,126864
4
+ qulab/fun.cpython-312-darwin.so,sha256=1IVuoTQNgWrDLiL7jS_FB97nujYE4M8jnmDKaHZCJKs,126864
5
5
  qulab/typing.py,sha256=vg62sGqxuD9CI5677ejlzAmf2fVdAESZCQjAE_xSxPg,69
6
6
  qulab/utils.py,sha256=JIXMSmZU0uYfKG_tzawpK7vRNPRir_hJE8JlqkVLX2o,1260
7
- qulab/version.py,sha256=TXxZaBvn1Y_BQ2YYBZ0iedwKmA3iOfYiZehFXuAoky0,21
7
+ qulab/version.py,sha256=89JN-VCK3x9bbDL4mH6FsYHIsGSTeoIxhxxTqfViSLE,21
8
8
  qulab/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  qulab/cli/commands.py,sha256=tgDIkkeIoasQXAifJZ6NU8jDgpNgb2a-B0C4nF0evrE,559
10
10
  qulab/cli/config.py,sha256=SdNmWzweWAdyk8M2oKYhMxnkaJ0qIayPlsLGCNlVqME,3108
11
11
  qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
12
12
  qulab/executor/cli.py,sha256=gGka2M6xccfM8facsIJ2qZ1y2Yx8C4BRhc1JG6nK9mo,8932
13
13
  qulab/executor/load.py,sha256=4FY_SwumLDUewC265v4j_ZGGpfYOgH4c8PtglYcWpBw,18077
14
- qulab/executor/schedule.py,sha256=DHQ5dI5YX8_frWplOoLEb9htcfM5-mikiSBNSPWT1io,16725
15
- qulab/executor/storage.py,sha256=sBD-aNvj29l5HtoTpk_627qarZkPn33F-hcc80AuF6k,11079
14
+ qulab/executor/schedule.py,sha256=OYvolWiafZbXiodeyJvr0-hscHvBt-eifmg7uWEymII,16952
15
+ qulab/executor/storage.py,sha256=JH817-d6izBiz6wBGWvWxNEY_IPhRwRmGcB_eUpvE8U,11364
16
16
  qulab/executor/transform.py,sha256=s0kxWQx8Sr9pMIQke1BLNM6KqrSogAkjB6Zkapl8YSU,2189
17
17
  qulab/executor/utils.py,sha256=cF6-2jlvlHyTjNHdxXKG04Fjfm3_3wfDQAF1G8DQphk,5686
18
18
  qulab/monitor/__init__.py,sha256=nTHelnDpxRS_fl_B38TsN0njgq8eVTEz9IAnN3NbDlM,42
@@ -94,9 +94,9 @@ qulab/visualization/plot_seq.py,sha256=UWTS6p9nfX_7B8ehcYo6UnSTUCjkBsNU9jiOeW2ca
94
94
  qulab/visualization/qdat.py,sha256=ZeevBYWkzbww4xZnsjHhw7wRorJCBzbG0iEu-XQB4EA,5735
95
95
  qulab/visualization/rot3d.py,sha256=lMrEJlRLwYe6NMBlGkKYpp_V9CTipOAuDy6QW_cQK00,734
96
96
  qulab/visualization/widgets.py,sha256=6KkiTyQ8J-ei70LbPQZAK35wjktY47w2IveOa682ftA,3180
97
- QuLab-2.7.7.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
98
- QuLab-2.7.7.dist-info/METADATA,sha256=uhQQtVYRkuDdN8Inh-gnDFZDTekIqQRrQEo5V9hPD1A,3698
99
- QuLab-2.7.7.dist-info/WHEEL,sha256=iDXcyuxg-66TzzqHGH-kgw_HJdaJE_1RHznrvPNCSNs,115
100
- QuLab-2.7.7.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
101
- QuLab-2.7.7.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
102
- QuLab-2.7.7.dist-info/RECORD,,
97
+ QuLab-2.7.8.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
98
+ QuLab-2.7.8.dist-info/METADATA,sha256=ZZQMlhagxeJHogg-wXRxB2SaFziTmaBjXwy05kW4fps,3698
99
+ QuLab-2.7.8.dist-info/WHEEL,sha256=iDXcyuxg-66TzzqHGH-kgw_HJdaJE_1RHznrvPNCSNs,115
100
+ QuLab-2.7.8.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
101
+ QuLab-2.7.8.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
102
+ QuLab-2.7.8.dist-info/RECORD,,
@@ -7,7 +7,7 @@ from pathlib import Path
7
7
  from loguru import logger
8
8
 
9
9
  from .load import WorkflowType, get_dependents
10
- from .storage import (Report, find_report, get_heads, renew_report,
10
+ from .storage import (Report, find_report, get_head, get_heads, renew_report,
11
11
  revoke_report, save_report)
12
12
  from .transform import current_config, obey_the_oracle, update_parameters
13
13
 
@@ -120,42 +120,6 @@ def check_state(workflow: WorkflowType, code_path: str | Path,
120
120
  return True
121
121
 
122
122
 
123
- def call_analyzer(node: WorkflowType,
124
- report: Report,
125
- history: Report | None,
126
- check=False,
127
- plot=False) -> Report:
128
- if check:
129
- report = node.check_analyze(report, history=history)
130
- veryfy_analyzed_report(report, node.__workflow_id__, "check_analyze")
131
- report.fully_calibrated = False
132
- else:
133
- report = node.analyze(report, history=history)
134
- veryfy_analyzed_report(report, node.__workflow_id__, "analyze")
135
- if hasattr(node, 'oracle') and callable(node.oracle):
136
- logger.debug(
137
- f'"{node.__workflow_id__}" has oracle method, calling ...')
138
- try:
139
- report = node.oracle(report,
140
- history=history,
141
- system_state=get_heads(report.base_path))
142
- except Exception as e:
143
- logger.exception(e)
144
- report.oracle = {}
145
- if not isinstance(report, Report):
146
- raise TypeError(
147
- f'"{node.__workflow_id__}" : function "oracle" must return a Report object'
148
- )
149
- if not is_pickleable(report.oracle):
150
- raise TypeError(
151
- f'"{node.__workflow_id__}" : function "oracle" return not pickleable data'
152
- )
153
- report.fully_calibrated = True
154
- if plot:
155
- call_plot(node, report)
156
- return report
157
-
158
-
159
123
  @logger.catch()
160
124
  def call_plot(node: WorkflowType, report: Report, check=False):
161
125
  if hasattr(node, 'plot') and callable(node.plot):
@@ -177,12 +141,11 @@ def call_check(workflow: WorkflowType, session_id: str, state_path: Path):
177
141
  data=data,
178
142
  config_path=current_config(state_path),
179
143
  base_path=state_path,
180
- heads=get_heads(state_path))
144
+ heads=get_heads(state_path),
145
+ previous_path=get_head(workflow.__workflow_id__,
146
+ state_path))
181
147
 
182
- save_report(workflow.__workflow_id__,
183
- report,
184
- state_path,
185
- refresh_heads=False)
148
+ save_report(workflow.__workflow_id__, report, state_path)
186
149
 
187
150
  set_cache(session_id, (workflow, 'check'), report)
188
151
  return report
@@ -203,7 +166,9 @@ def call_calibrate(workflow: WorkflowType, session_id: str, state_path: Path):
203
166
  data=data,
204
167
  config_path=current_config(state_path),
205
168
  base_path=state_path,
206
- heads=get_heads(state_path))
169
+ heads=get_heads(state_path),
170
+ previous_path=get_head(workflow.__workflow_id__,
171
+ state_path))
207
172
 
208
173
  save_report(workflow.__workflow_id__, report, state_path)
209
174
 
@@ -211,8 +176,60 @@ def call_calibrate(workflow: WorkflowType, session_id: str, state_path: Path):
211
176
  return report
212
177
 
213
178
 
214
- def check_data(workflow: WorkflowType, code_path: str | Path,
215
- state_path: str | Path, plot: bool, session_id: str) -> Report:
179
+ def call_check_analyzer(node: WorkflowType,
180
+ report: Report,
181
+ history: Report | None,
182
+ state_path: Path,
183
+ plot=False) -> Report:
184
+ report = node.check_analyze(report, history=history)
185
+ veryfy_analyzed_report(report, node.__workflow_id__, "check_analyze")
186
+ report.fully_calibrated = False
187
+ if report.in_spec:
188
+ logger.debug(
189
+ f'"{node.__workflow_id__}": checked in spec, renewing report')
190
+ renew_report(node.__workflow_id__, report.previous, state_path)
191
+ else:
192
+ logger.debug(
193
+ f'"{node.__workflow_id__}": checked out of spec, revoking report')
194
+ revoke_report(node.__workflow_id__, report.previous, state_path)
195
+ return report
196
+
197
+
198
+ def call_analyzer(node: WorkflowType,
199
+ report: Report,
200
+ history: Report | None,
201
+ state_path: Path,
202
+ plot=False) -> Report:
203
+
204
+ report = node.analyze(report, history=history)
205
+ veryfy_analyzed_report(report, node.__workflow_id__, "analyze")
206
+ if hasattr(node, 'oracle') and callable(node.oracle):
207
+ logger.debug(
208
+ f'"{node.__workflow_id__}" has oracle method, calling ...')
209
+ try:
210
+ report = node.oracle(report,
211
+ history=history,
212
+ system_state=get_heads(report.base_path))
213
+ except Exception as e:
214
+ logger.exception(e)
215
+ report.oracle = {}
216
+ if not isinstance(report, Report):
217
+ raise TypeError(
218
+ f'"{node.__workflow_id__}" : function "oracle" must return a Report object'
219
+ )
220
+ if not is_pickleable(report.oracle):
221
+ raise TypeError(
222
+ f'"{node.__workflow_id__}" : function "oracle" return not pickleable data'
223
+ )
224
+ report.fully_calibrated = True
225
+ save_report(node.__workflow_id__, report, state_path, overwrite=True)
226
+ if plot:
227
+ call_plot(node, report)
228
+ return report
229
+
230
+
231
+ def check_data(workflow: WorkflowType, state_path: str | Path, plot: bool,
232
+ session_id: str) -> Report:
216
233
  """
217
234
  check data answers two questions:
218
235
  Is the parameter associated with this cal in spec,
@@ -225,7 +242,9 @@ def check_data(workflow: WorkflowType, code_path: str | Path,
225
242
  report = Report(workflow=workflow.__workflow_id__,
226
243
  config_path=current_config(state_path),
227
244
  base_path=state_path,
228
- heads=get_heads(state_path))
245
+ heads=get_heads(state_path),
246
+ previous_path=get_head(workflow.__workflow_id__,
247
+ state_path))
229
248
  report.in_spec = False
230
249
  report.bad_data = False
231
250
  return report
@@ -250,21 +269,11 @@ def check_data(workflow: WorkflowType, code_path: str | Path,
250
269
  report = call_check(workflow, session_id, state_path)
251
270
 
252
271
  logger.debug(f'Checked "{workflow.__workflow_id__}" !')
253
- report = call_analyzer(workflow,
254
- report,
255
- history,
256
- check=True,
257
- plot=plot)
258
- if report.in_spec:
259
- logger.debug(
260
- f'"{workflow.__workflow_id__}": checked in spec, renewing report'
261
- )
262
- renew_report(workflow.__workflow_id__, report, state_path)
263
- else:
264
- logger.debug(
265
- f'"{workflow.__workflow_id__}": checked out of spec, revoking report'
266
- )
267
- revoke_report(workflow.__workflow_id__, report, state_path)
272
+ report = call_check_analyzer(workflow,
273
+ report,
274
+ history,
275
+ state_path,
276
+ plot=plot)
268
277
  else:
269
278
  logger.debug(
270
279
  f'Checking "{workflow.__workflow_id__}" with "calibrate" method ...'
@@ -276,17 +285,13 @@ def check_data(workflow: WorkflowType, code_path: str | Path,
276
285
  report = call_analyzer(workflow,
277
286
  report,
278
287
  history,
279
- check=False,
288
+ state_path,
280
289
  plot=plot)
281
- save_report(workflow.__workflow_id__,
282
- report,
283
- state_path,
284
- overwrite=True)
285
290
  return report
286
291
 
287
292
 
288
- def calibrate(workflow: WorkflowType, code_path: str | Path,
289
- state_path: str | Path, plot: bool, session_id: str) -> Report:
293
+ def calibrate(workflow: WorkflowType, state_path: str | Path, plot: bool,
294
+ session_id: str) -> Report:
290
295
  history = find_report(workflow.__workflow_id__, state_path)
291
296
 
292
297
  logger.debug(f'Calibrating "{workflow.__workflow_id__}" ...')
@@ -295,9 +300,12 @@ def calibrate(workflow: WorkflowType, code_path: str | Path,
295
300
 
296
301
  logger.debug(f'Calibrated "{workflow.__workflow_id__}" !')
297
302
 
298
- report = call_analyzer(workflow, report, history, check=False, plot=plot)
299
-
300
- save_report(workflow.__workflow_id__, report, state_path, overwrite=True)
303
+ report = call_analyzer(workflow,
304
+ report,
305
+ history,
306
+ state_path,
307
+ check=False,
308
+ plot=plot)
301
309
  return report
302
310
 
303
311
 
@@ -308,7 +316,7 @@ def diagnose(workflow: WorkflowType, code_path: str | Path,
308
316
  '''
309
317
  logger.debug(f'diagnose "{workflow.__workflow_id__}"')
310
318
  # check_data
311
- report = check_data(workflow, code_path, state_path, plot, session_id)
319
+ report = check_data(workflow, state_path, plot, session_id)
312
320
  # in spec case
313
321
  if report.in_spec:
314
322
  logger.debug(
@@ -350,7 +358,7 @@ def diagnose(workflow: WorkflowType, code_path: str | Path,
350
358
  else:
351
359
  logger.error(f'Never reach: recalibrate "{workflow.__workflow_id__}"')
352
360
 
353
- report = calibrate(workflow, code_path, state_path, plot, session_id)
361
+ report = calibrate(workflow, state_path, plot, session_id)
354
362
  if report.bad_data or not report.in_spec:
355
363
  obey_the_oracle(report, state_path)
356
364
  raise CalibrationFailedError(
@@ -393,7 +401,7 @@ def maintain(workflow: WorkflowType,
393
401
  f'"{workflow.__workflow_id__}": In spec, no need to maintain')
394
402
  return
395
403
  # check_data
396
- report = check_data(workflow, code_path, state_path, plot, session_id)
404
+ report = check_data(workflow, state_path, plot, session_id)
397
405
  if report.in_spec:
398
406
  if not run:
399
407
  logger.debug(
@@ -412,7 +420,7 @@ def maintain(workflow: WorkflowType,
412
420
  f'"{workflow.__workflow_id__}": All dependents diagnosed')
413
421
  # calibrate
414
422
  logger.debug(f'recalibrate "{workflow.__workflow_id__}"')
415
- report = calibrate(workflow, code_path, state_path, plot, session_id)
423
+ report = calibrate(workflow, state_path, plot, session_id)
416
424
  if report.bad_data or not report.in_spec:
417
425
  if not freeze:
418
426
  obey_the_oracle(report, state_path)
@@ -432,11 +440,7 @@ def run(workflow: WorkflowType,
432
440
  freeze: bool = False):
433
441
  session_id = uuid.uuid4().hex
434
442
  logger.debug(f'run "{workflow.__workflow_id__}" without dependences.')
435
- report = calibrate(workflow,
436
- code_path,
437
- state_path,
438
- plot,
439
- session_id=session_id)
443
+ report = calibrate(workflow, state_path, plot, session_id=session_id)
440
444
  if report.bad_data or not report.in_spec:
441
445
  if not freeze:
442
446
  obey_the_oracle(report, state_path)
qulab/executor/storage.py CHANGED
@@ -149,8 +149,11 @@ def save_report(workflow: str,
149
149
  f'Saving report for "{workflow}", {report.in_spec=}, {report.bad_data=}, {report.fully_calibrated=}'
150
150
  )
151
151
  base_path = Path(base_path)
152
- if overwrite:
152
+ try:
153
153
  buf = lzma.compress(pickle.dumps(report))
154
+ except:
155
+ raise ValueError(f"Can't pickle report for {workflow}")
156
+ if overwrite:
154
157
  path = report.path
155
158
  if path is None:
156
159
  raise ValueError("Report path is None, can't overwrite.")
@@ -158,8 +161,6 @@ def save_report(workflow: str,
158
161
  index = int.from_bytes(f.read(8), 'big')
159
162
  report.index = index
160
163
  else:
161
- report.previous_path = get_head(workflow, base_path)
162
- buf = lzma.compress(pickle.dumps(report))
163
164
  path = random_path(base_path / 'objects')
164
165
  (base_path / 'objects' / path).parent.mkdir(parents=True,
165
166
  exist_ok=True)
@@ -168,7 +169,6 @@ def save_report(workflow: str,
168
169
  base_path,
169
170
  context=str(path),
170
171
  width=35)
171
-
172
172
  with open(base_path / 'objects' / path, "wb") as f:
173
173
  f.write(report.index.to_bytes(8, 'big'))
174
174
  f.write(buf)
@@ -202,22 +202,30 @@ def find_report(
202
202
  return load_report(path, base_path)
203
203
 
204
204
 
205
- def renew_report(workflow: str, report, base_path: str | Path):
205
+ def renew_report(workflow: str, report: Report | None, base_path: str | Path):
206
206
  logger.debug(f'Renewing report for "{workflow}"')
207
- report = find_report(workflow, base_path)
208
207
  if report is not None:
209
208
  report.checked_time = datetime.now()
210
- return save_report(workflow, report, base_path)
209
+ return save_report(workflow,
210
+ report,
211
+ base_path,
212
+ overwrite=True,
213
+ refresh_heads=True)
214
+ else:
215
+ raise ValueError(f"Can't renew report for {workflow}")
211
216
 
212
217
 
213
- def revoke_report(workflow: str, report, base_path: str | Path):
218
+ def revoke_report(workflow: str, report: Report | None, base_path: str | Path):
214
219
  logger.debug(f'Revoking report for "{workflow}"')
215
220
  base_path = Path(base_path)
216
- path = get_head(workflow, base_path)
217
- if path is not None:
218
- report = load_report(path, base_path)
221
+ if report is not None:
219
222
  report.in_spec = False
220
- return save_report(workflow, report, base_path)
223
+ report.previous_path = report.path
224
+ return save_report(workflow,
225
+ report,
226
+ base_path,
227
+ overwrite=False,
228
+ refresh_heads=True)
221
229
 
222
230
 
223
231
  def set_head(workflow: str, path: Path, base_path: str | Path):
Binary file
qulab/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.7.7"
1
+ __version__ = "2.7.8"
File without changes
File without changes