@@ -156,6 +156,8 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
156156 )
157157
158158 elif event .button .id == "validate_validate_button" :
159+
160+ # Get settings from widgets
159161 select_value = self .query_one (
160162 "#validate_top_level_folder_select"
161163 ).value
@@ -171,6 +173,9 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
171173 ).value
172174
173175 if self .interface :
176+
177+ # If we are in a project, and it has a central storage we
178+ # will connect and, if it's a slow connection, show a waiting screen
174179 if self .interface .project .is_local_project ():
175180 include_central = False
176181 else :
@@ -181,6 +186,7 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
181186 if include_central and self .interface .project .cfg [
182187 "connection_method"
183188 ] in ["aws" , "gdrive" , "ssh" ]:
189+
184190 self .validating_central_popup = (
185191 modal_dialogs .CentralWaitingScreen (
186192 "Validating central project..."
@@ -189,31 +195,16 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
189195 self .parent_class .mainwindow .push_screen (
190196 self .validating_central_popup
191197 )
192- self ._validate_task = asyncio .create_task (
193- self .run_validate_and_dismiss_popup (
194- top_level_folder = top_level_folder ,
195- include_central = include_central ,
196- strict_mode = strict_mode ,
197- allow_letters_in_sub_ses_values = allow_letters_in_sub_ses_values ,
198- ),
199- name = "validate_async_task" ,
200- )
201- else :
202- success , output = self .interface .validate_project (
198+
199+ asyncio .create_task (
200+ self .run_validate_and_dismiss_popup (
203201 top_level_folder = top_level_folder ,
204202 include_central = include_central ,
205203 strict_mode = strict_mode ,
206204 allow_letters_in_sub_ses_values = allow_letters_in_sub_ses_values ,
207- )
208- if not success :
209- self .parent_class .mainwindow .show_modal_error_dialog (
210- cast ("str" , output )
211- )
212- else :
213- self .write_results_to_richlog (output )
214- self .query_one (
215- "#validate_logs_label"
216- ).value = f"Logs output to: { self .interface .project .get_logging_path ()} "
205+ ),
206+ name = "validate_async_task" ,
207+ )
217208 else :
218209 path_ = self .query_one ("#validate_path_input" ).value
219210
@@ -257,10 +248,7 @@ async def run_validate_and_dismiss_popup(
257248 allow_letters_in_sub_ses_values = allow_letters_in_sub_ses_values ,
258249 )
259250 await worker .wait ()
260- if (
261- hasattr (self , "validating_central_popup" )
262- and self .validating_central_popup
263- ):
251+ if self .validating_central_popup :
264252 self .validating_central_popup .dismiss ()
265253 self .validating_central_popup = None
266254
@@ -274,16 +262,18 @@ def validate_project_worker(
274262 ) -> Worker [None ]:
275263 """Run validation in a separate thread to avoid freezing the TUI."""
276264 assert self .interface is not None
265+
277266 success , output = self .interface .validate_project (
278267 top_level_folder = top_level_folder ,
279268 include_central = include_central ,
280269 strict_mode = strict_mode ,
281270 allow_letters_in_sub_ses_values = allow_letters_in_sub_ses_values ,
282271 )
272+
283273 if not success :
284274 self .app .call_from_thread (
285275 self .parent_class .mainwindow .show_modal_error_dialog ,
286- cast ( "str" , output ) ,
276+ output ,
287277 )
288278 else :
289279 self .app .call_from_thread (self .write_results_to_richlog , output )
0 commit comments