QuLab 2.9.4__cp311-cp311-macosx_10_9_universal2.whl → 2.9.6__cp311-cp311-macosx_10_9_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.
- qulab/cli/commands.py +2 -1
- qulab/executor/cli.py +37 -0
- qulab/executor/load.py +30 -1
- qulab/fun.cpython-311-darwin.so +0 -0
- qulab/version.py +1 -1
- {qulab-2.9.4.dist-info → qulab-2.9.6.dist-info}/METADATA +1 -1
- {qulab-2.9.4.dist-info → qulab-2.9.6.dist-info}/RECORD +11 -11
- {qulab-2.9.4.dist-info → qulab-2.9.6.dist-info}/WHEEL +0 -0
- {qulab-2.9.4.dist-info → qulab-2.9.6.dist-info}/entry_points.txt +0 -0
- {qulab-2.9.4.dist-info → qulab-2.9.6.dist-info}/licenses/LICENSE +0 -0
- {qulab-2.9.4.dist-info → qulab-2.9.6.dist-info}/top_level.txt +0 -0
qulab/cli/commands.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import click
|
2
2
|
|
3
|
-
from ..executor.cli import create, get, maintain, run, set
|
3
|
+
from ..executor.cli import create, get, maintain, reproduce, run, set
|
4
4
|
from ..monitor.__main__ import main as monitor
|
5
5
|
from ..scan.server import server
|
6
6
|
from ..sys.net.cli import dht
|
@@ -24,6 +24,7 @@ cli.add_command(dht)
|
|
24
24
|
cli.add_command(server)
|
25
25
|
cli.add_command(maintain)
|
26
26
|
cli.add_command(run)
|
27
|
+
cli.add_command(reproduce)
|
27
28
|
cli.add_command(create)
|
28
29
|
cli.add_command(set)
|
29
30
|
cli.add_command(get)
|
qulab/executor/cli.py
CHANGED
@@ -290,3 +290,40 @@ def maintain(workflow, code, data, api, retry, plot):
|
|
290
290
|
raise e
|
291
291
|
logger.warning(f'Calibration failed, retrying ({i + 1}/{retry})')
|
292
292
|
continue
|
293
|
+
|
294
|
+
|
295
|
+
@click.command()
|
296
|
+
@click.argument('report_id')
|
297
|
+
@click.option('--plot', '-p', is_flag=True, help='Plot the report.')
|
298
|
+
@log_options
|
299
|
+
@command_option('reproduce')
|
300
|
+
def reproduce(report_id, code, data, api, plot):
|
301
|
+
"""
|
302
|
+
Reproduce a report.
|
303
|
+
|
304
|
+
If `--plot` is set, plot the report.
|
305
|
+
If `--api` is set, use the api to get and update the config table.
|
306
|
+
If `--code` is not set, use the current working directory.
|
307
|
+
If `--data` is not set, use the `logs` directory in the code path.
|
308
|
+
"""
|
309
|
+
logger.info(
|
310
|
+
f'[CMD]: reproduce {report_id} --code {code} --data {data} --api {api}'
|
311
|
+
f'{" --plot" if plot else ""}')
|
312
|
+
if api is not None:
|
313
|
+
api = importlib.import_module(api)
|
314
|
+
set_config_api(api.query_config, api.update_config, api.export_config)
|
315
|
+
if code is None:
|
316
|
+
code = Path.cwd()
|
317
|
+
if data is None:
|
318
|
+
data = Path(code) / 'logs'
|
319
|
+
|
320
|
+
code = Path(os.path.expanduser(code))
|
321
|
+
data = Path(os.path.expanduser(data))
|
322
|
+
|
323
|
+
from .load import load_workflow_from_source_code
|
324
|
+
from .storage import get_report_by_index
|
325
|
+
|
326
|
+
r = get_report_by_index(int(report_id), data)
|
327
|
+
|
328
|
+
wf = load_workflow_from_source_code(r.workflow, r.script)
|
329
|
+
run_workflow(wf, code, data, plot=plot, freeze=True)
|
qulab/executor/load.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import graphlib
|
2
2
|
import inspect
|
3
3
|
import pickle
|
4
|
+
import sys
|
4
5
|
import warnings
|
5
6
|
from importlib.util import module_from_spec, spec_from_file_location
|
6
7
|
from pathlib import Path
|
@@ -329,6 +330,34 @@ def load_workflow_from_file(file_name: str,
|
|
329
330
|
return module
|
330
331
|
|
331
332
|
|
333
|
+
def load_workflow_from_source_code(workflow_id: str,
|
334
|
+
source_code: str,
|
335
|
+
package='workflows') -> WorkflowType:
|
336
|
+
path = Path(workflow_id)
|
337
|
+
module_name = f"{package}.{'.'.join([*path.parts[:-1], path.stem])}"
|
338
|
+
|
339
|
+
# 创建一个新的模块对象
|
340
|
+
module = ModuleType(module_name)
|
341
|
+
# 将模块注册到sys.modules中
|
342
|
+
sys.modules[module_name] = module
|
343
|
+
# 将源代码编译成字节码
|
344
|
+
code = compile(source_code, '<string>', 'exec')
|
345
|
+
# 在模块的命名空间中执行字节码
|
346
|
+
exec(code, module.__dict__)
|
347
|
+
|
348
|
+
module.__source__ = source_code
|
349
|
+
module.__mtime__ = 0
|
350
|
+
module.__workflow_id__ = workflow_id
|
351
|
+
|
352
|
+
if not hasattr(module, '__timeout__'):
|
353
|
+
module.__timeout__ = None
|
354
|
+
|
355
|
+
if not hasattr(module, 'depends'):
|
356
|
+
module.depends = lambda: []
|
357
|
+
|
358
|
+
return module
|
359
|
+
|
360
|
+
|
332
361
|
def _generate_target_file_path(template_path: str | Path, hash_str: str,
|
333
362
|
content: str, base_path: str | Path) -> Path:
|
334
363
|
path = Path(template_path)
|
@@ -341,7 +370,7 @@ def _generate_target_file_path(template_path: str | Path, hash_str: str,
|
|
341
370
|
path = path.parent / f'{path.stem}_tmp{hash_str}.py'
|
342
371
|
|
343
372
|
if 'templates' in path.parts:
|
344
|
-
|
373
|
+
return Path(*['run' if p == 'templates' else p for p in path.parts])
|
345
374
|
else:
|
346
375
|
return Path('run') / path
|
347
376
|
|
qulab/fun.cpython-311-darwin.so
CHANGED
Binary file
|
qulab/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "2.9.
|
1
|
+
__version__ = "2.9.6"
|
@@ -1,16 +1,16 @@
|
|
1
1
|
qulab/__init__.py,sha256=JZ3bn_kTVlnY-P8JXQ5xEdViieFXqfxX8ReLuiiXIpo,321
|
2
2
|
qulab/__main__.py,sha256=fjaRSL_uUjNIzBGNgjlGswb9TJ2VD5qnkZHW3hItrD4,68
|
3
3
|
qulab/dicttree.py,sha256=tRRMpGZYVOLw0TEByE3_2Ss8FdOmzuGL9e1DWbs8qoY,13684
|
4
|
-
qulab/fun.cpython-311-darwin.so,sha256=
|
4
|
+
qulab/fun.cpython-311-darwin.so,sha256=CzWrA4sqB0mgHXeLvvNru0O2zjSiKoL9WfOBCQeyO8g,126848
|
5
5
|
qulab/typing.py,sha256=vg62sGqxuD9CI5677ejlzAmf2fVdAESZCQjAE_xSxPg,69
|
6
6
|
qulab/utils.py,sha256=BdLdlfjpe6m6gSeONYmpAKTTqxDaYHNk4exlz8kZxTg,2982
|
7
|
-
qulab/version.py,sha256=
|
7
|
+
qulab/version.py,sha256=xbldOz0XM3Jg2OQP4pA5dIy-zqYfu1fHZ9muPBbegtA,21
|
8
8
|
qulab/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
qulab/cli/commands.py,sha256=
|
9
|
+
qulab/cli/commands.py,sha256=F1LATmSC9lOAdnrOTMK7DRjETCEcOmMsocovWRyjWTc,597
|
10
10
|
qulab/cli/config.py,sha256=Ei7eSYnbwPPlluDnm8YmWONYiI4g7WtvlZGQdr1Z6vo,3688
|
11
11
|
qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
|
12
|
-
qulab/executor/cli.py,sha256=
|
13
|
-
qulab/executor/load.py,sha256=
|
12
|
+
qulab/executor/cli.py,sha256=OXFmCo2loOCgUYXZpvJz5AnzDag5m_iPetsFM1J11uQ,11291
|
13
|
+
qulab/executor/load.py,sha256=qI-3b3xvsjZMCthRO3hlzHA0BZI-tH9Y_L0XLBcyWV8,18657
|
14
14
|
qulab/executor/schedule.py,sha256=XRimchHYCgnMAOtCvNLjwMv9IkcTAyBAUCHKQs5RBRw,18745
|
15
15
|
qulab/executor/storage.py,sha256=PWQIDYjQaoyLGgAKh0X1tlNQTgDWR8bI-HVie4hSkyA,21075
|
16
16
|
qulab/executor/template.py,sha256=_HEtsUQ5_jSujCw8FBDAK1PRTMRCa4iD4DduHIpjo3c,10569
|
@@ -97,9 +97,9 @@ qulab/visualization/plot_seq.py,sha256=UWTS6p9nfX_7B8ehcYo6UnSTUCjkBsNU9jiOeW2ca
|
|
97
97
|
qulab/visualization/qdat.py,sha256=ZeevBYWkzbww4xZnsjHhw7wRorJCBzbG0iEu-XQB4EA,5735
|
98
98
|
qulab/visualization/rot3d.py,sha256=lMrEJlRLwYe6NMBlGkKYpp_V9CTipOAuDy6QW_cQK00,734
|
99
99
|
qulab/visualization/widgets.py,sha256=6KkiTyQ8J-ei70LbPQZAK35wjktY47w2IveOa682ftA,3180
|
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.6.dist-info/licenses/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
|
101
|
+
qulab-2.9.6.dist-info/METADATA,sha256=EUA0I36KYGMd3X8yTwXUgOFsCvO4bQx5gZyKnsqfjcU,3720
|
102
|
+
qulab-2.9.6.dist-info/WHEEL,sha256=RbtvOFtP--plS2sXkxxM8xYfkibPkCKcYIqEe_GHrhY,114
|
103
|
+
qulab-2.9.6.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
|
104
|
+
qulab-2.9.6.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
|
105
|
+
qulab-2.9.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|