QuLab 2.7.18__cp312-cp312-win_amd64.whl → 2.7.19__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/executor/load.py CHANGED
@@ -81,16 +81,6 @@ class SetConfigWorkflow():
81
81
  WorkflowType = ModuleType | SetConfigWorkflow
82
82
 
83
83
 
84
- def get_source(workflow: WorkflowType, code_path: str | Path) -> str:
85
- if isinstance(code_path, str):
86
- code_path = Path(code_path)
87
- try:
88
- with open(code_path / workflow.__workflow_id__, 'r') as f:
89
- return f.read()
90
- except:
91
- return ''
92
-
93
-
94
84
  def can_call_without_args(func):
95
85
  if not callable(func):
96
86
  return False
@@ -320,6 +310,8 @@ def load_workflow_from_file(file_name: str,
320
310
  module = module_from_spec(spec)
321
311
  spec.loader.exec_module(module)
322
312
  module.__mtime__ = (base_path / path).stat().st_mtime
313
+ source_code = (base_path / path).read_text()
314
+ module.__source__ = source_code
323
315
 
324
316
  if hasattr(module, 'entries'):
325
317
  verify_entries(module, base_path)
@@ -347,11 +339,11 @@ def load_workflow_from_template(template_path: str,
347
339
  path = Path(template_path)
348
340
 
349
341
  with open(base_path / path) as f:
350
- content = f.read()
342
+ template = f.read()
351
343
 
352
344
  mtime = max((base_path / template_path).stat().st_mtime, mtime)
353
345
 
354
- content, hash_str = inject_mapping(content, mapping, str(path))
346
+ content, hash_str = inject_mapping(template, mapping, str(path))
355
347
 
356
348
  if target_path is None:
357
349
  if path.stem == 'template':
@@ -365,22 +357,19 @@ def load_workflow_from_template(template_path: str,
365
357
  path = target_path
366
358
 
367
359
  file = base_path / path
368
- if not file.exists():
360
+ if not file.exists() or file.stat().st_mtime < mtime:
369
361
  file.parent.mkdir(parents=True, exist_ok=True)
370
362
  with open(file, 'w') as f:
371
363
  f.write(content)
372
- else:
373
- if file.stat().st_mtime < mtime:
374
- with open(file, 'w') as f:
375
- f.write(content)
376
- else:
377
- if file.read_text() != content:
378
- logger.warning(
379
- f"`{file}` already exists and is different from the new one generated from template `{template_path}`"
380
- )
364
+ elif file.read_text() != content:
365
+ logger.warning(
366
+ f"`{file}` already exists and is different from the new one generated from template `{template_path}`"
367
+ )
381
368
 
382
369
  module = load_workflow_from_file(str(path), base_path, package)
383
370
  module.__mtime__ = max(mtime, module.__mtime__)
371
+ if module.__source__ == content:
372
+ module.__source__ = template, mapping, str(template_path)
384
373
 
385
374
  return module
386
375
 
@@ -422,8 +411,6 @@ def load_workflow(workflow: str | tuple[str, dict],
422
411
  w.__workflow_id__ = str(Path(w.__file__).relative_to(base_path))
423
412
  else:
424
413
  raise TypeError(f"Invalid workflow: {workflow}")
425
-
426
- w.__source__ = get_source(w, base_path)
427
414
 
428
415
  return w
429
416
 
qulab/executor/storage.py CHANGED
@@ -36,6 +36,20 @@ class Report():
36
36
  config_path: Path | None = field(default=None, repr=False)
37
37
  script_path: Path | None = field(default=None, repr=False)
38
38
 
39
+ def __getstate__(self):
40
+ state = self.__dict__.copy()
41
+ state.pop('base_path')
42
+ for k in ['path', 'previous_path', 'config_path', 'script_path']:
43
+ if state[k] is not None:
44
+ state[k] = str(state[k])
45
+ return state
46
+
47
+ def __setstate__(self, state):
48
+ for k in ['path', 'previous_path', 'config_path', 'script_path']:
49
+ if state[k] is not None:
50
+ state[k] = Path(state[k])
51
+ self.__dict__.update(state)
52
+
39
53
  @property
40
54
  def previous(self):
41
55
  if self.previous_path is not None and self.base_path is not None:
@@ -84,7 +98,9 @@ class Report():
84
98
  @property
85
99
  def script(self):
86
100
  if self.script_path is not None and self.base_path is not None:
87
- return load_item(self.script_path, self.base_path)
101
+ source = load_item(self.script_path, self.base_path)
102
+ if isinstance(source, str):
103
+ return source
88
104
  else:
89
105
  return None
90
106
 
Binary file
qulab/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.7.18"
1
+ __version__ = "2.7.19"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: QuLab
3
- Version: 2.7.18
3
+ Version: 2.7.19
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,18 +1,18 @@
1
1
  qulab/__init__.py,sha256=RZme5maBSMZpP6ckXymqZpo2sRYttwEpTYCIzIvys1c,292
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=Ej7tVU6leHUtpKpK9mmEI_pDYeczIKyvn8iTYzqGTVw,32256
4
+ qulab/fun.cp312-win_amd64.pyd,sha256=9KloY_zYqvO1_wgJsjITEhFZxq12rojMPovghk1PsCo,32256
5
5
  qulab/typing.py,sha256=PRtwbCHWY2ROKK8GHq4Bo8llXrIGo6xC73DrQf7S9os,71
6
6
  qulab/utils.py,sha256=kSy_tQRLDdlMwk7XhGhg75JadNHbDkau5vYcfOlJG_4,3088
7
- qulab/version.py,sha256=xLneP_cqIForMj5AICyQrp13un8yGC7zOY4cjyKywXk,22
7
+ qulab/version.py,sha256=l3aREioriZeXEjFmLR4Dbu7Nj408gevOUOElKwDjjD4,22
8
8
  qulab/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  qulab/cli/commands.py,sha256=6xd2eYw32k1NmfAuYSu__1kaP12Oz1QVqwbkYXdWno4,588
10
10
  qulab/cli/config.py,sha256=7h3k0K8FYHhI6LVWt8BoDdKrX2ApFDBAUAUuXhHwst4,3799
11
11
  qulab/executor/__init__.py,sha256=LosPzOMaljSZY1thy_Fxtbrgq7uubJszMABEB7oM7tU,101
12
12
  qulab/executor/cli.py,sha256=z8W1RivKdABQSOGy2viNUvG73QvOBpE9gSKjw45vSVA,9794
13
- qulab/executor/load.py,sha256=omD2aklKZnHOosahI-Vs6sQkGdn4U9PgnDIAbrEOhi0,17786
13
+ qulab/executor/load.py,sha256=YndvzagvWR8Sg6WHZ-gP-Of0FrFOyh_E_a3VXsjDf1Q,17502
14
14
  qulab/executor/schedule.py,sha256=0BV5LGxhqdIlGwW6-o5_5mljAtdtL1La8EDNBFi8pzU,18585
15
- qulab/executor/storage.py,sha256=gI6g28BmKKEZ_Pl-hFwvpiOj3mF8Su-yjj3hfMXs1VY,11630
15
+ qulab/executor/storage.py,sha256=jFUXYcBFyH2vVzrSzmXtyLtEgIMRczfk27Yb95pV5JM,12217
16
16
  qulab/executor/template.py,sha256=bKMoOBPfa3XMgTfGHQK6pDTswH1vcIjnopaWE3UKpP0,7726
17
17
  qulab/executor/transform.py,sha256=BDx0c4nqTHMAOLVqju0Ydd91uxNm6EpVIfssjZse0bI,2284
18
18
  qulab/executor/utils.py,sha256=l_b0y2kMwYKyyXeFtoblPYwKNU-wiFQ9PMo9QlWl9wE,6213
@@ -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.7.18.dist-info/LICENSE,sha256=b4NRQ-GFVpJMT7RuExW3NwhfbrYsX7AcdB7Gudok-fs,1086
101
- qulab-2.7.18.dist-info/METADATA,sha256=ftNypm4S-GR5LeN2SHGHdrAlv0dvHksDaQH_XwPoFo8,3804
102
- qulab-2.7.18.dist-info/WHEEL,sha256=A8mRFNvJcDL8dRPZ6k2ICKEOXwE8pzYFXYxEla0rR0g,101
103
- qulab-2.7.18.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
104
- qulab-2.7.18.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
105
- qulab-2.7.18.dist-info/RECORD,,
100
+ qulab-2.7.19.dist-info/LICENSE,sha256=b4NRQ-GFVpJMT7RuExW3NwhfbrYsX7AcdB7Gudok-fs,1086
101
+ qulab-2.7.19.dist-info/METADATA,sha256=De5Wd5mlNaRcr3jnjjS0R2O-_6tfd3Jj-4slwKIXmIc,3804
102
+ qulab-2.7.19.dist-info/WHEEL,sha256=A8mRFNvJcDL8dRPZ6k2ICKEOXwE8pzYFXYxEla0rR0g,101
103
+ qulab-2.7.19.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
104
+ qulab-2.7.19.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
105
+ qulab-2.7.19.dist-info/RECORD,,
File without changes