QuLab 2.10.3__cp312-cp312-win_amd64.whl → 2.10.5__cp312-cp312-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/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from .executor.analyze import manual_analysis
2
+ from .executor.registry import Registry
2
3
  from .executor.storage import find_report
3
4
  from .executor.storage import get_report_by_index as get_report
4
5
  from .executor.template import VAR
qulab/cli/decorators.py CHANGED
@@ -22,7 +22,7 @@ def run(main, *args, **kwds):
22
22
  try:
23
23
  import uvloop
24
24
  uvloop.run(main(*args, **kwds))
25
- except ImportError:
25
+ except (ImportError, ModuleNotFoundError):
26
26
  asyncio.run(main(*args, **kwds))
27
27
  else:
28
28
  main(*args, **kwds)
qulab/executor/cli.py CHANGED
@@ -12,10 +12,10 @@ from ..cli.config import get_config_value, log_options
12
12
  from ..cli.decorators import async_command
13
13
  from .load import (WorkflowType, find_unreferenced_workflows, get_entries,
14
14
  load_workflow, make_graph)
15
+ from .registry import Registry, set_config_api
15
16
  from .schedule import CalibrationFailedError
16
17
  from .schedule import maintain as maintain_workflow
17
18
  from .schedule import run as run_workflow
18
- from .transform import set_config_api
19
19
  from .utils import workflow_template
20
20
 
21
21
 
@@ -95,6 +95,7 @@ def command_option(command_name):
95
95
  '-c',
96
96
  default=lambda: get_config_value("code", str, 'create'),
97
97
  help='The path of the code.')
98
+ @log_options('create')
98
99
  def create(workflow, code):
99
100
  """
100
101
  Create a new workflow file.
@@ -124,12 +125,13 @@ def create(workflow, code):
124
125
  '-a',
125
126
  default=lambda: get_config_value("api", str, 'set'),
126
127
  help='The modlule name of the api.')
128
+ @log_options('set')
127
129
  def set(key, value, api):
128
130
  """
129
131
  Set a config.
130
132
  """
131
133
  logger.info(f'[CMD]: set {key} {value} --api {api}')
132
- from . import transform
134
+ reg = Registry()
133
135
  if api is not None:
134
136
  api = importlib.import_module(api)
135
137
  set_config_api(api.query_config, api.update_config, api.delete_config,
@@ -138,7 +140,7 @@ def set(key, value, api):
138
140
  value = eval(value)
139
141
  except:
140
142
  pass
141
- transform.update_config({key: value})
143
+ reg.set(key, value)
142
144
 
143
145
 
144
146
  @click.command()
@@ -147,17 +149,18 @@ def set(key, value, api):
147
149
  '-a',
148
150
  default=lambda: get_config_value("api", str, 'get'),
149
151
  help='The modlule name of the api.')
152
+ @log_options('get')
150
153
  def get(key, api):
151
154
  """
152
155
  Get a config.
153
156
  """
154
157
  logger.info(f'[CMD]: get {key} --api {api}')
155
- from . import transform
158
+ reg = Registry()
156
159
  if api is not None:
157
160
  api = importlib.import_module(api)
158
161
  set_config_api(api.query_config, api.update_config, api.delete_config,
159
162
  api.export_config, api.clear_config)
160
- click.echo(transform.query_config(key))
163
+ click.echo(reg.get(key))
161
164
 
162
165
 
163
166
  @click.command()
@@ -176,7 +179,7 @@ def get(key, api):
176
179
  @click.option('--veryfy-source-code',
177
180
  is_flag=True,
178
181
  help='Veryfy the source code.')
179
- @log_options
182
+ @log_options('run')
180
183
  @command_option('run')
181
184
  @async_command
182
185
  async def run(workflow,
@@ -236,7 +239,6 @@ async def run(workflow,
236
239
  data,
237
240
  plot=plot,
238
241
  freeze=freeze,
239
- veryfy_source_code=veryfy_source_code,
240
242
  )
241
243
  except Exception as e:
242
244
  if fail_fast:
@@ -251,7 +253,6 @@ async def run(workflow,
251
253
  data,
252
254
  plot=plot,
253
255
  freeze=freeze,
254
- veryfy_source_code=veryfy_source_code,
255
256
  )
256
257
  else:
257
258
  if hasattr(wf, 'entries'):
@@ -305,7 +306,7 @@ async def run(workflow,
305
306
  @click.option('--veryfy-source-code',
306
307
  is_flag=True,
307
308
  help='Veryfy the source code.')
308
- @log_options
309
+ @log_options('maintain')
309
310
  @command_option('maintain')
310
311
  @async_command
311
312
  async def maintain(workflow,
@@ -390,7 +391,7 @@ async def maintain(workflow,
390
391
  @click.command()
391
392
  @click.argument('report_id')
392
393
  @click.option('--plot', '-p', is_flag=True, help='Plot the report.')
393
- @log_options
394
+ @log_options('reproduce')
394
395
  @command_option('reproduce')
395
396
  @async_command
396
397
  async def reproduce(report_id, code, data, api, plot):
@@ -417,16 +418,17 @@ async def reproduce(report_id, code, data, api, plot):
417
418
  code = Path(os.path.expanduser(code))
418
419
  data = Path(os.path.expanduser(data))
419
420
 
420
- from . import transform
421
421
  from .load import load_workflow_from_source_code
422
422
  from .storage import get_report_by_index
423
423
 
424
+ reg = Registry()
425
+
424
426
  r = get_report_by_index(int(report_id), data)
425
427
 
426
428
  wf = load_workflow_from_source_code(r.workflow, r.script)
427
- cfg = transform.export_config()
428
- transform.clear_config()
429
- transform.update_config(r.config)
429
+ cfg = reg.export()
430
+ reg.clear()
431
+ reg.update(r.config)
430
432
  await run_workflow(wf, code, data, plot=plot, freeze=True)
431
- transform.clear_config()
432
- transform.update_config(cfg)
433
+ reg.clear()
434
+ reg.update(cfg)
@@ -1,3 +1,9 @@
1
+ import importlib
2
+ import os
3
+ import sys
4
+ from typing import Any
5
+
6
+ from ..cli.config import get_config_value
1
7
  from .storage import Report, save_item
2
8
 
3
9
  __current_config_id = None
@@ -132,3 +138,44 @@ def set_config_api(query_method,
132
138
  clear_config = clear_method
133
139
 
134
140
  return query_config, update_config, delete_config, export_config, clear_config
141
+
142
+
143
+ def _init():
144
+ code = get_config_value("code", str, default=None)
145
+ if code is not None:
146
+ code = os.path.expanduser(code)
147
+ if code not in sys.path:
148
+ sys.path.insert(0, code)
149
+
150
+ api = get_config_value('api', str, None)
151
+ if api is not None:
152
+ api = importlib.import_module(api)
153
+ set_config_api(api.query_config, api.update_config, api.delete_config,
154
+ api.export_config, api.clear_config)
155
+
156
+
157
+ _init()
158
+
159
+
160
+ class Registry():
161
+
162
+ def query(self, key: str) -> Any:
163
+ return query_config(key)
164
+
165
+ def get(self, key: str) -> Any:
166
+ return self.query(key)
167
+
168
+ def export(self) -> dict[str, dict[str, Any]]:
169
+ return export_config()
170
+
171
+ def set(self, key: str, value: Any):
172
+ return update_config({key: value})
173
+
174
+ def delete(self, key: str):
175
+ return delete_config(key)
176
+
177
+ def clear(self):
178
+ return clear_config()
179
+
180
+ def update(self, parameters: dict[str, Any]):
181
+ return update_config(parameters)
@@ -8,9 +8,9 @@ from pathlib import Path
8
8
  from loguru import logger
9
9
 
10
10
  from .load import WorkflowType, get_dependents
11
+ from .registry import current_config, obey_the_oracle, update_parameters
11
12
  from .storage import (Report, find_report, get_head, get_heads, renew_report,
12
13
  revoke_report, save_item, save_report)
13
- from .transform import current_config, obey_the_oracle, update_parameters
14
14
 
15
15
  __session_id = None
16
16
  __session_cache = {}
Binary file
qulab/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.10.3"
1
+ __version__ = "2.10.5"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QuLab
3
- Version: 2.10.3
3
+ Version: 2.10.5
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,22 +1,22 @@
1
- qulab/__init__.py,sha256=ulapyzt9DsDgT68EEbzuhniofHb512pNTFc-Sxfrr8Y,375
1
+ qulab/__init__.py,sha256=-tTI2n3lAFU3sRFEu-Z_ihgiHbyyaQeuLDWfLFHlPvc,416
2
2
  qulab/__main__.py,sha256=FL4YsGZL1jEtmcPc5WbleArzhOHLMsWl7OH3O-1d1ss,72
3
3
  qulab/dicttree.py,sha256=ZoSJVWK4VMqfzj42gPb_n5RqLlM6K1Me0WmLIfLEYf8,14195
4
- qulab/fun.cp312-win_amd64.pyd,sha256=iEgqMzxZAoOtwAFLdeIk4Fg7fy9CzlhHAZ2tTNLd7A0,32256
4
+ qulab/fun.cp312-win_amd64.pyd,sha256=2fm-wGsPEcgNyBgItE2QkDhDWm-_GgcT8Y_rvuKjiTA,32256
5
5
  qulab/typing.py,sha256=PRtwbCHWY2ROKK8GHq4Bo8llXrIGo6xC73DrQf7S9os,71
6
6
  qulab/utils.py,sha256=65N2Xj7kqRsQ4epoLNY6tL-i5ts6Wk8YuJYee3Te6zI,3077
7
- qulab/version.py,sha256=XIYhk5PoReQgD4uSOa1eXmCSwNRY66HHGSW3_z-nibk,22
7
+ qulab/version.py,sha256=SB3sQYH0e-iHrGpjw5MXxU2T-sxkpouM4O_fyPlJPXQ,22
8
8
  qulab/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  qulab/cli/commands.py,sha256=ZTs32yQjvwPIsFjXYWNr4KqEvly0NISIqyh--96qCAY,627
10
10
  qulab/cli/config.py,sha256=A3UnyaRtiofpokyzYkJnUdwzcsYX7H-xZvBVduIOSdg,5617
11
- qulab/cli/decorators.py,sha256=UmJab1o-XH-8DVS_LZFGY2SPjyVgZ1QrJwkauTZDUik,626
11
+ qulab/cli/decorators.py,sha256=mgAZiiaj2vZvsJEg70gxgB9TWkxR1nQSb2m-73RYHr0,649
12
12
  qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
13
13
  qulab/executor/analyze.py,sha256=VoSthE2RTarY6Wj3QFKh4FqReMYL7djSAyuitgHs5K0,5837
14
- qulab/executor/cli.py,sha256=ylsKlr1qiloTVPhF2xoTxbz5DD98VQkRXQpvmiVJdxY,15047
14
+ qulab/executor/cli.py,sha256=bmuFPpPhHiRzTjIjhvlp2tQYp0jEwXSETILX8Nu2tLE,14901
15
15
  qulab/executor/load.py,sha256=0-EtO4dkP6jB1vsgQlniv-OtPH1AZLjbtuvaWHsgbPs,20335
16
- qulab/executor/schedule.py,sha256=1YWz2d5YLmnEpXGX1aVroE0SOKdU28WwHGEioxBpTKQ,21411
16
+ qulab/executor/registry.py,sha256=qqj90HVYun-DDI9HPmwyOQI87M2mQ0jyw4vWwPMfYjg,4592
17
+ qulab/executor/schedule.py,sha256=7gAJFwj13j1niGjVa1fSzwOS22eNFEN1hdrN3dfTY6A,21410
17
18
  qulab/executor/storage.py,sha256=8K73KGLAVgchJdtd4rKHXkr1CQOJORWH-Gi57w8IYsw,21081
18
19
  qulab/executor/template.py,sha256=dKQM3IlADdTi9qp0fnOYjyycRNEl7KeSCBZhwbmP8bQ,10828
19
- qulab/executor/transform.py,sha256=rk4CLIKVjGRaFzi5FVSgadUxAKKVLSopEHZCaAzDwDg,3435
20
20
  qulab/executor/utils.py,sha256=3OLRMBJu-1t78BeuZs4fv4jioEXnRNygaPnSoibzfgs,6405
21
21
  qulab/monitor/__init__.py,sha256=xEVDkJF8issrsDeLqQmDsvtRmrf-UiViFcGTWuzdlFU,43
22
22
  qulab/monitor/__main__.py,sha256=k2H1H5Zf9LLXTDLISJkbikLH-z0f1e5i5i6wXXYPOrE,105
@@ -99,9 +99,9 @@ qulab/visualization/plot_seq.py,sha256=Uo1-dB1YE9IN_A9tuaOs9ZG3S5dKDQ_l98iD2Wbxp
99
99
  qulab/visualization/qdat.py,sha256=HubXFu4nfcA7iUzghJGle1C86G6221hicLR0b-GqhKQ,5887
100
100
  qulab/visualization/rot3d.py,sha256=jGHJcqj1lEWBUV-W4GUGONGacqjrYvuFoFCwPse5h1Y,757
101
101
  qulab/visualization/widgets.py,sha256=HcYwdhDtLreJiYaZuN3LfofjJmZcLwjMfP5aasebgDo,3266
102
- qulab-2.10.3.dist-info/licenses/LICENSE,sha256=b4NRQ-GFVpJMT7RuExW3NwhfbrYsX7AcdB7Gudok-fs,1086
103
- qulab-2.10.3.dist-info/METADATA,sha256=xpIJzNygtIMGd9wGlhVT99BwC_RTRsGEhn7YkWFLvdk,3860
104
- qulab-2.10.3.dist-info/WHEEL,sha256=ovhA9_Ei_7ok2fAych90j-feDV4goiAxbO7REePtvw0,101
105
- qulab-2.10.3.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
106
- qulab-2.10.3.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
107
- qulab-2.10.3.dist-info/RECORD,,
102
+ qulab-2.10.5.dist-info/licenses/LICENSE,sha256=b4NRQ-GFVpJMT7RuExW3NwhfbrYsX7AcdB7Gudok-fs,1086
103
+ qulab-2.10.5.dist-info/METADATA,sha256=qO155vhjLn82S1GuWo9IHD5JPWMQpIEpgIz7bQ6ps44,3860
104
+ qulab-2.10.5.dist-info/WHEEL,sha256=ovhA9_Ei_7ok2fAych90j-feDV4goiAxbO7REePtvw0,101
105
+ qulab-2.10.5.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
106
+ qulab-2.10.5.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
107
+ qulab-2.10.5.dist-info/RECORD,,
File without changes