Skip to content

Commit b6499bd

Browse files
committed
Added '_analyse' attribute to MultigridDirWatcher to control when to process data; adjusts logic when notifying listeners to take 'self_analyse' into account
1 parent ffe8dfd commit b6499bd

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/murfey/client/watchdir_multigrid.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ def __init__(
2121
):
2222
super().__init__()
2323
self._basepath = Path(path)
24-
self._skip_existing_processing = skip_existing_processing
25-
self._seen_dirs: List[Path] = []
26-
self._stopping = False
2724
self._machine_config = machine_config
25+
self._seen_dirs: List[Path] = []
2826
self.thread = threading.Thread(
2927
name=f"MultigridDirWatcher {self._basepath}",
3028
target=self._process,
3129
daemon=True,
3230
)
31+
# Toggleable settings
32+
self._analyse = True
33+
self._skip_existing_processing = skip_existing_processing
34+
self._stopping = False
3335

3436
def start(self):
3537
if self.thread.is_alive():
@@ -60,8 +62,14 @@ def _process(self):
6062
include_mid_path=False,
6163
use_suggested_path=False,
6264
analyse=(
63-
d.name
64-
in self._machine_config["analyse_created_directories"]
65+
(
66+
d.name
67+
in self._machine_config[
68+
"analyse_created_directories"
69+
]
70+
)
71+
if self._analyse
72+
else False
6573
),
6674
tag="atlas",
6775
)
@@ -72,23 +80,25 @@ def _process(self):
7280
d,
7381
extra_directory=f"metadata_{d.name}",
7482
include_mid_path=False,
75-
analyse=True, # not (first_loop and self._skip_existing_processing),
83+
analyse=self._analyse,
7684
limited=True,
7785
tag="metadata",
7886
)
7987
self._seen_dirs.append(d)
8088
processing_started = False
8189
for d02 in (d.parent.parent / d.name).glob("Images-Disc*"):
8290
if d02 not in self._seen_dirs:
83-
# if skip exisiting processing is set then do not process for any
84-
# data directories found on the first loop
85-
# this allows you to avoid triggering processing again if murfey is restarted
91+
# If 'skip_existing_processing' is set, do not process for
92+
# any data directories found on the first loop.
93+
# This allows you to avoid triggering processing again if Murfey is restarted
8694
self.notify(
8795
d02,
8896
include_mid_path=False,
8997
remove_files=True,
90-
analyse=not (
91-
first_loop and self._skip_existing_processing
98+
analyse=(
99+
not (first_loop and self._skip_existing_processing)
100+
if self._analyse
101+
else False
92102
),
93103
tag="fractions",
94104
)
@@ -104,8 +114,10 @@ def _process(self):
104114
self.notify(
105115
d02,
106116
include_mid_path=False,
107-
analyse=not (
108-
first_loop and self._skip_existing_processing
117+
analyse=(
118+
not (first_loop and self._skip_existing_processing)
119+
if self._analyse
120+
else False
109121
),
110122
tag="fractions",
111123
)

0 commit comments

Comments
 (0)