QuLab 2.9.5__cp310-cp310-win_amd64.whl → 2.9.6__cp310-cp310-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/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)
Binary file
qulab/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.9.5"
1
+ __version__ = "2.9.6"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QuLab
3
- Version: 2.9.5
3
+ Version: 2.9.6
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,16 +1,16 @@
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.cp310-win_amd64.pyd,sha256=eQKq16P3tebV-jumN1lABscQTGOqiiuFsU1qCDbiENg,31744
4
+ qulab/fun.cp310-win_amd64.pyd,sha256=kbesHtsqKxAox7RlPvx3pRQolQ2yzH4G1MPl_VmCYiM,31744
5
5
  qulab/typing.py,sha256=PRtwbCHWY2ROKK8GHq4Bo8llXrIGo6xC73DrQf7S9os,71
6
6
  qulab/utils.py,sha256=65N2Xj7kqRsQ4epoLNY6tL-i5ts6Wk8YuJYee3Te6zI,3077
7
- qulab/version.py,sha256=w1TrLnI1WG1RnKU5vN73-FD1f7CJlGfGd4-SplmrIUE,21
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=6xd2eYw32k1NmfAuYSu__1kaP12Oz1QVqwbkYXdWno4,588
9
+ qulab/cli/commands.py,sha256=ZTs32yQjvwPIsFjXYWNr4KqEvly0NISIqyh--96qCAY,627
10
10
  qulab/cli/config.py,sha256=7h3k0K8FYHhI6LVWt8BoDdKrX2ApFDBAUAUuXhHwst4,3799
11
11
  qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
12
- qulab/executor/cli.py,sha256=8d-8bRWZ5lmsMtjASsl1zu1rV-syeAESMNVthvIQxlo,10018
13
- qulab/executor/load.py,sha256=GBd0FZHO7kLvwzcXAnChStgeaMKJBNVjUi_Yh43PABA,17736
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=dKQM3IlADdTi9qp0fnOYjyycRNEl7KeSCBZhwbmP8bQ,10828
@@ -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.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=xtqxYTqke_XhXNhgwydvlroVayIzBVjJDMBpIgge99s,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,,
100
+ qulab-2.9.6.dist-info/licenses/LICENSE,sha256=b4NRQ-GFVpJMT7RuExW3NwhfbrYsX7AcdB7Gudok-fs,1086
101
+ qulab-2.9.6.dist-info/METADATA,sha256=Gg72JEDnJ23sN2HwHTxkQUaH7Hfk2tz5SFvDn-WTthQ,3826
102
+ qulab-2.9.6.dist-info/WHEEL,sha256=xtqxYTqke_XhXNhgwydvlroVayIzBVjJDMBpIgge99s,101
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