np-workflows 1.6.93__py3-none-any.whl → 1.6.95__py3-none-any.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.
@@ -91,24 +91,39 @@ def photodoc_widget(session: np_session.Session, reminder: str) -> None:
91
91
  vimba_dir = np_config.local_to_unc(
92
92
  session.rig.mon, np_services.config_from_zk()["ImageVimba"]["data"]
93
93
  )
94
- n_files = len(tuple(vimba_dir.iterdir()))
95
- t0 = time.time()
94
+
95
+ def get_file_stats():
96
+ return {p: p.stat().st_mtime for p in vimba_dir.iterdir() if p.is_file()}
97
+
98
+ original_file_stats = get_file_stats()
99
+
100
+ timeout_s = 300
96
101
  print(
97
- f"Take an image in Vimba Viewer and save it with the default name (eg should be unique)."
98
- f"\n\n*This cell will wait for a new file to be created in {vimba_dir}, then copy it to the session folder with suffix {reminder!r}*"
102
+ f"Take an image in Vimba Viewer and save it {vimba_dir} with any name and .png suffix."
103
+ f"\n\nThis cell will wait for a new file or an existing file to be modified ({timeout_s = })*"
99
104
  )
100
- timeout_s = 120
101
- while len(files := tuple(vimba_dir.iterdir())) == n_files:
105
+ t0 = time.time()
106
+ while True:
102
107
  time.sleep(1)
108
+ new_files = len(new_file_stats := get_file_stats()) != len(original_file_stats)
109
+ modified_files = any(
110
+ p
111
+ for p in new_file_stats
112
+ if new_file_stats[p] > original_file_stats.get(p, 0)
113
+ )
114
+ if new_files or modified_files:
115
+ break
116
+
103
117
  if time.time() - t0 > timeout_s:
104
118
  raise TimeoutError(
105
119
  f"No new image file detected in Vimba folder after {timeout_s} seconds - aborting"
106
120
  )
107
- latest_image = max(
108
- (p for p in files if p.is_file()), key=lambda f: f.stat().st_ctime
121
+ latest_image = max(new_file_stats, key=lambda k: new_file_stats[k])
122
+ dest = (
123
+ session.npexp_path
124
+ / f"{session.npexp_path.name}_{reminder}{latest_image.suffix}"
109
125
  )
110
- print(f"New file detected:\n\t{latest_image.name}\nCopying to session folder")
111
- new_name = f"{session.npexp_path.name}_{reminder}.png"
112
- shutil.copy2(latest_image, session.npexp_path / new_name)
113
- npxc.validate_or_overwrite(session.npexp_path / new_name, latest_image)
126
+ print(f"New file detected:\n\t{latest_image.name}\nCopying to:\n\t{dest}")
127
+ shutil.copy2(latest_image, dest)
128
+ npxc.validate_or_overwrite(dest, latest_image)
114
129
  print("Done!")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: np-workflows
3
- Version: 1.6.93
3
+ Version: 1.6.95
4
4
  Summary: Ecephys and behavior workflows for the Mindscope Neuropixels team.
5
5
  Author-email: Ben Hardcastle <ben.hardcastle@alleninstitute.org>
6
6
  License: MIT
@@ -2,7 +2,7 @@ np_workflows/__init__.py,sha256=5ZC3gO-VV7PfP13WenHePtvU2wlP68ar6j47pJVvUCM,231
2
2
  np_workflows/experiments/__init__.py,sha256=voWNXF2Kl3mmB4PwqnZ4DcD5zhvBq1j2xLUHnLe6So8,39
3
3
  np_workflows/experiments/dynamic_routing/__init__.py,sha256=M2oiBrVpy_Wrt7oC8J1wzHvKTYdA2K1UIb0-_7S6SuQ,123
4
4
  np_workflows/experiments/dynamic_routing/main.py,sha256=BHleH7NmomD_tMhVPVIpbebetABooOoVClFkggLQS10,2617
5
- np_workflows/experiments/dynamic_routing/widgets.py,sha256=WMoewsS-VEgJZcR8bkhiAumQEgnIcAwFKk_9qYP1jXY,3946
5
+ np_workflows/experiments/dynamic_routing/widgets.py,sha256=a0vb27Jc6TL3KTehG2uDDUnEG3kaC28WTORdRsk1MxA,4239
6
6
  np_workflows/experiments/openscope_P3/P3_workflow_widget.py,sha256=MmGgo-ir4Xy-PDjY3YRhxy5lATAeQ3F9bsuGtF6Bu5I,2361
7
7
  np_workflows/experiments/openscope_P3/__init__.py,sha256=g1SzGmPdWB4MPzx7Zaye4YQU89BDocywCfcAs2ITC5A,133
8
8
  np_workflows/experiments/openscope_P3/main_P3_pilot.py,sha256=39vcLIEVPoB85TdPQ-QlF0sT7Ej9R7oIQHpGJ-dt1Q0,7007
@@ -41,8 +41,8 @@ np_workflows/shared/__init__.py,sha256=YErshr5fY7jU8TJgWqEHz07tUHnEJEZ_mY31DIpQ5
41
41
  np_workflows/shared/base_experiments.py,sha256=KTxsltWtvNlHmlHJkIbMj7qon-RULAlb_Q224c2dtI0,35395
42
42
  np_workflows/shared/npxc.py,sha256=R6n6xrLGr31epoDX_99D_Wy7BYgmjjiZ6efl3UOoK3Y,6642
43
43
  np_workflows/shared/widgets.py,sha256=xF4PKZugYfyHtCPyYxwYgeH5jpB8vyoGDgenEodTTzo,27799
44
- np_workflows-1.6.93.dist-info/METADATA,sha256=kUh_0cAZ-B49iNlBgKZBQsUxpWCmgPr6MI33GbxadTg,3399
45
- np_workflows-1.6.93.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
46
- np_workflows-1.6.93.dist-info/entry_points.txt,sha256=XBvlXc6-LK4_pCjspQZF_yBbopODJIquhZ8J4LhxlaI,41
47
- np_workflows-1.6.93.dist-info/top_level.txt,sha256=lndEdwvoxg_3fCYd2tyIUfcdvCFegVm3lWUdEf85u8M,13
48
- np_workflows-1.6.93.dist-info/RECORD,,
44
+ np_workflows-1.6.95.dist-info/METADATA,sha256=skvFVCb9OMs8h2a6IsO0nzzcUohoaxacwKM7KkvJUjM,3399
45
+ np_workflows-1.6.95.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
46
+ np_workflows-1.6.95.dist-info/entry_points.txt,sha256=XBvlXc6-LK4_pCjspQZF_yBbopODJIquhZ8J4LhxlaI,41
47
+ np_workflows-1.6.95.dist-info/top_level.txt,sha256=lndEdwvoxg_3fCYd2tyIUfcdvCFegVm3lWUdEf85u8M,13
48
+ np_workflows-1.6.95.dist-info/RECORD,,