np-workflows 1.6.92__py3-none-any.whl → 1.6.94__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.
@@ -1,7 +1,13 @@
1
+ import shutil
2
+ import time
3
+
1
4
  import IPython.display
2
5
  import ipywidgets as ipw
6
+ import np_config
7
+ import np_services
3
8
  import np_session
4
9
 
10
+ import np_workflows.shared.npxc as npxc
5
11
  from np_workflows.shared.base_experiments import DynamicRoutingExperiment
6
12
 
7
13
  # for widget, before creating a experiment --------------------------------------------- #
@@ -82,6 +88,39 @@ def workflow_select_widget(
82
88
 
83
89
 
84
90
  def photodoc_widget(session: np_session.Session, reminder: str) -> None:
91
+ vimba_dir = np_config.local_to_unc(
92
+ session.rig.mon, np_services.config_from_zk()["ImageVimba"]["data"]
93
+ )
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
+
85
100
  print(
86
- f"Take an image in Vimba Viewer and save as:\n{session.npexp_path.name}_{reminder}.png"
101
+ f"Take an image in Vimba Viewer and save it {vimba_dir} with any name + .png suffix."
102
+ f"\n\nThis cell will wait for a new file or an existing file to be modified, then copy it as {reminder!r}*"
87
103
  )
104
+ t0 = time.time()
105
+ timeout_s = 120
106
+ while True:
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
+
117
+ if time.time() - t0 > timeout_s:
118
+ raise TimeoutError(
119
+ f"No new image file detected in Vimba folder after {timeout_s} seconds - aborting"
120
+ )
121
+ latest_image = max(new_file_stats, key=lambda k: new_file_stats[k])
122
+ print(f"New file detected:\n\t{latest_image.name}\nCopying to session folder")
123
+ new_name = f"{session.npexp_path.name}_{reminder}.png"
124
+ shutil.copy2(latest_image, session.npexp_path / new_name)
125
+ npxc.validate_or_overwrite(session.npexp_path / new_name, latest_image)
126
+ print("Done!")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: np-workflows
3
- Version: 1.6.92
3
+ Version: 1.6.94
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=kRtpnyKYyKcjM_4oNM2YeCLDNaxEwOUopyDcdK0gNj0,2815
5
+ np_workflows/experiments/dynamic_routing/widgets.py,sha256=q9X0hitKO63wZhv-ryB97xuluU-EWyt2frfC5qi1-oU,4246
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.92.dist-info/METADATA,sha256=Xb9Y8sY16RTF2eeDSrd1yNjRTX_vPnPqZlczpCMBzvk,3399
45
- np_workflows-1.6.92.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
46
- np_workflows-1.6.92.dist-info/entry_points.txt,sha256=XBvlXc6-LK4_pCjspQZF_yBbopODJIquhZ8J4LhxlaI,41
47
- np_workflows-1.6.92.dist-info/top_level.txt,sha256=lndEdwvoxg_3fCYd2tyIUfcdvCFegVm3lWUdEf85u8M,13
48
- np_workflows-1.6.92.dist-info/RECORD,,
44
+ np_workflows-1.6.94.dist-info/METADATA,sha256=VGccVYWAt-BY4bB4h26uMtvn8P5D8gqhJ3ALa8aFEXI,3399
45
+ np_workflows-1.6.94.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
46
+ np_workflows-1.6.94.dist-info/entry_points.txt,sha256=XBvlXc6-LK4_pCjspQZF_yBbopODJIquhZ8J4LhxlaI,41
47
+ np_workflows-1.6.94.dist-info/top_level.txt,sha256=lndEdwvoxg_3fCYd2tyIUfcdvCFegVm3lWUdEf85u8M,13
48
+ np_workflows-1.6.94.dist-info/RECORD,,