QuLab 2.6.2__tar.gz → 2.7.1__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.6.2 → qulab-2.7.1}/PKG-INFO +1 -1
- {qulab-2.6.2 → qulab-2.7.1}/QuLab.egg-info/PKG-INFO +1 -1
- {qulab-2.6.2 → qulab-2.7.1}/qulab/executor/cli.py +20 -10
- {qulab-2.6.2 → qulab-2.7.1}/qulab/executor/load.py +11 -6
- {qulab-2.6.2 → qulab-2.7.1}/qulab/executor/schedule.py +37 -8
- {qulab-2.6.2 → qulab-2.7.1}/qulab/executor/storage.py +52 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/executor/transform.py +7 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/executor/utils.py +19 -0
- qulab-2.7.1/qulab/version.py +1 -0
- qulab-2.6.2/qulab/version.py +0 -1
- {qulab-2.6.2 → qulab-2.7.1}/LICENSE +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/MANIFEST.in +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/QuLab.egg-info/SOURCES.txt +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/QuLab.egg-info/dependency_links.txt +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/QuLab.egg-info/entry_points.txt +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/QuLab.egg-info/requires.txt +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/QuLab.egg-info/top_level.txt +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/README.md +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/pyproject.toml +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/__main__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/cli/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/cli/commands.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/cli/config.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/dicttree.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/executor/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/__main__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/config.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/dataset.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/event_queue.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/mainwindow.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/monitor.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/ploter.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/qt_compat.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/monitor/toolbar.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/curd.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/expression.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/models.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/optimize.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/query.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/record.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/scan.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/server.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/space.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/scan/utils.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/__main__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/backend/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/backend/redis.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/base_dataset.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/chunk.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/dataset.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/file.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/base.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/config.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/file.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/ipy.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/models.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/record.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/report.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/models/tag.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/storage/storage.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/chat.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/device/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/device/basedevice.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/device/loader.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/device/utils.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/drivers/FakeInstrument.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/drivers/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/ipy_events.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/net/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/net/bencoder.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/net/cli.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/net/dhcp.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/net/dhcpd.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/net/kad.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/net/kcp.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/net/nginx.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/progress.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/client.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/exceptions.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/msgpack.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/msgpack.pyi +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/router.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/rpc.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/serialize.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/server.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/socket.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/utils.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/worker.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/sys/rpc/zmq_socket.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/typing.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/__init__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/__main__.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/_autoplot.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/plot_circ.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/plot_layout.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/plot_seq.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/qdat.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/rot3d.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/qulab/visualization/widgets.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/setup.cfg +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/setup.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/src/qulab.h +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/tests/test_kad.py +0 -0
- {qulab-2.6.2 → qulab-2.7.1}/tests/test_scan.py +0 -0
@@ -10,9 +10,9 @@ from loguru import logger
|
|
10
10
|
from ..cli.config import get_config_value, log_options
|
11
11
|
from .load import (WorkflowType, find_unreferenced_workflows, get_entries,
|
12
12
|
load_workflow, make_graph)
|
13
|
+
from .schedule import CalibrationFailedError
|
13
14
|
from .schedule import maintain as maintain_workflow
|
14
15
|
from .schedule import run as run_workflow
|
15
|
-
from .schedule import CalibrationFailedError
|
16
16
|
from .transform import set_config_api
|
17
17
|
from .utils import workflow_template
|
18
18
|
|
@@ -137,10 +137,10 @@ def get(key, api):
|
|
137
137
|
is_flag=True,
|
138
138
|
help='Do not run dependents.')
|
139
139
|
@click.option('--retry', '-r', default=1, type=int, help='Retry times.')
|
140
|
-
@click.option('--
|
140
|
+
@click.option('--freeze', is_flag=True, help='Freeze the config table.')
|
141
141
|
@log_options
|
142
142
|
@command_option('run')
|
143
|
-
def run(workflow, code, data, api, plot, no_dependents, retry,
|
143
|
+
def run(workflow, code, data, api, plot, no_dependents, retry, freeze):
|
144
144
|
"""
|
145
145
|
Run a workflow.
|
146
146
|
"""
|
@@ -149,7 +149,7 @@ def run(workflow, code, data, api, plot, no_dependents, retry, update):
|
|
149
149
|
f'{" --plot" if plot else ""}'
|
150
150
|
f'{" --no-dependents" if no_dependents else ""}'
|
151
151
|
f' --retry {retry}'
|
152
|
-
f'{" --
|
152
|
+
f'{" --freeze " if freeze else ""}')
|
153
153
|
if api is not None:
|
154
154
|
api = importlib.import_module(api)
|
155
155
|
set_config_api(api.query_config, api.update_config, api.export_config)
|
@@ -173,9 +173,9 @@ def run(workflow, code, data, api, plot, no_dependents, retry, update):
|
|
173
173
|
code,
|
174
174
|
data,
|
175
175
|
plot=plot,
|
176
|
-
|
176
|
+
freeze=freeze)
|
177
177
|
else:
|
178
|
-
run_workflow(wf, code, data, plot=plot,
|
178
|
+
run_workflow(wf, code, data, plot=plot, freeze=freeze)
|
179
179
|
else:
|
180
180
|
if hasattr(wf, 'entries'):
|
181
181
|
for entry in get_entries(wf, code):
|
@@ -184,14 +184,14 @@ def run(workflow, code, data, api, plot, no_dependents, retry, update):
|
|
184
184
|
data,
|
185
185
|
run=True,
|
186
186
|
plot=plot,
|
187
|
-
|
187
|
+
freeze=freeze)
|
188
188
|
else:
|
189
189
|
maintain_workflow(wf,
|
190
190
|
code,
|
191
191
|
data,
|
192
192
|
run=True,
|
193
193
|
plot=plot,
|
194
|
-
|
194
|
+
freeze=freeze)
|
195
195
|
break
|
196
196
|
except CalibrationFailedError as e:
|
197
197
|
if i == retry - 1:
|
@@ -232,9 +232,19 @@ def maintain(workflow, code, data, api, retry, plot):
|
|
232
232
|
try:
|
233
233
|
if hasattr(wf, 'entries'):
|
234
234
|
for entry in get_entries(wf, code):
|
235
|
-
maintain_workflow(entry,
|
235
|
+
maintain_workflow(entry,
|
236
|
+
code,
|
237
|
+
data,
|
238
|
+
run=False,
|
239
|
+
plot=plot,
|
240
|
+
freeze=False)
|
236
241
|
else:
|
237
|
-
maintain_workflow(wf,
|
242
|
+
maintain_workflow(wf,
|
243
|
+
code,
|
244
|
+
data,
|
245
|
+
run=False,
|
246
|
+
plot=plot,
|
247
|
+
freeze=False)
|
238
248
|
except CalibrationFailedError as e:
|
239
249
|
if i == retry - 1:
|
240
250
|
raise e
|
@@ -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.
|
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
|
-
|
54
|
-
return query_config(self.key)
|
54
|
+
return self.calibrate()
|
55
55
|
|
56
|
-
def check_analyze(self, result: Result, history: Result):
|
57
|
-
|
58
|
-
|
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,9 +7,9 @@ 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,
|
11
|
-
save_result)
|
12
|
-
from .transform import current_config, update_parameters
|
10
|
+
from .storage import (Result, find_result, get_heads, renew_result,
|
11
|
+
revoke_result, save_result)
|
12
|
+
from .transform import current_config, obey_the_oracle, update_parameters
|
13
13
|
|
14
14
|
|
15
15
|
class CalibrationFailedError(Exception):
|
@@ -100,6 +100,24 @@ def call_analyzer(node,
|
|
100
100
|
else:
|
101
101
|
result = node.analyze(result, history=history)
|
102
102
|
veryfy_analyzed_result(result, node.__workflow_id__, "analyze")
|
103
|
+
if hasattr(node, 'oracle') and callable(node.oracle):
|
104
|
+
logger.debug(
|
105
|
+
f'"{node.__workflow_id__}" has oracle method, calling ...')
|
106
|
+
try:
|
107
|
+
result = node.oracle(result,
|
108
|
+
history=history,
|
109
|
+
system_state=get_heads(result.base_path))
|
110
|
+
except Exception as e:
|
111
|
+
logger.exception(e)
|
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
|
+
)
|
117
|
+
if not is_pickleable(result.oracle):
|
118
|
+
raise TypeError(
|
119
|
+
f'"{node.__workflow_id__}" : function "oracle" return not pickleable data'
|
120
|
+
)
|
103
121
|
result.fully_calibrated = True
|
104
122
|
if plot:
|
105
123
|
call_plot(node, result)
|
@@ -276,6 +294,7 @@ def diagnose(workflow: WorkflowType, code_path: str | Path,
|
|
276
294
|
|
277
295
|
result = calibrate(workflow, code_path, state_path, plot, session_id)
|
278
296
|
if result.bad_data or not result.in_spec:
|
297
|
+
obey_the_oracle(result, state_path)
|
279
298
|
raise CalibrationFailedError(
|
280
299
|
f'"{workflow.__workflow_id__}": All dependents passed, but calibration failed!'
|
281
300
|
)
|
@@ -290,7 +309,7 @@ def maintain(workflow: WorkflowType,
|
|
290
309
|
session_id: str | None = None,
|
291
310
|
run: bool = False,
|
292
311
|
plot: bool = False,
|
293
|
-
|
312
|
+
freeze: bool = False):
|
294
313
|
if session_id is None:
|
295
314
|
session_id = uuid.uuid4().hex
|
296
315
|
logger.debug(f'run "{workflow.__workflow_id__}"'
|
@@ -300,7 +319,13 @@ def maintain(workflow: WorkflowType,
|
|
300
319
|
logger.debug(
|
301
320
|
f'maintain "{n.__workflow_id__}" because it is depended by "{workflow.__workflow_id__}"'
|
302
321
|
)
|
303
|
-
maintain(n,
|
322
|
+
maintain(n,
|
323
|
+
code_path,
|
324
|
+
state_path,
|
325
|
+
session_id,
|
326
|
+
run=False,
|
327
|
+
plot=plot,
|
328
|
+
freeze=freeze)
|
304
329
|
else:
|
305
330
|
logger.debug(
|
306
331
|
f'"{workflow.__workflow_id__}": All dependents maintained')
|
@@ -331,10 +356,12 @@ def maintain(workflow: WorkflowType,
|
|
331
356
|
logger.debug(f'recalibrate "{workflow.__workflow_id__}"')
|
332
357
|
result = calibrate(workflow, code_path, state_path, plot, session_id)
|
333
358
|
if result.bad_data or not result.in_spec:
|
359
|
+
if not freeze:
|
360
|
+
obey_the_oracle(result, state_path)
|
334
361
|
raise CalibrationFailedError(
|
335
362
|
f'"{workflow.__workflow_id__}": All dependents passed, but calibration failed!'
|
336
363
|
)
|
337
|
-
if
|
364
|
+
if not freeze:
|
338
365
|
update_parameters(result, state_path)
|
339
366
|
return
|
340
367
|
|
@@ -344,7 +371,7 @@ def run(workflow: WorkflowType,
|
|
344
371
|
code_path: str | Path,
|
345
372
|
state_path: str | Path,
|
346
373
|
plot: bool = False,
|
347
|
-
|
374
|
+
freeze: bool = False):
|
348
375
|
session_id = uuid.uuid4().hex
|
349
376
|
logger.debug(f'run "{workflow.__workflow_id__}" without dependences.')
|
350
377
|
result = calibrate(workflow,
|
@@ -353,9 +380,11 @@ def run(workflow: WorkflowType,
|
|
353
380
|
plot,
|
354
381
|
session_id=session_id)
|
355
382
|
if result.bad_data or not result.in_spec:
|
383
|
+
if not freeze:
|
384
|
+
obey_the_oracle(result, state_path)
|
356
385
|
raise CalibrationFailedError(
|
357
386
|
f'"{workflow.__workflow_id__}": All dependents passed, but calibration failed!'
|
358
387
|
)
|
359
|
-
if
|
388
|
+
if not freeze:
|
360
389
|
update_parameters(result, state_path)
|
361
390
|
return
|
@@ -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():
|
@@ -23,6 +25,7 @@ class Result():
|
|
23
25
|
checked_time: datetime = field(default_factory=datetime.now)
|
24
26
|
ttl: timedelta = timedelta(days=3650)
|
25
27
|
parameters: dict = field(default_factory=dict)
|
28
|
+
oracle: dict = field(default_factory=dict)
|
26
29
|
other_infomation: dict = field(default_factory=dict)
|
27
30
|
data: Any = field(default_factory=tuple)
|
28
31
|
index: int = -1
|
@@ -84,10 +87,56 @@ def random_path(base: Path) -> Path:
|
|
84
87
|
return path
|
85
88
|
|
86
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
|
+
|
87
133
|
def save_result(workflow: str,
|
88
134
|
result: Result,
|
89
135
|
base_path: str | Path,
|
90
136
|
overwrite: bool = False) -> int:
|
137
|
+
if workflow.startswith("cfg:"):
|
138
|
+
return save_config_key_history(workflow[4:], result, base_path)
|
139
|
+
|
91
140
|
logger.debug(
|
92
141
|
f'Saving result for "{workflow}", {result.in_spec=}, {result.bad_data=}, {result.fully_calibrated=}'
|
93
142
|
)
|
@@ -131,6 +180,9 @@ def load_result(path: str | Path, base_path: str | Path) -> Result | None:
|
|
131
180
|
def find_result(
|
132
181
|
workflow: str, base_path: str | Path = get_config_value("data", Path)
|
133
182
|
) -> Result | None:
|
183
|
+
if workflow.startswith("cfg:"):
|
184
|
+
return find_config_key_history(workflow[4:], base_path)
|
185
|
+
|
134
186
|
base_path = Path(base_path)
|
135
187
|
path = get_head(workflow, base_path)
|
136
188
|
if path is None:
|
@@ -43,6 +43,13 @@ def _export_config() -> dict:
|
|
43
43
|
return parameters
|
44
44
|
|
45
45
|
|
46
|
+
def obey_the_oracle(result: Result, data_path):
|
47
|
+
global __current_config_id
|
48
|
+
update_config(result.oracle)
|
49
|
+
cfg = export_config()
|
50
|
+
__current_config_id = save_config(cfg, data_path)
|
51
|
+
|
52
|
+
|
46
53
|
def update_parameters(result: Result, data_path):
|
47
54
|
global __current_config_id
|
48
55
|
update_config(result.parameters)
|
@@ -133,6 +133,25 @@ def check_analyze(result: Result, history: Result | None = None) -> Result:
|
|
133
133
|
result.state = random.choice(['Outdated', 'OK', 'Bad'])
|
134
134
|
|
135
135
|
return result
|
136
|
+
|
137
|
+
|
138
|
+
def oracle(result: Result,
|
139
|
+
history: Result | None = None,
|
140
|
+
system_state: dict[str:str] | None = None) -> Result:
|
141
|
+
\"\"\"
|
142
|
+
谕示:指凭直觉或经验判断,改动某些配置,以期望下次校准成功。
|
143
|
+
|
144
|
+
当校准失败时,根据 analyze 的结果,尝试改变某些配置再重新校准整个系统。
|
145
|
+
比如通常我们在死活测不到 rabi 或能谱时,会换一个 idle bias 再试试。这
|
146
|
+
里我们凭直觉设的那个 bias 值,就是一个谕示,可以通过 oracle 来设定。
|
147
|
+
|
148
|
+
该函数代入的参数 result 是 analyze 函数的返回值。
|
149
|
+
\"\"\"
|
150
|
+
|
151
|
+
# result.oracle['Q0.bias'] = 0.1
|
152
|
+
# result.oracle['Q1.bias'] = -0.03
|
153
|
+
|
154
|
+
return result
|
136
155
|
"""
|
137
156
|
|
138
157
|
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "2.7.1"
|
qulab-2.6.2/qulab/version.py
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "2.6.2"
|
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
|