QuLab 2.4.12__cp310-cp310-macosx_10_9_universal2.whl → 2.4.14__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.12
3
+ Version: 2.4.14
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=ThCRooT22_qpwFtbAvVOyHzpBCuGlfDVkXBXvApzgps,597
3
3
  qulab/dicttree.py,sha256=tRRMpGZYVOLw0TEByE3_2Ss8FdOmzuGL9e1DWbs8qoY,13684
4
- qulab/fun.cpython-310-darwin.so,sha256=l2j8u_hDaQVbFSXjRKFyZxjCsOib1ynJsQdSGXucfj4,126864
5
- qulab/version.py,sha256=3Ac_4-IUz5KK-UOcxuXzEVTZr4p9bV93jrLgO3Au_zA,22
4
+ qulab/fun.cpython-310-darwin.so,sha256=q6JIrxGDqs4OebdUzbs1L3-_roWXrr_-VFmzFzIKrZo,126864
5
+ qulab/version.py,sha256=IPQCIOITfbX8l3dhIiuTYy89V7yOtf70dflfUCn6Dgk,22
6
6
  qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
7
7
  qulab/executor/__main__.py,sha256=qgZcdmx1wBZInHf6ionpuuZytIJnaDje9WRv-a8o2OM,5870
8
- qulab/executor/load.py,sha256=GSRrP2UXOmTgg5VDTmZy_y4xXk91H3Sd5SEX-tOEBqY,8689
9
- qulab/executor/schedule.py,sha256=UOace0Gpt9gR0xe1BoNSUfeHxZynaUS0BFHZhmfnB30,11849
8
+ qulab/executor/load.py,sha256=WNpJmHAxXaQKPkmycsqbqeuAuiudNi-4GscmBKfdKlw,9713
9
+ qulab/executor/schedule.py,sha256=SfMZys8WdmIvfW5fPM42g-F6XwewTdpC0-puhf5TA54,11721
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=n3uCSKh-qdDFFeNvOpj7_es2_B4AaC-ASAlV9gPmSO0,3086
12
+ qulab/executor/utils.py,sha256=jp3F0swO9gpKhmTauxbgEK9WVorjI9FAL6zT60cYTdk,3106
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.12.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
93
- QuLab-2.4.12.dist-info/METADATA,sha256=OdTgtOdriEitEyphmV6lZTskqK97GLmDGp7hkAYQGgo,3699
94
- QuLab-2.4.12.dist-info/WHEEL,sha256=Yd3eJSBM2hj8W-ouaiMfFUwQYAS-D6P73Ob9yN5MZd0,114
95
- QuLab-2.4.12.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
96
- QuLab-2.4.12.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
97
- QuLab-2.4.12.dist-info/RECORD,,
92
+ QuLab-2.4.14.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
93
+ QuLab-2.4.14.dist-info/METADATA,sha256=TThc_IP0lzmpuuWgCsvPExFvPQ7a-to9Zscte5sjtq8,3699
94
+ QuLab-2.4.14.dist-info/WHEEL,sha256=Yd3eJSBM2hj8W-ouaiMfFUwQYAS-D6P73Ob9yN5MZd0,114
95
+ QuLab-2.4.14.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
96
+ QuLab-2.4.14.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
97
+ QuLab-2.4.14.dist-info/RECORD,,
qulab/executor/load.py CHANGED
@@ -128,15 +128,15 @@ def find_unreferenced_workflows(path: str) -> list[str]:
128
128
  for file_path in root.rglob("*.py"):
129
129
  if file_path.name == "__init__.py":
130
130
  continue
131
- if file_path.name.endswith("_template.py") or re.match(
132
- r'.*_tmp_[0-9a-fA-F]{8}.py', file_path.name):
131
+ if file_path.name == 'template.py' or file_path.name.endswith(
132
+ "_template.py"):
133
133
  continue
134
134
  try:
135
135
  rel_path = file_path.relative_to(root)
136
136
  except ValueError:
137
137
  continue
138
138
 
139
- module = load_workflow_from_module(str(rel_path), root)
139
+ module = load_workflow_from_file(str(rel_path), root)
140
140
 
141
141
  if is_workflow(module):
142
142
  rel_str = str(rel_path)
@@ -147,7 +147,7 @@ def find_unreferenced_workflows(path: str) -> list[str]:
147
147
 
148
148
  # Check dependencies for each workflow module
149
149
  for rel_str in workflows:
150
- module = load_workflow_from_module(rel_str, root)
150
+ module = load_workflow_from_file(rel_str, root)
151
151
 
152
152
  depends_func = getattr(module, "depends", None)
153
153
  if depends_func and callable(depends_func):
@@ -157,7 +157,9 @@ def find_unreferenced_workflows(path: str) -> list[str]:
157
157
  )
158
158
  continue
159
159
  try:
160
- depends_list = depends_func()[0]
160
+ depends_list = [
161
+ n.__workflow_id__ for n in get_dependents(module, root)
162
+ ]
161
163
  except Exception as e:
162
164
  warnings.warn(f"Error calling depends() in {rel_str}: {e}")
163
165
  continue
@@ -183,9 +185,9 @@ def find_unreferenced_workflows(path: str) -> list[str]:
183
185
  return unreferenced
184
186
 
185
187
 
186
- def load_workflow_from_module(file_name: str,
187
- base_path: str | Path,
188
- package='workflows') -> WorkflowType:
188
+ def load_workflow_from_file(file_name: str,
189
+ base_path: str | Path,
190
+ package='workflows') -> WorkflowType:
189
191
  if file_name.startswith('cfg:'):
190
192
  return SetConfigWorkflow(file_name[4:])
191
193
  base_path = Path(base_path)
@@ -217,20 +219,45 @@ def load_workflow_from_template(file_name: str,
217
219
 
218
220
  with open(base_path / path) as f:
219
221
  content = f.read()
220
- template = string.Template(content)
222
+
223
+ def replace(text):
224
+ """
225
+ 将给定文本中的所有 _D_("var") 替换为 ${var}。
226
+
227
+ Args:
228
+ text (str): 包含 _D_ 调用的字符串。
229
+
230
+ Returns:
231
+ str: 已经替换的新字符串。
232
+ """
233
+ pattern = re.compile(r'_D_\s*\(\s*(["\'])(\w+)\1\s*\)')
234
+ replacement = r'${\2}'
235
+ new_text = re.sub(pattern, replacement, text)
236
+ return new_text
237
+
238
+ template = string.Template(replace(content))
221
239
  content = template.substitute(mappping)
222
240
 
223
241
  hash_str = hashlib.md5(pickle.dumps(mappping)).hexdigest()[:8]
224
242
  if subtitle is None:
225
- path = path.parent / path.stem.replace('_template',
226
- f'_tmp{hash_str}.py')
243
+ if path.stem == 'template':
244
+ path = path.parent / f'tmp{hash_str}.py'
245
+ else:
246
+ path = path.parent / path.stem.replace('_template',
247
+ f'_tmp{hash_str}.py')
227
248
  else:
228
- path = path.parent / path.stem.replace('_template', f'_{subtitle}.py')
249
+ if path.stem == 'template':
250
+ path = path.parent / f'{subtitle}.py'
251
+ else:
252
+ path = path.parent / path.stem.replace('_template',
253
+ f'_{subtitle}.py')
229
254
 
230
- with open(base_path / path, 'w') as f:
231
- f.write(content)
255
+ file = base_path / path
256
+ if not file.exists():
257
+ with open(file, 'w') as f:
258
+ f.write(content)
232
259
 
233
- module = load_workflow_from_module(str(path), base_path, package)
260
+ module = load_workflow_from_file(str(path), base_path, package)
234
261
 
235
262
  return module
236
263
 
@@ -256,9 +283,14 @@ def load_workflow(workflow: str | tuple[str, dict],
256
283
  w = SetConfigWorkflow(key)
257
284
  w.__workflow_id__ = workflow
258
285
  else:
259
- w = load_workflow_from_module(workflow, base_path, package)
286
+ w = load_workflow_from_file(workflow, base_path, package)
260
287
  w.__workflow_id__ = str(Path(w.__file__).relative_to(base_path))
261
288
  else:
262
289
  raise TypeError(f"Invalid workflow: {workflow}")
263
290
 
264
291
  return w
292
+
293
+
294
+ def get_dependents(workflow: WorkflowType,
295
+ code_path: str | Path) -> list[WorkflowType]:
296
+ return [load_workflow(n, code_path) for n in workflow.depends()[0]]
@@ -6,7 +6,7 @@ from pathlib import Path
6
6
  from loguru import logger
7
7
 
8
8
  from . import transform
9
- from .load import WorkflowType, load_workflow
9
+ from .load import WorkflowType, get_dependents
10
10
  from .storage import (Result, find_result, get_head, renew_result,
11
11
  revoke_result, save_result)
12
12
 
@@ -230,11 +230,6 @@ def diagnose(workflow: WorkflowType, code_path: str | Path,
230
230
  return True
231
231
 
232
232
 
233
- def get_dependents(workflow: WorkflowType,
234
- code_path: str | Path) -> list[WorkflowType]:
235
- return [load_workflow(n, code_path) for n in workflow.depends()[0]]
236
-
237
-
238
233
  @logger.catch(reraise=True)
239
234
  def maintain(workflow: WorkflowType,
240
235
  code_path: str | Path,
@@ -294,8 +289,9 @@ def run(workflow: WorkflowType,
294
289
  code_path: str | Path,
295
290
  state_path: str | Path,
296
291
  plot: bool = False):
292
+ session_id = uuid.uuid4().hex
297
293
  logger.debug(f'run "{workflow.__workflow_id__}" without dependences.')
298
- result = calibrate(workflow, code_path, state_path, plot)
294
+ result = calibrate(workflow, code_path, state_path, plot, session_id=session_id)
299
295
  if result.bad_data or not result.in_spec:
300
296
  raise CalibrationFailedError(
301
297
  f'"{workflow.__workflow_id__}": All dependents passed, but calibration failed!'
qulab/executor/utils.py CHANGED
@@ -34,6 +34,8 @@ def workflow_template(deps: list[str]) -> str:
34
34
  return f"""
35
35
  from loguru import logger
36
36
 
37
+ def _D_(s): pass
38
+
37
39
  import numpy as np
38
40
 
39
41
 
Binary file
qulab/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.4.12"
1
+ __version__ = "2.4.14"
File without changes