QuLab 2.9.3__cp311-cp311-win_amd64.whl → 2.9.5__cp311-cp311-win_amd64.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.
- qulab/executor/load.py +21 -8
- qulab/executor/schedule.py +6 -3
- qulab/executor/storage.py +22 -14
- qulab/executor/transform.py +3 -3
- qulab/fun.cp311-win_amd64.pyd +0 -0
- qulab/version.py +1 -1
- {qulab-2.9.3.dist-info → qulab-2.9.5.dist-info}/METADATA +1 -1
- {qulab-2.9.3.dist-info → qulab-2.9.5.dist-info}/RECORD +12 -12
- {qulab-2.9.3.dist-info → qulab-2.9.5.dist-info}/WHEEL +0 -0
- {qulab-2.9.3.dist-info → qulab-2.9.5.dist-info}/entry_points.txt +0 -0
- {qulab-2.9.3.dist-info → qulab-2.9.5.dist-info}/licenses/LICENSE +0 -0
- {qulab-2.9.3.dist-info → qulab-2.9.5.dist-info}/top_level.txt +0 -0
qulab/executor/load.py
CHANGED
@@ -329,6 +329,23 @@ def load_workflow_from_file(file_name: str,
|
|
329
329
|
return module
|
330
330
|
|
331
331
|
|
332
|
+
def _generate_target_file_path(template_path: str | Path, hash_str: str,
|
333
|
+
content: str, base_path: str | Path) -> Path:
|
334
|
+
path = Path(template_path)
|
335
|
+
if path.stem == 'template':
|
336
|
+
path = path.parent / f'tmp{hash_str}.py'
|
337
|
+
elif path.stem.endswith('_template'):
|
338
|
+
path = path.parent / path.stem.replace('_template',
|
339
|
+
f'_tmp{hash_str}.py')
|
340
|
+
else:
|
341
|
+
path = path.parent / f'{path.stem}_tmp{hash_str}.py'
|
342
|
+
|
343
|
+
if 'templates' in path.parts:
|
344
|
+
return Path(*['run' if p == 'templates' else p for p in path.parts])
|
345
|
+
else:
|
346
|
+
return Path('run') / path
|
347
|
+
|
348
|
+
|
332
349
|
def load_workflow_from_template(template_path: str,
|
333
350
|
mapping: dict[str, str],
|
334
351
|
base_path: str | Path,
|
@@ -346,13 +363,8 @@ def load_workflow_from_template(template_path: str,
|
|
346
363
|
content, hash_str = inject_mapping(template, mapping, str(path))
|
347
364
|
|
348
365
|
if target_path is None:
|
349
|
-
|
350
|
-
|
351
|
-
elif path.stem.endswith('_template'):
|
352
|
-
path = path.parent / path.stem.replace('_template',
|
353
|
-
f'_tmp{hash_str}.py')
|
354
|
-
else:
|
355
|
-
path = path.parent / f'{path.stem}_tmp{hash_str}.py'
|
366
|
+
path = _generate_target_file_path(template_path, hash_str, content,
|
367
|
+
base_path)
|
356
368
|
else:
|
357
369
|
path = target_path
|
358
370
|
|
@@ -423,7 +435,8 @@ def _load_workflow_list(workflow, lst, code_path):
|
|
423
435
|
ret.append(load_workflow(n, code_path, mtime=workflow.__mtime__))
|
424
436
|
except TemplateKeyError as e:
|
425
437
|
msg, *_ = e.args
|
426
|
-
e.args = (
|
438
|
+
e.args = (
|
439
|
+
f"Workflow {workflow.__workflow_id__} entry {i}: {msg}", )
|
427
440
|
raise e
|
428
441
|
return ret
|
429
442
|
|
qulab/executor/schedule.py
CHANGED
@@ -150,7 +150,8 @@ def call_check(workflow: WorkflowType, session_id: str, state_path: Path):
|
|
150
150
|
heads=get_heads(state_path),
|
151
151
|
previous_path=get_head(workflow.__workflow_id__,
|
152
152
|
state_path),
|
153
|
-
script_path=save_item(workflow.__source__,
|
153
|
+
script_path=save_item(workflow.__source__, 'items',
|
154
|
+
state_path))
|
154
155
|
|
155
156
|
save_report(workflow.__workflow_id__, report, state_path)
|
156
157
|
|
@@ -176,7 +177,8 @@ def call_calibrate(workflow: WorkflowType, session_id: str, state_path: Path):
|
|
176
177
|
heads=get_heads(state_path),
|
177
178
|
previous_path=get_head(workflow.__workflow_id__,
|
178
179
|
state_path),
|
179
|
-
script_path=save_item(workflow.__source__,
|
180
|
+
script_path=save_item(workflow.__source__, 'items',
|
181
|
+
state_path))
|
180
182
|
|
181
183
|
save_report(workflow.__workflow_id__, report, state_path)
|
182
184
|
|
@@ -274,7 +276,8 @@ def check_data(workflow: WorkflowType, state_path: str | Path, plot: bool,
|
|
274
276
|
heads=get_heads(state_path),
|
275
277
|
previous_path=get_head(workflow.__workflow_id__,
|
276
278
|
state_path),
|
277
|
-
script_path=save_item(workflow.__source__,
|
279
|
+
script_path=save_item(workflow.__source__, 'items',
|
280
|
+
state_path))
|
278
281
|
report.in_spec = False
|
279
282
|
report.bad_data = False
|
280
283
|
return report
|
qulab/executor/storage.py
CHANGED
@@ -118,14 +118,14 @@ class Report():
|
|
118
118
|
@property
|
119
119
|
def config(self):
|
120
120
|
if self.config_path is not None and self.base_path is not None:
|
121
|
-
return load_item(self.config_path, self.base_path)
|
121
|
+
return load_item(self.config_path, 'items', self.base_path)
|
122
122
|
else:
|
123
123
|
return None
|
124
124
|
|
125
125
|
@property
|
126
126
|
def script(self):
|
127
127
|
if self.script_path is not None and self.base_path is not None:
|
128
|
-
source = load_item(self.script_path, self.base_path)
|
128
|
+
source = load_item(self.script_path, 'items', self.base_path)
|
129
129
|
if isinstance(source, str):
|
130
130
|
return source
|
131
131
|
else:
|
@@ -137,7 +137,7 @@ class Report():
|
|
137
137
|
@property
|
138
138
|
def template_source(self):
|
139
139
|
if self.script_path is not None and self.base_path is not None:
|
140
|
-
source = load_item(self.script_path, self.base_path)
|
140
|
+
source = load_item(self.script_path, 'items', self.base_path)
|
141
141
|
return source
|
142
142
|
else:
|
143
143
|
return None
|
@@ -296,7 +296,7 @@ def create_index(name: str,
|
|
296
296
|
return index
|
297
297
|
|
298
298
|
|
299
|
-
def save_item(item, data_path):
|
299
|
+
def save_item(item, group, data_path):
|
300
300
|
salt = 0
|
301
301
|
buf = pickle.dumps(item)
|
302
302
|
buf = lzma.compress(buf)
|
@@ -306,7 +306,7 @@ def save_item(item, data_path):
|
|
306
306
|
h.update(f"{salt}".encode())
|
307
307
|
hashstr = h.hexdigest()
|
308
308
|
item_id = Path(hashstr[:2]) / hashstr[2:4] / hashstr[4:]
|
309
|
-
path = Path(data_path) /
|
309
|
+
path = Path(data_path) / group / item_id
|
310
310
|
if not path.exists():
|
311
311
|
path.parent.mkdir(parents=True, exist_ok=True)
|
312
312
|
with open(path, 'wb') as f:
|
@@ -318,6 +318,14 @@ def save_item(item, data_path):
|
|
318
318
|
return str(item_id)
|
319
319
|
|
320
320
|
|
321
|
+
def append_item_data(data, id, group, base_path):
|
322
|
+
path = Path(base_path) / group / id
|
323
|
+
if not path.exists():
|
324
|
+
raise ValueError(f"Item {id} does not exist.")
|
325
|
+
with open(path, 'ab') as f:
|
326
|
+
f.write(data)
|
327
|
+
|
328
|
+
|
321
329
|
def save_config_key_history(key: str, report: Report,
|
322
330
|
base_path: str | Path) -> int:
|
323
331
|
global __current_config_cache
|
@@ -412,20 +420,20 @@ def query_index(name: str, base_path: str | Path, index: int):
|
|
412
420
|
|
413
421
|
|
414
422
|
@lru_cache(maxsize=4096)
|
415
|
-
def load_item(id, base_path):
|
423
|
+
def load_item(id, group, base_path):
|
416
424
|
if isinstance(base_path, str) and base_path.startswith('ssh://'):
|
417
425
|
with SSHClient() as client:
|
418
426
|
cfg = parse_ssh_uri(base_path)
|
419
427
|
remote_base_path = cfg.pop('remote_file_path')
|
420
428
|
client.load_system_host_keys()
|
421
429
|
client.connect(**cfg)
|
422
|
-
buf = load_item_buf_from_scp(id, remote_base_path, client)
|
430
|
+
buf = load_item_buf_from_scp(id, group, remote_base_path, client)
|
423
431
|
else:
|
424
432
|
base_path = Path(base_path)
|
425
433
|
if zipfile.is_zipfile(base_path):
|
426
|
-
buf = load_item_buf_from_zipfile(id, base_path)
|
434
|
+
buf = load_item_buf_from_zipfile(id, group, base_path)
|
427
435
|
else:
|
428
|
-
path = Path(base_path) /
|
436
|
+
path = Path(base_path) / group / id
|
429
437
|
with open(path, 'rb') as f:
|
430
438
|
buf = f.read()
|
431
439
|
item = pickle.loads(lzma.decompress(buf))
|
@@ -494,9 +502,9 @@ def query_index_from_zipfile(name: str, base_path: str | Path, index: int):
|
|
494
502
|
return context.rstrip()
|
495
503
|
|
496
504
|
|
497
|
-
def load_item_buf_from_zipfile(id, base_path):
|
505
|
+
def load_item_buf_from_zipfile(id, group, base_path):
|
498
506
|
with zipfile.ZipFile(base_path) as zf:
|
499
|
-
with zf.open(f"{base_path.stem}/
|
507
|
+
with zf.open(f"{base_path.stem}/{group}/{id}") as f:
|
500
508
|
return f.read()
|
501
509
|
|
502
510
|
|
@@ -597,11 +605,11 @@ def query_index_from_scp(name: str, base_path: Path, client: SSHClient,
|
|
597
605
|
return None
|
598
606
|
|
599
607
|
|
600
|
-
def load_item_buf_from_scp(id: str,
|
608
|
+
def load_item_buf_from_scp(id: str, group: str, base_path: Path,
|
609
|
+
client: SSHClient):
|
601
610
|
try:
|
602
611
|
with client.open_sftp() as sftp:
|
603
|
-
with sftp.open(str(Path(base_path) /
|
604
|
-
'rb') as f:
|
612
|
+
with sftp.open(str(Path(base_path) / group / str(id)), 'rb') as f:
|
605
613
|
return f.read()
|
606
614
|
except SSHException:
|
607
615
|
return None
|
qulab/executor/transform.py
CHANGED
@@ -47,21 +47,21 @@ def obey_the_oracle(report: Report, data_path):
|
|
47
47
|
global __current_config_id
|
48
48
|
update_config(report.oracle)
|
49
49
|
cfg = export_config()
|
50
|
-
__current_config_id = save_item(cfg, data_path)
|
50
|
+
__current_config_id = save_item(cfg, 'items', data_path)
|
51
51
|
|
52
52
|
|
53
53
|
def update_parameters(report: Report, data_path):
|
54
54
|
global __current_config_id
|
55
55
|
update_config(report.parameters)
|
56
56
|
cfg = export_config()
|
57
|
-
__current_config_id = save_item(cfg, data_path)
|
57
|
+
__current_config_id = save_item(cfg, 'items', data_path)
|
58
58
|
|
59
59
|
|
60
60
|
def current_config(data_path):
|
61
61
|
global __current_config_id
|
62
62
|
if __current_config_id is None:
|
63
63
|
cfg = export_config()
|
64
|
-
__current_config_id = save_item(cfg, data_path)
|
64
|
+
__current_config_id = save_item(cfg, 'items', data_path)
|
65
65
|
return __current_config_id
|
66
66
|
|
67
67
|
|
qulab/fun.cp311-win_amd64.pyd
CHANGED
Binary file
|
qulab/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "2.9.
|
1
|
+
__version__ = "2.9.5"
|
@@ -1,20 +1,20 @@
|
|
1
1
|
qulab/__init__.py,sha256=RrWRvG8Lw27zMr7XP8s-z43b09-wiwPi0ZtiNWbky-c,328
|
2
2
|
qulab/__main__.py,sha256=FL4YsGZL1jEtmcPc5WbleArzhOHLMsWl7OH3O-1d1ss,72
|
3
3
|
qulab/dicttree.py,sha256=ZoSJVWK4VMqfzj42gPb_n5RqLlM6K1Me0WmLIfLEYf8,14195
|
4
|
-
qulab/fun.cp311-win_amd64.pyd,sha256=
|
4
|
+
qulab/fun.cp311-win_amd64.pyd,sha256=Pm1z_sRmol7M-Rx_KrxXKWyIthKGbc8M0SWiIbjQmKU,31744
|
5
5
|
qulab/typing.py,sha256=PRtwbCHWY2ROKK8GHq4Bo8llXrIGo6xC73DrQf7S9os,71
|
6
6
|
qulab/utils.py,sha256=65N2Xj7kqRsQ4epoLNY6tL-i5ts6Wk8YuJYee3Te6zI,3077
|
7
|
-
qulab/version.py,sha256=
|
7
|
+
qulab/version.py,sha256=w1TrLnI1WG1RnKU5vN73-FD1f7CJlGfGd4-SplmrIUE,21
|
8
8
|
qulab/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
qulab/cli/commands.py,sha256=6xd2eYw32k1NmfAuYSu__1kaP12Oz1QVqwbkYXdWno4,588
|
10
10
|
qulab/cli/config.py,sha256=7h3k0K8FYHhI6LVWt8BoDdKrX2ApFDBAUAUuXhHwst4,3799
|
11
11
|
qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
|
12
12
|
qulab/executor/cli.py,sha256=8d-8bRWZ5lmsMtjASsl1zu1rV-syeAESMNVthvIQxlo,10018
|
13
|
-
qulab/executor/load.py,sha256=
|
14
|
-
qulab/executor/schedule.py,sha256=
|
15
|
-
qulab/executor/storage.py,sha256=
|
13
|
+
qulab/executor/load.py,sha256=GBd0FZHO7kLvwzcXAnChStgeaMKJBNVjUi_Yh43PABA,17736
|
14
|
+
qulab/executor/schedule.py,sha256=XRimchHYCgnMAOtCvNLjwMv9IkcTAyBAUCHKQs5RBRw,18745
|
15
|
+
qulab/executor/storage.py,sha256=PWQIDYjQaoyLGgAKh0X1tlNQTgDWR8bI-HVie4hSkyA,21075
|
16
16
|
qulab/executor/template.py,sha256=dKQM3IlADdTi9qp0fnOYjyycRNEl7KeSCBZhwbmP8bQ,10828
|
17
|
-
qulab/executor/transform.py,sha256=
|
17
|
+
qulab/executor/transform.py,sha256=ABrnD0l53NI2y2e8ETYO7lmqGtyiE6EAY965kFRqme0,2311
|
18
18
|
qulab/executor/utils.py,sha256=l_b0y2kMwYKyyXeFtoblPYwKNU-wiFQ9PMo9QlWl9wE,6213
|
19
19
|
qulab/monitor/__init__.py,sha256=xEVDkJF8issrsDeLqQmDsvtRmrf-UiViFcGTWuzdlFU,43
|
20
20
|
qulab/monitor/__main__.py,sha256=k2H1H5Zf9LLXTDLISJkbikLH-z0f1e5i5i6wXXYPOrE,105
|
@@ -97,9 +97,9 @@ qulab/visualization/plot_seq.py,sha256=Uo1-dB1YE9IN_A9tuaOs9ZG3S5dKDQ_l98iD2Wbxp
|
|
97
97
|
qulab/visualization/qdat.py,sha256=HubXFu4nfcA7iUzghJGle1C86G6221hicLR0b-GqhKQ,5887
|
98
98
|
qulab/visualization/rot3d.py,sha256=jGHJcqj1lEWBUV-W4GUGONGacqjrYvuFoFCwPse5h1Y,757
|
99
99
|
qulab/visualization/widgets.py,sha256=HcYwdhDtLreJiYaZuN3LfofjJmZcLwjMfP5aasebgDo,3266
|
100
|
-
qulab-2.9.
|
101
|
-
qulab-2.9.
|
102
|
-
qulab-2.9.
|
103
|
-
qulab-2.9.
|
104
|
-
qulab-2.9.
|
105
|
-
qulab-2.9.
|
100
|
+
qulab-2.9.5.dist-info/licenses/LICENSE,sha256=b4NRQ-GFVpJMT7RuExW3NwhfbrYsX7AcdB7Gudok-fs,1086
|
101
|
+
qulab-2.9.5.dist-info/METADATA,sha256=v4f4OtNOvJnF6m4Zn8Z3eABRc_ddeoIPQmsxAOrQEWE,3826
|
102
|
+
qulab-2.9.5.dist-info/WHEEL,sha256=_ZWIY2n7n6SpiuIFl1-RvcMp4Ty36T57FKf-7NzqZHM,101
|
103
|
+
qulab-2.9.5.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
|
104
|
+
qulab-2.9.5.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
|
105
|
+
qulab-2.9.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|