QuLab 2.10.4__cp312-cp312-win_amd64.whl → 2.10.6__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/dicttree.py CHANGED
@@ -297,8 +297,8 @@ def update_tree(result, updates):
297
297
  return result
298
298
 
299
299
 
300
- def queryref_tree(q, keys, dct, prefix=[], chain=None):
301
- q = q[1:]
300
+ def queryref_tree(q: str, keys, dct, prefix=[], chain=None):
301
+ q = q.removeprefix('$')
302
302
  if q.startswith('.'):
303
303
  while q.startswith('.'):
304
304
  keys.pop()
@@ -340,7 +340,7 @@ class Env():
340
340
  self.prefix = prefix
341
341
 
342
342
  def get(self, name):
343
- return queryref_tree(name[1:],
343
+ return queryref_tree(name,
344
344
  self.keys,
345
345
  self.dct,
346
346
  prefix=self.prefix,
@@ -405,8 +405,9 @@ internal_functions = {
405
405
 
406
406
 
407
407
  def eval_expr(expression, env=None, functions=None):
408
- from pyparsing import (Forward, Literal, ParseResults, Suppress, Word,
409
- alphanums, delimitedList, infixNotation, oneOf,
408
+ from pyparsing import (Combine, Forward, Literal, MatchFirst, ParseResults,
409
+ Regex, Suppress, Word, ZeroOrMore, alphanums,
410
+ alphas, delimitedList, infixNotation, oneOf,
410
411
  opAssoc, pyparsing_common)
411
412
  if functions is None:
412
413
  functions = internal_functions
@@ -436,8 +437,19 @@ def eval_expr(expression, env=None, functions=None):
436
437
  'e': math.e
437
438
  }.get(t[0]))
438
439
 
439
- variable = Word("$", alphanums +
440
- "._").setParseAction(lambda s, l, t: lookup(t[0]))
440
+ identifier = Word(alphas + '_', alphanums + '_')
441
+ dollar = Literal('$')
442
+ dot_sequence = Regex(r'\.{1,}')
443
+ attr = Combine(Literal('.') + identifier)
444
+ attr_chain = ZeroOrMore(attr)
445
+ dollar_named_chain = Combine(dollar + identifier + attr_chain)
446
+ dollar_dotN_chain = Combine(dollar + dot_sequence + identifier +
447
+ attr_chain)
448
+ dollar_simple = Combine(dollar + identifier)
449
+
450
+ variable = MatchFirst(
451
+ [dollar_dotN_chain, dollar_named_chain,
452
+ dollar_simple]).setParseAction(lambda s, l, t: lookup(t[0]))
441
453
 
442
454
  bracket = Suppress('(') + expr + Suppress(')')
443
455
  bracket.setParseAction(lambda s, l, t: t[0])
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,
@@ -303,7 +306,7 @@ async def run(workflow,
303
306
  @click.option('--veryfy-source-code',
304
307
  is_flag=True,
305
308
  help='Veryfy the source code.')
306
- @log_options
309
+ @log_options('maintain')
307
310
  @command_option('maintain')
308
311
  @async_command
309
312
  async def maintain(workflow,
@@ -388,7 +391,7 @@ async def maintain(workflow,
388
391
  @click.command()
389
392
  @click.argument('report_id')
390
393
  @click.option('--plot', '-p', is_flag=True, help='Plot the report.')
391
- @log_options
394
+ @log_options('reproduce')
392
395
  @command_option('reproduce')
393
396
  @async_command
394
397
  async def reproduce(report_id, code, data, api, plot):
@@ -415,16 +418,17 @@ async def reproduce(report_id, code, data, api, plot):
415
418
  code = Path(os.path.expanduser(code))
416
419
  data = Path(os.path.expanduser(data))
417
420
 
418
- from . import transform
419
421
  from .load import load_workflow_from_source_code
420
422
  from .storage import get_report_by_index
421
423
 
424
+ reg = Registry()
425
+
422
426
  r = get_report_by_index(int(report_id), data)
423
427
 
424
428
  wf = load_workflow_from_source_code(r.workflow, r.script)
425
- cfg = transform.export_config()
426
- transform.clear_config()
427
- transform.update_config(r.config)
429
+ cfg = reg.export()
430
+ reg.clear()
431
+ reg.update(r.config)
428
432
  await run_workflow(wf, code, data, plot=plot, freeze=True)
429
- transform.clear_config()
430
- transform.update_config(cfg)
433
+ reg.clear()
434
+ reg.update(cfg)
qulab/executor/load.py CHANGED
@@ -1,10 +1,10 @@
1
1
  import atexit
2
2
  import inspect
3
- import pickle
4
3
  import os
5
- import time
4
+ import pickle
6
5
  import shutil
7
6
  import tempfile
7
+ import time
8
8
  import warnings
9
9
  from importlib.util import module_from_spec, spec_from_file_location
10
10
  from pathlib import Path
@@ -13,6 +13,7 @@ from typing import Any
13
13
 
14
14
  from loguru import logger
15
15
 
16
+ from .registry import Registry
16
17
  from .storage import Report
17
18
  from .template import (TemplateKeyError, TemplateTypeError, decode_mapping,
18
19
  inject_mapping)
@@ -31,17 +32,16 @@ class SetConfigWorkflow():
31
32
  return []
32
33
 
33
34
  def check_state(self, history: Report) -> bool:
34
- from . import transform
35
+ reg = Registry()
35
36
  try:
36
- return self._equal(history.parameters[self.key],
37
- transform.query_config(self.key))
37
+ return self._equal(history.parameters[self.key], reg.get(self.key))
38
38
  except:
39
39
  return False
40
40
 
41
41
  def calibrate(self):
42
- from . import transform
42
+ reg = Registry()
43
43
  try:
44
- value = transform.query_config(self.key)
44
+ value = reg.get(self.key)
45
45
  except:
46
46
  value = eval(input(f'"{self.key}": '))
47
47
  return value
@@ -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
@@ -123,7 +129,7 @@ def set_config_api(query_method,
123
129
  clear_method: The clear method.
124
130
  the method should clear the config.
125
131
  """
126
- global query_config, update_config, delete_config, export_config, clear_config
132
+ global query_config, update_config, delete_config, export_config, clear_config, _api
127
133
 
128
134
  query_config = query_method
129
135
  update_config = update_method
@@ -132,3 +138,48 @@ 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 __init__(self):
163
+ self.api = (query_config, update_config, delete_config, export_config,
164
+ clear_config)
165
+
166
+ def query(self, key: str) -> Any:
167
+ return self.api[0](key)
168
+
169
+ def get(self, key: str) -> Any:
170
+ return self.query(key)
171
+
172
+ def export(self) -> dict[str, dict[str, Any]]:
173
+ return self.api[3]()
174
+
175
+ def set(self, key: str, value: Any):
176
+ return self.api[1]({key: value})
177
+
178
+ def delete(self, key: str):
179
+ return self.api[2](key)
180
+
181
+ def clear(self):
182
+ return self.api[4]()
183
+
184
+ def update(self, parameters: dict[str, Any]):
185
+ return self.api[1](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/scan/__init__.py CHANGED
@@ -1,3 +1,2 @@
1
- from .expression import Expression, Symbol
2
1
  from .query import get_record, load_record, lookup, lookup_list
3
2
  from .scan import Scan
qulab/scan/scan.py CHANGED
@@ -18,8 +18,8 @@ import dill
18
18
  import numpy as np
19
19
  import zmq
20
20
 
21
+ from ..expression import Env, Expression, Symbol
21
22
  from ..sys.rpc.zmq_socket import ZMQContextManager
22
- from .expression import Env, Expression, Symbol
23
23
  from .optimize import NgOptimizer
24
24
  from .record import Record
25
25
  from .server import default_record_port
@@ -509,7 +509,8 @@ class Scan():
509
509
 
510
510
  if self.config:
511
511
  self.description['config'] = await create_config(
512
- self._raw_config_copy, self.description['database'], self._sock)
512
+ self._raw_config_copy, self.description['database'],
513
+ self._sock)
513
514
  if current_notebook() is None:
514
515
  await create_notebook('untitle', self.description['database'],
515
516
  self._sock)
qulab/scan/utils.py CHANGED
@@ -11,7 +11,7 @@ from typing import Any, Callable
11
11
 
12
12
  import dill
13
13
 
14
- from .expression import Env, Expression
14
+ from ..expression import Env, Expression
15
15
 
16
16
 
17
17
  class Unpicklable:
qulab/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.10.4"
1
+ __version__ = "2.10.6"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QuLab
3
- Version: 2.10.4
3
+ Version: 2.10.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,22 +1,23 @@
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
- qulab/dicttree.py,sha256=ZoSJVWK4VMqfzj42gPb_n5RqLlM6K1Me0WmLIfLEYf8,14195
4
- qulab/fun.cp312-win_amd64.pyd,sha256=QddftATgZkwseIwCAYDh_ffwv43VGp5E_uwl0YtHvRo,32256
3
+ qulab/dicttree.py,sha256=hYjVWjNYFmtzMWcIjIH6NJNDzpIW-g4TZbn2EBarpzg,14759
4
+ qulab/expression.py,sha256=pfp3usiHCMHIbSBRqSCSDXA2f0gDDIZ9PMrkxf8yWjY,25777
5
+ qulab/fun.cp312-win_amd64.pyd,sha256=BmkILgRUd9S2hLF4753GuK14tod04lqR0r9X456czqc,32256
5
6
  qulab/typing.py,sha256=PRtwbCHWY2ROKK8GHq4Bo8llXrIGo6xC73DrQf7S9os,71
6
7
  qulab/utils.py,sha256=65N2Xj7kqRsQ4epoLNY6tL-i5ts6Wk8YuJYee3Te6zI,3077
7
- qulab/version.py,sha256=K_lsR8oWkx9B0hBjg9Do_K_HlMnbbdWzkT8W_QIxmL8,22
8
+ qulab/version.py,sha256=9LJkGNy79PoPvb-ypqzJeCk2XlpeUgkGouuN08RGMH4,22
8
9
  qulab/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
10
  qulab/cli/commands.py,sha256=ZTs32yQjvwPIsFjXYWNr4KqEvly0NISIqyh--96qCAY,627
10
11
  qulab/cli/config.py,sha256=A3UnyaRtiofpokyzYkJnUdwzcsYX7H-xZvBVduIOSdg,5617
11
12
  qulab/cli/decorators.py,sha256=mgAZiiaj2vZvsJEg70gxgB9TWkxR1nQSb2m-73RYHr0,649
12
13
  qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
13
14
  qulab/executor/analyze.py,sha256=VoSthE2RTarY6Wj3QFKh4FqReMYL7djSAyuitgHs5K0,5837
14
- qulab/executor/cli.py,sha256=_npz238lTU5RVJOKbfE4wTPS00RpMci19QcX01MfrE8,14911
15
- qulab/executor/load.py,sha256=0-EtO4dkP6jB1vsgQlniv-OtPH1AZLjbtuvaWHsgbPs,20335
16
- qulab/executor/schedule.py,sha256=1YWz2d5YLmnEpXGX1aVroE0SOKdU28WwHGEioxBpTKQ,21411
15
+ qulab/executor/cli.py,sha256=bmuFPpPhHiRzTjIjhvlp2tQYp0jEwXSETILX8Nu2tLE,14901
16
+ qulab/executor/load.py,sha256=C5qepxC9QALMgfG_twxvGts6i0bCsnVg9lS05PXZZRM,20291
17
+ qulab/executor/registry.py,sha256=gym9F5FIDY5eV-cSCZsP99wC4l-6jkx9VMjJMaPOLaQ,4730
18
+ qulab/executor/schedule.py,sha256=7gAJFwj13j1niGjVa1fSzwOS22eNFEN1hdrN3dfTY6A,21410
17
19
  qulab/executor/storage.py,sha256=8K73KGLAVgchJdtd4rKHXkr1CQOJORWH-Gi57w8IYsw,21081
18
20
  qulab/executor/template.py,sha256=dKQM3IlADdTi9qp0fnOYjyycRNEl7KeSCBZhwbmP8bQ,10828
19
- qulab/executor/transform.py,sha256=rk4CLIKVjGRaFzi5FVSgadUxAKKVLSopEHZCaAzDwDg,3435
20
21
  qulab/executor/utils.py,sha256=3OLRMBJu-1t78BeuZs4fv4jioEXnRNygaPnSoibzfgs,6405
21
22
  qulab/monitor/__init__.py,sha256=xEVDkJF8issrsDeLqQmDsvtRmrf-UiViFcGTWuzdlFU,43
22
23
  qulab/monitor/__main__.py,sha256=k2H1H5Zf9LLXTDLISJkbikLH-z0f1e5i5i6wXXYPOrE,105
@@ -28,17 +29,16 @@ qulab/monitor/monitor.py,sha256=2AP-hhg1T6-38mieDm5_ONTIXnXYlIrSyOiAOxDKy0I,2398
28
29
  qulab/monitor/ploter.py,sha256=dg7W28XTwEbBxHVtdPkFV135OQgoQwTi-NJCZQF-HYU,3724
29
30
  qulab/monitor/qt_compat.py,sha256=Eq7zlA4_XstB92NhtAqebtWU_Btw4lcwFO30YxZ-TPE,804
30
31
  qulab/monitor/toolbar.py,sha256=HxqG6ywKFyQJM2Q1s7SnhuzjbyeROczAZKwxztD1WJ8,8213
31
- qulab/scan/__init__.py,sha256=RR_0NQcr8Mi3vpWdypydbijQ1rXA0D3DEidQ7xjNslM,133
32
+ qulab/scan/__init__.py,sha256=ZUwe6GvaaEmelsvAwM6yTWF1DYG8klAFvya6nD_BGI4,89
32
33
  qulab/scan/curd.py,sha256=m1MiW7Q_UActxpXor8n6PTck6A6O0_GRWHjVTJ3jBM4,7109
33
- qulab/scan/expression.py,sha256=pfp3usiHCMHIbSBRqSCSDXA2f0gDDIZ9PMrkxf8yWjY,25777
34
34
  qulab/scan/models.py,sha256=LMMWNfty9T1CoO07pN1wloq6Gob7taeOxWTBJFjGXLI,18180
35
35
  qulab/scan/optimize.py,sha256=zOR4Wp96bLarTSiPJ-cTAfT-V_MU-YEgB-XqYsBhS30,2637
36
36
  qulab/scan/query.py,sha256=RM8bG4Tcx_PaNk8tv9HdlTZ1dGuuSr3sZVkYVq2BtfQ,12183
37
37
  qulab/scan/record.py,sha256=MVmxhIzwmOju7eWxJEWsqJZlVgrDeRXGMfNvXImj7Ms,21883
38
- qulab/scan/scan.py,sha256=p7LZvmjDSnUHeszgILlEXFIspHVPLk9Rt2dVqFtNsaQ,40645
38
+ qulab/scan/scan.py,sha256=IcPckASWJc1qtoBTRApp9l7wjIQKbBP8vXxjn-znyEg,40663
39
39
  qulab/scan/server.py,sha256=rNYdf53TysNjT8RvL5LGcO9YRbBrwOWCl1gwd7wBtaE,17443
40
40
  qulab/scan/space.py,sha256=t8caa_gKlnhaAIEksJyxINUTecOS7lMWAz1HDKlVcds,6909
41
- qulab/scan/utils.py,sha256=YXFA19HEakHB5TaPOU9CjQ1Lc3GUJaSIGOtiWjAWsG4,6353
41
+ qulab/scan/utils.py,sha256=MpuNPJZJThFS2dze1ZfQ3_zvtfgG5wBL4Ic9-1xR_5E,6354
42
42
  qulab/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  qulab/storage/__main__.py,sha256=6-EjN0waX1yfcMPJXqpIr9UlrIEsSCFApm5G-ZeaPMQ,1742
44
44
  qulab/storage/base_dataset.py,sha256=28y3-OZrqJ52p5sbirEpUgjb7hqwLLpd38KU9DCkD24,12217
@@ -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.4.dist-info/licenses/LICENSE,sha256=b4NRQ-GFVpJMT7RuExW3NwhfbrYsX7AcdB7Gudok-fs,1086
103
- qulab-2.10.4.dist-info/METADATA,sha256=JXEKGtdaLzjMsnLhaXVwk6EbxpMuCoW4-eNZr9R23Ys,3860
104
- qulab-2.10.4.dist-info/WHEEL,sha256=ovhA9_Ei_7ok2fAych90j-feDV4goiAxbO7REePtvw0,101
105
- qulab-2.10.4.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
106
- qulab-2.10.4.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
107
- qulab-2.10.4.dist-info/RECORD,,
102
+ qulab-2.10.6.dist-info/licenses/LICENSE,sha256=b4NRQ-GFVpJMT7RuExW3NwhfbrYsX7AcdB7Gudok-fs,1086
103
+ qulab-2.10.6.dist-info/METADATA,sha256=2uAIz5ZYxwC2THY2cVecR0o46JP_WXkAg2g46CgZHEM,3860
104
+ qulab-2.10.6.dist-info/WHEEL,sha256=ovhA9_Ei_7ok2fAych90j-feDV4goiAxbO7REePtvw0,101
105
+ qulab-2.10.6.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
106
+ qulab-2.10.6.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
107
+ qulab-2.10.6.dist-info/RECORD,,
File without changes
File without changes