QuLab 2.9.7__tar.gz → 2.9.8__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.
- {qulab-2.9.7 → qulab-2.9.8}/PKG-INFO +2 -1
- {qulab-2.9.7 → qulab-2.9.8}/QuLab.egg-info/PKG-INFO +2 -1
- {qulab-2.9.7 → qulab-2.9.8}/QuLab.egg-info/SOURCES.txt +1 -0
- {qulab-2.9.7 → qulab-2.9.8}/QuLab.egg-info/requires.txt +1 -0
- {qulab-2.9.7 → qulab-2.9.8}/pyproject.toml +1 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/__init__.py +1 -0
- qulab-2.9.8/qulab/executor/analyze.py +164 -0
- qulab-2.9.8/qulab/version.py +1 -0
- qulab-2.9.7/qulab/version.py +0 -1
- {qulab-2.9.7 → qulab-2.9.8}/LICENSE +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/MANIFEST.in +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/QuLab.egg-info/dependency_links.txt +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/QuLab.egg-info/entry_points.txt +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/QuLab.egg-info/top_level.txt +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/README.md +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/__main__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/cli/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/cli/commands.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/cli/config.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/dicttree.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/executor/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/executor/cli.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/executor/load.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/executor/schedule.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/executor/storage.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/executor/template.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/executor/transform.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/executor/utils.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/__main__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/config.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/dataset.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/event_queue.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/mainwindow.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/monitor.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/ploter.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/qt_compat.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/monitor/toolbar.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/curd.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/expression.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/models.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/optimize.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/query.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/record.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/scan.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/server.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/space.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/scan/utils.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/__main__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/backend/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/backend/redis.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/base_dataset.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/chunk.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/dataset.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/file.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/base.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/config.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/file.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/ipy.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/models.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/record.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/report.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/models/tag.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/storage/storage.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/chat.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/device/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/device/basedevice.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/device/loader.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/device/utils.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/drivers/FakeInstrument.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/drivers/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/ipy_events.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/net/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/net/bencoder.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/net/cli.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/net/dhcp.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/net/dhcpd.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/net/kad.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/net/kcp.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/net/nginx.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/progress.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/client.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/exceptions.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/msgpack.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/msgpack.pyi +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/router.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/rpc.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/serialize.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/server.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/socket.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/utils.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/worker.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/sys/rpc/zmq_socket.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/tools/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/tools/connection_helper.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/typing.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/utils.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/__init__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/__main__.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/_autoplot.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/plot_circ.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/plot_layout.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/plot_seq.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/qdat.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/rot3d.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/qulab/visualization/widgets.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/setup.cfg +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/setup.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/src/qulab.h +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/tests/test_kad.py +0 -0
- {qulab-2.9.7 → qulab-2.9.8}/tests/test_scan.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: QuLab
|
3
|
-
Version: 2.9.
|
3
|
+
Version: 2.9.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>
|
@@ -36,6 +36,7 @@ Requires-Dist: msgpack>=1.0.5
|
|
36
36
|
Requires-Dist: nevergrad>=1.0.2
|
37
37
|
Requires-Dist: numpy>=1.13.3
|
38
38
|
Requires-Dist: ply>=3.11
|
39
|
+
Requires-Dist: pyperclip>=1.8.2
|
39
40
|
Requires-Dist: pyzmq>=25.1.0
|
40
41
|
Requires-Dist: scipy>=1.0.0
|
41
42
|
Requires-Dist: scikit-optimize>=0.9.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: QuLab
|
3
|
-
Version: 2.9.
|
3
|
+
Version: 2.9.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>
|
@@ -36,6 +36,7 @@ Requires-Dist: msgpack>=1.0.5
|
|
36
36
|
Requires-Dist: nevergrad>=1.0.2
|
37
37
|
Requires-Dist: numpy>=1.13.3
|
38
38
|
Requires-Dist: ply>=3.11
|
39
|
+
Requires-Dist: pyperclip>=1.8.2
|
39
40
|
Requires-Dist: pyzmq>=25.1.0
|
40
41
|
Requires-Dist: scipy>=1.0.0
|
41
42
|
Requires-Dist: scikit-optimize>=0.9.0
|
@@ -0,0 +1,164 @@
|
|
1
|
+
import pickle
|
2
|
+
import threading
|
3
|
+
import time
|
4
|
+
|
5
|
+
import pyperclip
|
6
|
+
import zmq
|
7
|
+
|
8
|
+
from .storage import Report
|
9
|
+
|
10
|
+
# 需要复制到 Notebook 的代码模板
|
11
|
+
clip_template = """
|
12
|
+
from qulab.executor.analyze import get_report as get_report_{server_port}
|
13
|
+
|
14
|
+
report, history = get_report_{server_port}("tcp://{server_address}:{server_port}")
|
15
|
+
# 在这里插入数据处理逻辑
|
16
|
+
|
17
|
+
{analysis_code}
|
18
|
+
"""
|
19
|
+
|
20
|
+
analysis_code = """
|
21
|
+
# report.parameters = {}
|
22
|
+
# report.oracle = {}
|
23
|
+
"""
|
24
|
+
|
25
|
+
|
26
|
+
# ZeroMQ 服务线程,用于响应 Notebook 的请求
|
27
|
+
class ServerThread(threading.Thread):
|
28
|
+
|
29
|
+
def __init__(self, data, timeout):
|
30
|
+
super().__init__()
|
31
|
+
self.data = data
|
32
|
+
self.result = None
|
33
|
+
self.port = 0
|
34
|
+
self.timeout = timeout
|
35
|
+
self.running = True
|
36
|
+
self.finished = threading.Event()
|
37
|
+
self.context = zmq.Context()
|
38
|
+
|
39
|
+
def find_free_port(self):
|
40
|
+
with zmq.Socket(self.context, zmq.REQ) as s:
|
41
|
+
s.bind_to_random_port("tcp://*")
|
42
|
+
self.port = int(
|
43
|
+
s.getsockopt(zmq.LAST_ENDPOINT).decode().split(":")[-1])
|
44
|
+
s.unbind(s.getsockopt(zmq.LAST_ENDPOINT))
|
45
|
+
return self.port
|
46
|
+
|
47
|
+
def run(self):
|
48
|
+
self.port = self.find_free_port()
|
49
|
+
socket = self.context.socket(zmq.REP)
|
50
|
+
socket.bind(f"tcp://*:{self.port}")
|
51
|
+
# 设置 recv 超时 1 秒
|
52
|
+
socket.RCVTIMEO = 1000
|
53
|
+
start_time = time.time()
|
54
|
+
try:
|
55
|
+
while self.running and (time.time() - start_time < self.timeout):
|
56
|
+
try:
|
57
|
+
msg = socket.recv()
|
58
|
+
except zmq.Again:
|
59
|
+
continue # 超时后继续等待
|
60
|
+
|
61
|
+
# Notebook 端请求数据
|
62
|
+
if msg == b"GET":
|
63
|
+
socket.send(pickle.dumps(self.data))
|
64
|
+
else:
|
65
|
+
# Notebook 端提交了处理结果
|
66
|
+
try:
|
67
|
+
self.result = pickle.loads(msg)
|
68
|
+
except Exception as e:
|
69
|
+
# 如果解析失败,也返回默认 ACK
|
70
|
+
self.result = None
|
71
|
+
socket.send(b"ACK")
|
72
|
+
self.running = False
|
73
|
+
break
|
74
|
+
finally:
|
75
|
+
socket.close()
|
76
|
+
self.context.term()
|
77
|
+
self.finished.set()
|
78
|
+
|
79
|
+
def stop(self):
|
80
|
+
self.running = False
|
81
|
+
self.finished.set()
|
82
|
+
|
83
|
+
def wait_for_result(self):
|
84
|
+
self.finished.wait()
|
85
|
+
return self.result
|
86
|
+
|
87
|
+
|
88
|
+
# 进入分析流程,启动服务并打印等待提示
|
89
|
+
def get_result_or_wait_until_timeout(data: tuple[Report, Report | None],
|
90
|
+
timeout: float) -> Report:
|
91
|
+
server = ServerThread(data, timeout)
|
92
|
+
server.start()
|
93
|
+
|
94
|
+
# 格式化代码模板
|
95
|
+
code = clip_template.format(server_address="127.0.0.1",
|
96
|
+
server_port=server.port,
|
97
|
+
analysis_code=analysis_code)
|
98
|
+
|
99
|
+
# 将代码复制到剪切板
|
100
|
+
pyperclip.copy(code)
|
101
|
+
|
102
|
+
# 同时打印到终端,防止误操作导致剪切板内容丢失
|
103
|
+
print("请在 Jupyter Notebook 中运行下面这段代码:")
|
104
|
+
print("-" * 60)
|
105
|
+
print(code)
|
106
|
+
print("-" * 60)
|
107
|
+
print("等待 Notebook 提交处理结果,或等待超时({} 秒)...".format(timeout))
|
108
|
+
|
109
|
+
start_time = time.time()
|
110
|
+
# 采用循环等待提交结果,间隔 0.5 秒检测一次
|
111
|
+
while server.finished.wait(timeout=0.5) is False:
|
112
|
+
elapsed = time.time() - start_time
|
113
|
+
if elapsed >= timeout:
|
114
|
+
# 超时后结束等待
|
115
|
+
server.stop()
|
116
|
+
break
|
117
|
+
|
118
|
+
result = server.wait_for_result()
|
119
|
+
return result if result is not None else data
|
120
|
+
|
121
|
+
|
122
|
+
def manual_analysis(report: Report, history=None, timeout=3600):
|
123
|
+
try:
|
124
|
+
report = get_result_or_wait_until_timeout((report, history), timeout)
|
125
|
+
except Exception as e:
|
126
|
+
pass
|
127
|
+
return report
|
128
|
+
|
129
|
+
|
130
|
+
def get_report(address: str) -> Report:
|
131
|
+
import IPython
|
132
|
+
|
133
|
+
ipy = IPython.get_ipython()
|
134
|
+
if ipy is None:
|
135
|
+
raise RuntimeError("请在 Jupyter Notebook 中运行此函数。")
|
136
|
+
ipy.set_next_input(("from qulab.executor.analyze import submit_report\n"
|
137
|
+
"# 处理完成后,提交结果\n"
|
138
|
+
f"# submit_report(report, \"{address}\")"),
|
139
|
+
replace=False)
|
140
|
+
context = zmq.Context()
|
141
|
+
sock = context.socket(zmq.REQ)
|
142
|
+
sock.connect(address)
|
143
|
+
# 请求数据
|
144
|
+
sock.send(b"GET")
|
145
|
+
report, history = pickle.loads(sock.recv())
|
146
|
+
return report, history
|
147
|
+
|
148
|
+
|
149
|
+
def submit_report(report: Report, address: str):
|
150
|
+
import IPython
|
151
|
+
|
152
|
+
ipy = IPython.get_ipython()
|
153
|
+
if ipy is None:
|
154
|
+
raise RuntimeError("请在 Jupyter Notebook 中运行此函数。")
|
155
|
+
|
156
|
+
# ipy.user_ns['In'][-2]
|
157
|
+
|
158
|
+
context = zmq.Context()
|
159
|
+
sock = context.socket(zmq.REQ)
|
160
|
+
sock.connect(address)
|
161
|
+
# 提交处理后的结果
|
162
|
+
sock.send(pickle.dumps(report))
|
163
|
+
ack = sock.recv()
|
164
|
+
print("结果已提交。")
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "2.9.8"
|
qulab-2.9.7/qulab/version.py
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "2.9.7"
|
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
|
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
|