QuLab 2.4.9__tar.gz → 2.4.10__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.
Files changed (108) hide show
  1. {qulab-2.4.9 → qulab-2.4.10}/PKG-INFO +1 -1
  2. {qulab-2.4.9 → qulab-2.4.10}/QuLab.egg-info/PKG-INFO +1 -1
  3. qulab-2.4.10/qulab/executor/__main__.py +132 -0
  4. {qulab-2.4.9 → qulab-2.4.10}/qulab/executor/load.py +1 -1
  5. {qulab-2.4.9 → qulab-2.4.10}/qulab/executor/schedule.py +19 -4
  6. qulab-2.4.10/qulab/version.py +1 -0
  7. qulab-2.4.9/qulab/executor/__main__.py +0 -92
  8. qulab-2.4.9/qulab/version.py +0 -1
  9. {qulab-2.4.9 → qulab-2.4.10}/LICENSE +0 -0
  10. {qulab-2.4.9 → qulab-2.4.10}/MANIFEST.in +0 -0
  11. {qulab-2.4.9 → qulab-2.4.10}/QuLab.egg-info/SOURCES.txt +0 -0
  12. {qulab-2.4.9 → qulab-2.4.10}/QuLab.egg-info/dependency_links.txt +0 -0
  13. {qulab-2.4.9 → qulab-2.4.10}/QuLab.egg-info/entry_points.txt +0 -0
  14. {qulab-2.4.9 → qulab-2.4.10}/QuLab.egg-info/requires.txt +0 -0
  15. {qulab-2.4.9 → qulab-2.4.10}/QuLab.egg-info/top_level.txt +0 -0
  16. {qulab-2.4.9 → qulab-2.4.10}/README.md +0 -0
  17. {qulab-2.4.9 → qulab-2.4.10}/pyproject.toml +0 -0
  18. {qulab-2.4.9 → qulab-2.4.10}/qulab/__init__.py +0 -0
  19. {qulab-2.4.9 → qulab-2.4.10}/qulab/__main__.py +0 -0
  20. {qulab-2.4.9 → qulab-2.4.10}/qulab/dicttree.py +0 -0
  21. {qulab-2.4.9 → qulab-2.4.10}/qulab/executor/__init__.py +0 -0
  22. {qulab-2.4.9 → qulab-2.4.10}/qulab/executor/storage.py +0 -0
  23. {qulab-2.4.9 → qulab-2.4.10}/qulab/executor/transform.py +0 -0
  24. {qulab-2.4.9 → qulab-2.4.10}/qulab/executor/utils.py +0 -0
  25. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/__init__.py +0 -0
  26. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/__main__.py +0 -0
  27. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/config.py +0 -0
  28. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/dataset.py +0 -0
  29. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/event_queue.py +0 -0
  30. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/mainwindow.py +0 -0
  31. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/monitor.py +0 -0
  32. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/ploter.py +0 -0
  33. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/qt_compat.py +0 -0
  34. {qulab-2.4.9 → qulab-2.4.10}/qulab/monitor/toolbar.py +0 -0
  35. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/__init__.py +0 -0
  36. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/curd.py +0 -0
  37. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/expression.py +0 -0
  38. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/models.py +0 -0
  39. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/optimize.py +0 -0
  40. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/query.py +0 -0
  41. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/record.py +0 -0
  42. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/scan.py +0 -0
  43. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/server.py +0 -0
  44. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/space.py +0 -0
  45. {qulab-2.4.9 → qulab-2.4.10}/qulab/scan/utils.py +0 -0
  46. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/__init__.py +0 -0
  47. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/__main__.py +0 -0
  48. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/backend/__init__.py +0 -0
  49. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/backend/redis.py +0 -0
  50. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/base_dataset.py +0 -0
  51. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/chunk.py +0 -0
  52. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/dataset.py +0 -0
  53. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/file.py +0 -0
  54. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/__init__.py +0 -0
  55. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/base.py +0 -0
  56. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/config.py +0 -0
  57. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/file.py +0 -0
  58. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/ipy.py +0 -0
  59. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/models.py +0 -0
  60. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/record.py +0 -0
  61. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/report.py +0 -0
  62. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/models/tag.py +0 -0
  63. {qulab-2.4.9 → qulab-2.4.10}/qulab/storage/storage.py +0 -0
  64. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/__init__.py +0 -0
  65. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/chat.py +0 -0
  66. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/device/__init__.py +0 -0
  67. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/device/basedevice.py +0 -0
  68. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/device/loader.py +0 -0
  69. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/device/utils.py +0 -0
  70. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/drivers/FakeInstrument.py +0 -0
  71. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/drivers/__init__.py +0 -0
  72. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/ipy_events.py +0 -0
  73. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/net/__init__.py +0 -0
  74. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/net/bencoder.py +0 -0
  75. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/net/cli.py +0 -0
  76. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/net/dhcp.py +0 -0
  77. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/net/dhcpd.py +0 -0
  78. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/net/kad.py +0 -0
  79. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/net/kcp.py +0 -0
  80. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/net/nginx.py +0 -0
  81. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/progress.py +0 -0
  82. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/__init__.py +0 -0
  83. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/client.py +0 -0
  84. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/exceptions.py +0 -0
  85. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/msgpack.py +0 -0
  86. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/msgpack.pyi +0 -0
  87. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/router.py +0 -0
  88. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/rpc.py +0 -0
  89. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/serialize.py +0 -0
  90. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/server.py +0 -0
  91. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/socket.py +0 -0
  92. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/utils.py +0 -0
  93. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/worker.py +0 -0
  94. {qulab-2.4.9 → qulab-2.4.10}/qulab/sys/rpc/zmq_socket.py +0 -0
  95. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/__init__.py +0 -0
  96. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/__main__.py +0 -0
  97. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/_autoplot.py +0 -0
  98. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/plot_circ.py +0 -0
  99. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/plot_layout.py +0 -0
  100. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/plot_seq.py +0 -0
  101. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/qdat.py +0 -0
  102. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/rot3d.py +0 -0
  103. {qulab-2.4.9 → qulab-2.4.10}/qulab/visualization/widgets.py +0 -0
  104. {qulab-2.4.9 → qulab-2.4.10}/setup.cfg +0 -0
  105. {qulab-2.4.9 → qulab-2.4.10}/setup.py +0 -0
  106. {qulab-2.4.9 → qulab-2.4.10}/src/qulab.h +0 -0
  107. {qulab-2.4.9 → qulab-2.4.10}/tests/test_kad.py +0 -0
  108. {qulab-2.4.9 → qulab-2.4.10}/tests/test_scan.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: QuLab
3
- Version: 2.4.9
3
+ Version: 2.4.10
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,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: QuLab
3
- Version: 2.4.9
3
+ Version: 2.4.10
4
4
  Summary: contral instruments and manage data
5
5
  Author-email: feihoo87 <feihoo87@gmail.com>
6
6
  Maintainer-email: feihoo87 <feihoo87@gmail.com>
@@ -0,0 +1,132 @@
1
+ import functools
2
+ import importlib
3
+ import sys, os
4
+ from pathlib import Path
5
+
6
+ import click
7
+ from loguru import logger
8
+
9
+ from .load import find_unreferenced_workflows
10
+ from .schedule import maintain as maintain_workflow
11
+ from .schedule import run as run_workflow
12
+ from .transform import set_config_api
13
+ from .utils import workflow_template
14
+
15
+
16
+ def log_options(func):
17
+
18
+ @click.option("--debug", is_flag=True, help="Enable debug mode.")
19
+ @click.option("--log", type=str, help="Log file path.")
20
+ @functools.wraps(func) # 保持函数元信息
21
+ def wrapper(*args, log=None, debug=False, **kwargs):
22
+ print(f"{func} {log=}, {debug=}")
23
+ if log is None and not debug:
24
+ logger.remove()
25
+ logger.add(sys.stderr, level='INFO')
26
+ elif log is None and debug:
27
+ logger.remove()
28
+ logger.add(sys.stderr, level='DEBUG')
29
+ elif log is not None and not debug:
30
+ logger.configure(handlers=[dict(sink=log, level='INFO')])
31
+ elif log is not None and debug:
32
+ logger.configure(handlers=[
33
+ dict(sink=log, level='DEBUG'),
34
+ dict(sink=sys.stderr, level='DEBUG')
35
+ ])
36
+ return func(*args, **kwargs)
37
+
38
+ return wrapper
39
+
40
+
41
+ @click.group()
42
+ def cli():
43
+ pass
44
+
45
+
46
+ @click.command()
47
+ @click.argument('workflow')
48
+ @click.option('--code', '-c', default=None, help='The path of the code.')
49
+ def create(workflow, code):
50
+ """
51
+ Create a new workflow file.
52
+ """
53
+ if code is None:
54
+ code = Path.cwd()
55
+
56
+ fname = Path(code) / f'{workflow}'
57
+ fname = Path(os.path.expanduser(fname))
58
+ if fname.exists():
59
+ click.echo(f'{workflow} already exists')
60
+ return
61
+
62
+ fname.parent.mkdir(parents=True, exist_ok=True)
63
+ deps = find_unreferenced_workflows(code)
64
+
65
+ with open(fname, 'w') as f:
66
+ f.write(workflow_template(list(deps)))
67
+ click.echo(f'{workflow} created')
68
+
69
+
70
+ @click.command()
71
+ @click.argument('workflow')
72
+ @click.option('--code', '-c', default=None, help='The path of the code.')
73
+ @click.option('--data', '-d', default=None, help='The path of the data.')
74
+ @click.option('--api', '-a', default=None, help='The modlule name of the api.')
75
+ @click.option('--plot', '-p', is_flag=True, help='Plot the result.')
76
+ @click.option('--no-dependents',
77
+ '-n',
78
+ is_flag=True,
79
+ help='Do not run dependents.')
80
+ @log_options
81
+ def run(workflow, code, data, api, plot, no_dependents):
82
+ """
83
+ Run a workflow.
84
+ """
85
+ if api is not None:
86
+ api = importlib.import_module(api)
87
+ set_config_api(api.query_config, api.update_config)
88
+ if code is None:
89
+ code = Path.cwd()
90
+ if data is None:
91
+ data = Path(code) / 'logs'
92
+
93
+ code = Path(os.path.expanduser(code))
94
+ data = Path(os.path.expanduser(data))
95
+
96
+ if no_dependents:
97
+ run_workflow(workflow, code, data, plot=plot)
98
+ else:
99
+ maintain_workflow(workflow, code, data, run=True, plot=plot)
100
+
101
+
102
+ @click.command()
103
+ @click.argument('workflow')
104
+ @click.option('--code', '-c', default=None, help='The path of the code.')
105
+ @click.option('--data', '-d', default=None, help='The path of the data.')
106
+ @click.option('--api', '-a', default=None, help='The modlule name of the api.')
107
+ @click.option('--plot', '-p', is_flag=True, help='Plot the result.')
108
+ @log_options
109
+ def maintain(workflow, code, data, api, plot):
110
+ """
111
+ Maintain a workflow.
112
+ """
113
+ if api is not None:
114
+ api = importlib.import_module(api)
115
+ set_config_api(api.query_config, api.update_config)
116
+ if code is None:
117
+ code = Path.cwd()
118
+ if data is None:
119
+ data = Path(code) / 'logs'
120
+
121
+ code = Path(os.path.expanduser(code))
122
+ data = Path(os.path.expanduser(data))
123
+
124
+ maintain_workflow(workflow, code, data, run=False, plot=plot)
125
+
126
+
127
+ cli.add_command(maintain)
128
+ cli.add_command(run)
129
+ cli.add_command(create)
130
+
131
+ if __name__ == '__main__':
132
+ cli()
@@ -150,7 +150,7 @@ def find_unreferenced_workflows(path: str) -> list[str]:
150
150
  )
151
151
  continue
152
152
  try:
153
- depends_list = depends_func()
153
+ depends_list = depends_func()[0]
154
154
  except Exception as e:
155
155
  warnings.warn(f"Error calling depends() in {rel_str}: {e}")
156
156
  continue
@@ -172,15 +172,29 @@ def diagnose(node, code_path: str | Path, state_path: str | Path, plot: bool,
172
172
  # bad data case
173
173
  recalibrated = []
174
174
  if result.bad_data:
175
+ logger.debug(f'"{node}": Bad data, diagnosing dependents')
175
176
  recalibrated = [
176
177
  diagnose(n, code_path, state_path, plot, session_id)
177
178
  for n in get_dependents(node, code_path)
178
179
  ]
179
- if not any(recalibrated) and recalibrated:
180
+ if not any(recalibrated):
181
+ if result.bad_data:
182
+ raise CalibrationFailedError(
183
+ f'"{node}": bad data but no dependents recalibrated.')
180
184
  logger.debug(f'"{node}": no dependents recalibrated.')
181
- return False
182
185
  # calibrate
183
- logger.debug(f'recalibrate "{node}" because some dependents recalibrated')
186
+ if any(recalibrated):
187
+ logger.debug(
188
+ f'recalibrate "{node}" because some dependents recalibrated.')
189
+ elif not result.in_spec and not result.bad_data:
190
+ logger.debug(f'recalibrate "{node}" because out of spec.')
191
+ elif result.in_spec:
192
+ logger.error(f'Never reach: recalibrate "{node}" because in spec.')
193
+ elif result.bad_data:
194
+ logger.error(f'Never reach: recalibrate "{node}" because bad data.')
195
+ else:
196
+ logger.error(f'Never reach: recalibrate "{node}"')
197
+
184
198
  result = calibrate(node, code_path, state_path, plot, session_id)
185
199
  if result.bad_data or not result.in_spec:
186
200
  raise CalibrationFailedError(
@@ -193,7 +207,7 @@ def get_dependents(workflow: str, code_path: str | Path) -> list[str]:
193
207
  return [n for n in load_workflow(workflow, code_path).depends()[0]]
194
208
 
195
209
 
196
- #@logger.catch(reraise=True)
210
+ @logger.catch(reraise=True)
197
211
  def maintain(node,
198
212
  code_path: str | Path,
199
213
  state_path: str | Path,
@@ -236,6 +250,7 @@ def maintain(node,
236
250
  return
237
251
 
238
252
 
253
+ @logger.catch(reraise=True)
239
254
  def run(node,
240
255
  code_path: str | Path,
241
256
  state_path: str | Path,
@@ -0,0 +1 @@
1
+ __version__ = "2.4.10"
@@ -1,92 +0,0 @@
1
- import importlib
2
- from pathlib import Path
3
-
4
- import click
5
-
6
- from .load import find_unreferenced_workflows
7
- from .schedule import maintain as maintain_workflow
8
- from .schedule import run as run_workflow
9
- from .transform import set_config_api
10
- from .utils import workflow_template
11
-
12
-
13
- @click.group()
14
- def cli():
15
- pass
16
-
17
-
18
- @click.command()
19
- @click.argument('workflow')
20
- @click.option('--code', '-c', default=None)
21
- def create(workflow, code):
22
- """
23
- Create a new workflow file.
24
- """
25
- if code is None:
26
- code = Path.cwd()
27
-
28
- fname = Path(code) / f'{workflow}'
29
- if fname.exists():
30
- click.echo(f'{workflow} already exists')
31
- return
32
-
33
- fname.parent.mkdir(parents=True, exist_ok=True)
34
- deps = find_unreferenced_workflows(code)
35
-
36
- with open(fname, 'w') as f:
37
- f.write(workflow_template(list(deps)))
38
- click.echo(f'{workflow} created')
39
-
40
-
41
- @click.command()
42
- @click.argument('workflow')
43
- @click.option('--code', '-c', default=None)
44
- @click.option('--data', '-d', default=None)
45
- @click.option('--api', '-a', default=None)
46
- @click.option('--plot', '-p', is_flag=True)
47
- @click.option('--no-dependents', '-n', is_flag=True)
48
- def run(workflow, code, data, api, plot, no_dependents):
49
- """
50
- Run a workflow.
51
- """
52
- if api is not None:
53
- api = importlib.import_module(api)
54
- set_config_api(api.query_config, api.update_config)
55
- if code is None:
56
- code = Path.cwd()
57
- if data is None:
58
- data = Path(code) / 'logs'
59
-
60
- if no_dependents:
61
- run_workflow(workflow, code, data, plot=plot)
62
- else:
63
- maintain_workflow(workflow, code, data, run=True, plot=plot)
64
-
65
-
66
- @click.command()
67
- @click.argument('workflow')
68
- @click.option('--code', '-c', default=None)
69
- @click.option('--data', '-d', default=None)
70
- @click.option('--api', '-a', default=None)
71
- @click.option('--plot', '-p', is_flag=True)
72
- def maintain(workflow, code, data, api, plot):
73
- """
74
- Maintain a workflow.
75
- """
76
- if api is not None:
77
- api = importlib.import_module(api)
78
- set_config_api(api.query_config, api.update_config)
79
- if code is None:
80
- code = Path.cwd()
81
- if data is None:
82
- data = Path(code) / 'logs'
83
-
84
- maintain_workflow(workflow, code, data, run=False, plot=plot)
85
-
86
-
87
- cli.add_command(maintain)
88
- cli.add_command(run)
89
- cli.add_command(create)
90
-
91
- if __name__ == '__main__':
92
- cli()
@@ -1 +0,0 @@
1
- __version__ = "2.4.9"
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