QuLab 2.7.0__tar.gz → 2.7.2__tar.gz

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.
Files changed (112) hide show
  1. {qulab-2.7.0 → qulab-2.7.2}/PKG-INFO +1 -1
  2. {qulab-2.7.0 → qulab-2.7.2}/QuLab.egg-info/PKG-INFO +1 -1
  3. {qulab-2.7.0 → qulab-2.7.2}/QuLab.egg-info/SOURCES.txt +1 -0
  4. {qulab-2.7.0 → qulab-2.7.2}/qulab/executor/load.py +11 -6
  5. {qulab-2.7.0 → qulab-2.7.2}/qulab/executor/schedule.py +12 -6
  6. {qulab-2.7.0 → qulab-2.7.2}/qulab/executor/storage.py +51 -0
  7. {qulab-2.7.0 → qulab-2.7.2}/qulab/executor/utils.py +3 -2
  8. qulab-2.7.2/qulab/utils.py +31 -0
  9. qulab-2.7.2/qulab/version.py +1 -0
  10. qulab-2.7.0/qulab/version.py +0 -1
  11. {qulab-2.7.0 → qulab-2.7.2}/LICENSE +0 -0
  12. {qulab-2.7.0 → qulab-2.7.2}/MANIFEST.in +0 -0
  13. {qulab-2.7.0 → qulab-2.7.2}/QuLab.egg-info/dependency_links.txt +0 -0
  14. {qulab-2.7.0 → qulab-2.7.2}/QuLab.egg-info/entry_points.txt +0 -0
  15. {qulab-2.7.0 → qulab-2.7.2}/QuLab.egg-info/requires.txt +0 -0
  16. {qulab-2.7.0 → qulab-2.7.2}/QuLab.egg-info/top_level.txt +0 -0
  17. {qulab-2.7.0 → qulab-2.7.2}/README.md +0 -0
  18. {qulab-2.7.0 → qulab-2.7.2}/pyproject.toml +0 -0
  19. {qulab-2.7.0 → qulab-2.7.2}/qulab/__init__.py +0 -0
  20. {qulab-2.7.0 → qulab-2.7.2}/qulab/__main__.py +0 -0
  21. {qulab-2.7.0 → qulab-2.7.2}/qulab/cli/__init__.py +0 -0
  22. {qulab-2.7.0 → qulab-2.7.2}/qulab/cli/commands.py +0 -0
  23. {qulab-2.7.0 → qulab-2.7.2}/qulab/cli/config.py +0 -0
  24. {qulab-2.7.0 → qulab-2.7.2}/qulab/dicttree.py +0 -0
  25. {qulab-2.7.0 → qulab-2.7.2}/qulab/executor/__init__.py +0 -0
  26. {qulab-2.7.0 → qulab-2.7.2}/qulab/executor/cli.py +0 -0
  27. {qulab-2.7.0 → qulab-2.7.2}/qulab/executor/transform.py +0 -0
  28. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/__init__.py +0 -0
  29. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/__main__.py +0 -0
  30. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/config.py +0 -0
  31. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/dataset.py +0 -0
  32. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/event_queue.py +0 -0
  33. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/mainwindow.py +0 -0
  34. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/monitor.py +0 -0
  35. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/ploter.py +0 -0
  36. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/qt_compat.py +0 -0
  37. {qulab-2.7.0 → qulab-2.7.2}/qulab/monitor/toolbar.py +0 -0
  38. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/__init__.py +0 -0
  39. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/curd.py +0 -0
  40. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/expression.py +0 -0
  41. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/models.py +0 -0
  42. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/optimize.py +0 -0
  43. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/query.py +0 -0
  44. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/record.py +0 -0
  45. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/scan.py +0 -0
  46. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/server.py +0 -0
  47. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/space.py +0 -0
  48. {qulab-2.7.0 → qulab-2.7.2}/qulab/scan/utils.py +0 -0
  49. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/__init__.py +0 -0
  50. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/__main__.py +0 -0
  51. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/backend/__init__.py +0 -0
  52. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/backend/redis.py +0 -0
  53. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/base_dataset.py +0 -0
  54. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/chunk.py +0 -0
  55. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/dataset.py +0 -0
  56. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/file.py +0 -0
  57. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/__init__.py +0 -0
  58. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/base.py +0 -0
  59. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/config.py +0 -0
  60. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/file.py +0 -0
  61. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/ipy.py +0 -0
  62. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/models.py +0 -0
  63. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/record.py +0 -0
  64. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/report.py +0 -0
  65. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/models/tag.py +0 -0
  66. {qulab-2.7.0 → qulab-2.7.2}/qulab/storage/storage.py +0 -0
  67. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/__init__.py +0 -0
  68. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/chat.py +0 -0
  69. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/device/__init__.py +0 -0
  70. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/device/basedevice.py +0 -0
  71. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/device/loader.py +0 -0
  72. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/device/utils.py +0 -0
  73. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/drivers/FakeInstrument.py +0 -0
  74. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/drivers/__init__.py +0 -0
  75. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/ipy_events.py +0 -0
  76. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/net/__init__.py +0 -0
  77. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/net/bencoder.py +0 -0
  78. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/net/cli.py +0 -0
  79. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/net/dhcp.py +0 -0
  80. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/net/dhcpd.py +0 -0
  81. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/net/kad.py +0 -0
  82. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/net/kcp.py +0 -0
  83. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/net/nginx.py +0 -0
  84. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/progress.py +0 -0
  85. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/__init__.py +0 -0
  86. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/client.py +0 -0
  87. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/exceptions.py +0 -0
  88. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/msgpack.py +0 -0
  89. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/msgpack.pyi +0 -0
  90. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/router.py +0 -0
  91. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/rpc.py +0 -0
  92. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/serialize.py +0 -0
  93. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/server.py +0 -0
  94. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/socket.py +0 -0
  95. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/utils.py +0 -0
  96. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/worker.py +0 -0
  97. {qulab-2.7.0 → qulab-2.7.2}/qulab/sys/rpc/zmq_socket.py +0 -0
  98. {qulab-2.7.0 → qulab-2.7.2}/qulab/typing.py +0 -0
  99. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/__init__.py +0 -0
  100. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/__main__.py +0 -0
  101. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/_autoplot.py +0 -0
  102. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/plot_circ.py +0 -0
  103. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/plot_layout.py +0 -0
  104. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/plot_seq.py +0 -0
  105. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/qdat.py +0 -0
  106. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/rot3d.py +0 -0
  107. {qulab-2.7.0 → qulab-2.7.2}/qulab/visualization/widgets.py +0 -0
  108. {qulab-2.7.0 → qulab-2.7.2}/setup.cfg +0 -0
  109. {qulab-2.7.0 → qulab-2.7.2}/setup.py +0 -0
  110. {qulab-2.7.0 → qulab-2.7.2}/src/qulab.h +0 -0
  111. {qulab-2.7.0 → qulab-2.7.2}/tests/test_kad.py +0 -0
  112. {qulab-2.7.0 → qulab-2.7.2}/tests/test_scan.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: QuLab
3
- Version: 2.7.0
3
+ Version: 2.7.2
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,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: QuLab
3
- Version: 2.7.0
3
+ Version: 2.7.2
4
4
  Summary: contral instruments and manage data
5
5
  Author-email: feihoo87 <feihoo87@gmail.com>
6
6
  Maintainer-email: feihoo87 <feihoo87@gmail.com>
@@ -13,6 +13,7 @@ qulab/__init__.py
13
13
  qulab/__main__.py
14
14
  qulab/dicttree.py
15
15
  qulab/typing.py
16
+ qulab/utils.py
16
17
  qulab/version.py
17
18
  qulab/cli/__init__.py
18
19
  qulab/cli/commands.py
@@ -24,6 +24,7 @@ class SetConfigWorkflow():
24
24
 
25
25
  def __init__(self, key):
26
26
  self.key = key
27
+ self.__workflow_id__ = f"cfg:{self.key}"
27
28
 
28
29
  def depends(self):
29
30
  return []
@@ -31,7 +32,7 @@ class SetConfigWorkflow():
31
32
  def check_state(self, history: Result) -> bool:
32
33
  from . import transform
33
34
  try:
34
- return self._equal(history.params[self.key],
35
+ return self._equal(history.parameters[self.key],
35
36
  transform.query_config(self.key))
36
37
  except:
37
38
  return False
@@ -50,18 +51,22 @@ class SetConfigWorkflow():
50
51
  return result
51
52
 
52
53
  def check(self):
53
- from .transform import query_config
54
- return query_config(self.key)
54
+ return self.calibrate()
55
55
 
56
- def check_analyze(self, result: Result, history: Result):
57
- result.state = 'Outdated'
58
- result.parameters = {self.key: result.data}
56
+ def check_analyze(self, result: Result, history: Result | None):
57
+ if self.check_state(history):
58
+ result.state = 'OK'
59
+ result.parameters = {self.key: history.data}
60
+ else:
61
+ result.state = 'Outdated'
59
62
  return result
60
63
 
61
64
  @staticmethod
62
65
  def _equal(a, b):
63
66
  import numpy as np
64
67
 
68
+ if a is b:
69
+ return True
65
70
  try:
66
71
  return a == b
67
72
  except:
@@ -7,8 +7,8 @@ from pathlib import Path
7
7
  from loguru import logger
8
8
 
9
9
  from .load import WorkflowType, get_dependents
10
- from .storage import (Result, find_result, renew_result, revoke_result,
11
- save_result)
10
+ from .storage import (Result, find_result, get_heads, renew_result,
11
+ revoke_result, save_result)
12
12
  from .transform import current_config, obey_the_oracle, update_parameters
13
13
 
14
14
 
@@ -47,7 +47,7 @@ def check_state(workflow: WorkflowType, code_path: str | Path,
47
47
  3. No dependencies have been recalibrated since the last time check data or calibrate was run on this cal.
48
48
  4. All dependencies pass check state.
49
49
  """
50
- logger.debug(f'check_state: "{workflow}"')
50
+ logger.debug(f'check_state: "{workflow.__workflow_id__}"')
51
51
  result = find_result(workflow.__workflow_id__, state_path)
52
52
  if not result:
53
53
  logger.debug(
@@ -104,13 +104,19 @@ def call_analyzer(node,
104
104
  logger.debug(
105
105
  f'"{node.__workflow_id__}" has oracle method, calling ...')
106
106
  try:
107
- result = node.oracle(result, history=history)
107
+ result = node.oracle(result,
108
+ history=history,
109
+ system_state=get_heads(result.base_path))
108
110
  except Exception as e:
109
111
  logger.exception(e)
110
112
  result.oracle = {}
113
+ if not isinstance(result, Result):
114
+ raise TypeError(
115
+ f'"{node.__workflow_id__}" : function "oracle" must return a Result object'
116
+ )
111
117
  if not is_pickleable(result.oracle):
112
118
  raise TypeError(
113
- f'"{node.__workflow_id__}" : "oracle" return not pickleable data'
119
+ f'"{node.__workflow_id__}" : function "oracle" return not pickleable data'
114
120
  )
115
121
  result.fully_calibrated = True
116
122
  if plot:
@@ -201,7 +207,7 @@ def check_data(workflow: WorkflowType, code_path: str | Path,
201
207
  base_path=state_path)
202
208
  save_result(workflow.__workflow_id__, result, state_path)
203
209
 
204
- logger.debug(f'Calibrated "{workflow}" !')
210
+ logger.debug(f'Calibrated "{workflow.__workflow_id__}" !')
205
211
  result = call_analyzer(workflow,
206
212
  result,
207
213
  history,
@@ -12,6 +12,8 @@ from loguru import logger
12
12
 
13
13
  from ..cli.config import get_config_value
14
14
 
15
+ __current_config_cache = None
16
+
15
17
 
16
18
  @dataclass
17
19
  class Result():
@@ -85,10 +87,56 @@ def random_path(base: Path) -> Path:
85
87
  return path
86
88
 
87
89
 
90
+ def save_config_key_history(key: str, result: Result,
91
+ base_path: str | Path) -> int:
92
+ global __current_config_cache
93
+ base_path = Path(base_path) / 'state'
94
+ base_path.mkdir(parents=True, exist_ok=True)
95
+
96
+ if __current_config_cache is None:
97
+ if (base_path / 'parameters.pkl').exists():
98
+ with open(base_path / 'parameters.pkl', 'rb') as f:
99
+ __current_config_cache = pickle.load(f)
100
+ else:
101
+ __current_config_cache = {}
102
+
103
+ __current_config_cache[key] = result.data
104
+
105
+ with open(base_path / 'parameters.pkl', 'wb') as f:
106
+ pickle.dump(__current_config_cache, f)
107
+ return 0
108
+
109
+
110
+ def find_config_key_history(key: str, base_path: str | Path) -> Result | None:
111
+ global __current_config_cache
112
+ base_path = Path(base_path) / 'state'
113
+ if __current_config_cache is None:
114
+ if (base_path / 'parameters.pkl').exists():
115
+ with open(base_path / 'parameters.pkl', 'rb') as f:
116
+ __current_config_cache = pickle.load(f)
117
+ else:
118
+ __current_config_cache = {}
119
+
120
+ if key in __current_config_cache:
121
+ value = __current_config_cache.get(key, None)
122
+ result = Result(workflow=f'cfg:{key}',
123
+ bad_data=False,
124
+ in_spec=True,
125
+ fully_calibrated=True,
126
+ parameters={key: value},
127
+ data=value)
128
+ result.bad_data = False
129
+ return result
130
+ return None
131
+
132
+
88
133
  def save_result(workflow: str,
89
134
  result: Result,
90
135
  base_path: str | Path,
91
136
  overwrite: bool = False) -> int:
137
+ if workflow.startswith("cfg:"):
138
+ return save_config_key_history(workflow[4:], result, base_path)
139
+
92
140
  logger.debug(
93
141
  f'Saving result for "{workflow}", {result.in_spec=}, {result.bad_data=}, {result.fully_calibrated=}'
94
142
  )
@@ -132,6 +180,9 @@ def load_result(path: str | Path, base_path: str | Path) -> Result | None:
132
180
  def find_result(
133
181
  workflow: str, base_path: str | Path = get_config_value("data", Path)
134
182
  ) -> Result | None:
183
+ if workflow.startswith("cfg:"):
184
+ return find_config_key_history(workflow[4:], base_path)
185
+
135
186
  base_path = Path(base_path)
136
187
  path = get_head(workflow, base_path)
137
188
  if path is None:
@@ -135,7 +135,9 @@ def check_analyze(result: Result, history: Result | None = None) -> Result:
135
135
  return result
136
136
 
137
137
 
138
- def oracle(result: Result, history: Result | None = None):
138
+ def oracle(result: Result,
139
+ history: Result | None = None,
140
+ system_state: dict[str:str] | None = None) -> Result:
139
141
  \"\"\"
140
142
  谕示:指凭直觉或经验判断,改动某些配置,以期望下次校准成功。
141
143
 
@@ -145,7 +147,6 @@ def oracle(result: Result, history: Result | None = None):
145
147
 
146
148
  该函数代入的参数 result 是 analyze 函数的返回值。
147
149
  \"\"\"
148
- result.oracle = {{}}
149
150
 
150
151
  # result.oracle['Q0.bias'] = 0.1
151
152
  # result.oracle['Q1.bias'] = -0.03
@@ -0,0 +1,31 @@
1
+ import subprocess
2
+ import sys
3
+
4
+
5
+ def run_detached_with_terminal(executable_path):
6
+ """
7
+ 启动可执行文件并在新终端窗口中保持运行,Python退出后进程仍存在。
8
+ 适用于Windows、Linux和macOS。
9
+ """
10
+ try:
11
+ if sys.platform == 'win32':
12
+ # Windows:使用start命令启动新cmd窗口
13
+ cmd = f'start cmd /k "{executable_path}"'
14
+ subprocess.Popen(cmd, shell=True)
15
+ elif sys.platform == 'darwin':
16
+ # macOS:通过AppleScript在Terminal中执行命令
17
+ escaped_path = executable_path.replace('"', r'\"')
18
+ script = f'tell application "Terminal" to do script "{escaped_path}"'
19
+ subprocess.Popen(['osascript', '-e', script],
20
+ start_new_session=True)
21
+ else:
22
+ # Linux:尝试gnome-terminal或xterm
23
+ try:
24
+ subprocess.Popen(['gnome-terminal', '--', executable_path],
25
+ start_new_session=True)
26
+ except FileNotFoundError:
27
+ subprocess.Popen(['xterm', '-e', executable_path],
28
+ start_new_session=True)
29
+ except Exception as e:
30
+ print(f"启动失败: {e}")
31
+ sys.exit(1)
@@ -0,0 +1 @@
1
+ __version__ = "2.7.2"
@@ -1 +0,0 @@
1
- __version__ = "2.7.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes