QuLab 2.4.18__cp312-cp312-macosx_10_13_universal2.whl → 2.4.20__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.4.18
3
+ Version: 2.4.20
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,17 +1,17 @@
1
1
  qulab/__init__.py,sha256=P-Mx2p4TVmL91SoxoeXcj8Qm0x4xUf5Q_FLk0Yc_gIQ,138
2
2
  qulab/__main__.py,sha256=JgErYkiskih8Y6oRwowALtR-rwQhAAdqOYWjQraRIPI,59
3
3
  qulab/dicttree.py,sha256=tRRMpGZYVOLw0TEByE3_2Ss8FdOmzuGL9e1DWbs8qoY,13684
4
- qulab/fun.cpython-312-darwin.so,sha256=QNmr2TtOaM4wKSaKxqfCFQRcARQxrgwRPbRhU_XsCRs,126864
5
- qulab/version.py,sha256=vQo2edKgYGHn5FfacX8TS2Blt-3b9unuA9CvJvhZhfo,22
4
+ qulab/fun.cpython-312-darwin.so,sha256=-Ckd6wlBupwONbFbJNda13b4TSY6HQ0sLwDcbjMOD8A,126864
5
+ qulab/version.py,sha256=0EYwz_vOIrGy7c3cr82zYeYGyK4QxRsY1XkcDC_j6SI,22
6
6
  qulab/cli/__init__.py,sha256=tgDIkkeIoasQXAifJZ6NU8jDgpNgb2a-B0C4nF0evrE,559
7
- qulab/cli/config.py,sha256=QksTYD3-RBYBG8xnKLAh7EXrNOwxr128XXr30ZTFW6A,2983
7
+ qulab/cli/config.py,sha256=Dhl7i_KM3iJ29SVIgiTmzdBsqeSOuJpcz9qcGCBp3Ts,3051
8
8
  qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
9
9
  qulab/executor/cli.py,sha256=owdDSaSuzTPQA5SlNCxX4nHWITU1BF0VZMj7tLqCZhM,5781
10
- qulab/executor/load.py,sha256=eKysHL5EHKd_YcfHOVwRoaNsD-k0cTuxDY_7Yn5W8hA,11078
10
+ qulab/executor/load.py,sha256=fZNmsOGR_2s1IykVmVwziDKeWCIej-jRJAQzKJRUdaE,11990
11
11
  qulab/executor/schedule.py,sha256=bXQzn3e3tCvAVdEBsvh5ecAThP52njyxbsrlrxC9TzA,11922
12
12
  qulab/executor/storage.py,sha256=M66Q5_Uc5MMfc_QAuuaaexwAz7wxBPMkeleB5nRpQmI,4621
13
13
  qulab/executor/transform.py,sha256=inaOn6eqCs22ZZ0xAQl8s8YCoEACaXSwFNNu7jqdwAk,2148
14
- qulab/executor/utils.py,sha256=RmnT0wMTAvavM-abgFt2tQN8TaaHuk86-YAiOUQCoBU,3101
14
+ qulab/executor/utils.py,sha256=_9EZkx2rBpsWjhDN5BZ-Lq9MboqmHcI1jtwpRyrzSTY,3101
15
15
  qulab/monitor/__init__.py,sha256=nTHelnDpxRS_fl_B38TsN0njgq8eVTEz9IAnN3NbDlM,42
16
16
  qulab/monitor/__main__.py,sha256=w3yUcqq195LzSnXTkQcuC1RSFRhy4oQ_PEBmucXguME,97
17
17
  qulab/monitor/config.py,sha256=fQ5JcsMApKc1UwANEnIvbDQZl8uYW0tle92SaYtX9lI,744
@@ -91,9 +91,9 @@ qulab/visualization/plot_seq.py,sha256=UWTS6p9nfX_7B8ehcYo6UnSTUCjkBsNU9jiOeW2ca
91
91
  qulab/visualization/qdat.py,sha256=ZeevBYWkzbww4xZnsjHhw7wRorJCBzbG0iEu-XQB4EA,5735
92
92
  qulab/visualization/rot3d.py,sha256=lMrEJlRLwYe6NMBlGkKYpp_V9CTipOAuDy6QW_cQK00,734
93
93
  qulab/visualization/widgets.py,sha256=6KkiTyQ8J-ei70LbPQZAK35wjktY47w2IveOa682ftA,3180
94
- QuLab-2.4.18.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
95
- QuLab-2.4.18.dist-info/METADATA,sha256=SX3AKzWxSqBxr-pLe9B0pVY65i7zCPltEgIkq-yKVWU,3699
96
- QuLab-2.4.18.dist-info/WHEEL,sha256=iDXcyuxg-66TzzqHGH-kgw_HJdaJE_1RHznrvPNCSNs,115
97
- QuLab-2.4.18.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
98
- QuLab-2.4.18.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
99
- QuLab-2.4.18.dist-info/RECORD,,
94
+ QuLab-2.4.20.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
95
+ QuLab-2.4.20.dist-info/METADATA,sha256=L8c-qIikU3zaAhOUIlynPWdk-KhYfLoQW9L_bjnWaGs,3699
96
+ QuLab-2.4.20.dist-info/WHEEL,sha256=iDXcyuxg-66TzzqHGH-kgw_HJdaJE_1RHznrvPNCSNs,115
97
+ QuLab-2.4.20.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
98
+ QuLab-2.4.20.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
99
+ QuLab-2.4.20.dist-info/RECORD,,
qulab/cli/config.py CHANGED
@@ -25,7 +25,7 @@ def _get_config_value(option_name, type_cast=str, command_name=None):
25
25
  if env_value := os.getenv(env_var):
26
26
  if type_cast is bool:
27
27
  return env_value.lower() in ("true", "1", "yes")
28
- if "path" in option_name:
28
+ if "path" in option_name or issubclass(type_cast, Path):
29
29
  return os.path.expanduser(env_value)
30
30
  return type_cast(env_value)
31
31
 
@@ -43,7 +43,7 @@ def _get_config_value(option_name, type_cast=str, command_name=None):
43
43
  fallback=None):
44
44
  if type_cast is bool:
45
45
  return config_value.lower() in ("true", "1", "yes")
46
- if "path" in option_name:
46
+ if "path" in option_name or issubclass(type_cast, Path):
47
47
  return os.path.expanduser(config_value)
48
48
  return type_cast(config_value)
49
49
 
@@ -66,7 +66,7 @@ def log_options(func):
66
66
  help=f"Enable debug mode")
67
67
  @click.option("--log",
68
68
  type=click.Path(),
69
- default=lambda: get_config_value("log"),
69
+ default=lambda: get_config_value("log", Path),
70
70
  help=f"Log file path")
71
71
  @functools.wraps(func)
72
72
  def wrapper(*args, log=None, debug=False, **kwargs):
qulab/executor/load.py CHANGED
@@ -1,8 +1,11 @@
1
+ import base64
1
2
  import hashlib
2
3
  import inspect
4
+ import lzma
3
5
  import pickle
4
6
  import re
5
7
  import string
8
+ import textwrap
6
9
  import warnings
7
10
  from importlib.util import module_from_spec, spec_from_file_location
8
11
  from pathlib import Path
@@ -224,8 +227,24 @@ def load_workflow_from_file(file_name: str,
224
227
  return module
225
228
 
226
229
 
230
+ def encode_mapping(mapping):
231
+ mapping_bytes = lzma.compress(pickle.dumps(mapping))
232
+ hash_str = hashlib.md5(mapping_bytes).hexdigest()[:8]
233
+ mappping_code = '\n'.join(
234
+ textwrap.wrap(base64.b64encode(mapping_bytes).decode(), 100))
235
+ return hash_str, mappping_code
236
+
237
+
238
+ def decode_mapping(hash_str, mappping_code):
239
+ mapping_bytes = base64.b64decode(mappping_code.replace('\n', ''))
240
+ if hash_str != hashlib.md5(mapping_bytes).hexdigest()[:8]:
241
+ raise ValueError("Hash does not match")
242
+ mapping = pickle.loads(lzma.decompress(mapping_bytes))
243
+ return mapping
244
+
245
+
227
246
  def load_workflow_from_template(template_path: str,
228
- mappping: dict[str, str],
247
+ mapping: dict[str, str],
229
248
  base_path: str | Path,
230
249
  target_path: str | None = None,
231
250
  package='workflows',
@@ -237,30 +256,36 @@ def load_workflow_from_template(template_path: str,
237
256
  content = f.read()
238
257
 
239
258
  mtime = max(Path(template_path).stat().st_mtime, mtime)
259
+ hash_str, mapping_code = encode_mapping(mapping)
240
260
 
241
261
  def replace(text):
242
262
  """
243
- 将给定文本中的所有 _D_("var") 替换为 ${var}
263
+ 将给定文本中的所有 VAR("var") 替换为 __VAR_{hash_str}["var"]
244
264
 
245
265
  Args:
246
- text (str): 包含 _D_ 调用的字符串。
266
+ text (str): 包含 VAR 调用的字符串。
247
267
 
248
268
  Returns:
249
269
  str: 已经替换的新字符串。
250
270
  """
251
- pattern = re.compile(r'_D_\s*\(\s*(["\'])(\w+)\1\s*\)')
252
- replacement = r'${\2}'
271
+ pattern = re.compile(r'VAR\s*\(\s*(["\'])(\w+)\1\s*\)')
272
+ replacement = f'__VAR_{hash_str}' + r'["\2"]'
253
273
  new_text = re.sub(pattern, replacement, text)
254
274
  return new_text
255
275
 
256
276
  template = string.Template(replace(content))
257
277
  keys = template.get_identifiers()
258
- missing = set(keys) - set(mappping.keys())
278
+ missing = set(keys) - set(mapping.keys())
259
279
  if missing:
260
280
  raise KeyError(f"{template_path}: Missing keys in mapping: {missing}")
261
- content = template.substitute(mappping)
281
+ content = template.substitute(mapping)
262
282
 
263
- hash_str = hashlib.md5(pickle.dumps(mappping)).hexdigest()[:8]
283
+ inject_code = [
284
+ "from qulab.executor.load import decode_mapping",
285
+ f"__VAR_{hash_str} = decode_mapping(\"{hash_str}\",",
286
+ f"\"\"\"{mapping_code}\"\"\")"
287
+ ]
288
+ content = '\n'.join(inject_code + [content])
264
289
  if target_path is None:
265
290
  if path.stem == 'template':
266
291
  path = path.parent / f'tmp{hash_str}.py'
qulab/executor/utils.py CHANGED
@@ -34,7 +34,7 @@ def workflow_template(deps: list[str]) -> str:
34
34
  return f"""
35
35
  from loguru import logger
36
36
 
37
- def _D_(s): pass
37
+ def VAR(s): pass
38
38
 
39
39
  import numpy as np
40
40
 
Binary file
qulab/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.4.18"
1
+ __version__ = "2.4.20"
File without changes