Coverage for src/fsl_pipe_gui/run.py: 33%

24 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-11 11:06 +0100

1"""Main module containing the actual code to run the GUI.""" 

2from file_tree import FileTree 

3from fsl_pipe import Pipeline 

4from rich import print 

5 

6from .all_panes import AllPanes, PipelineSelector 

7from .placeholder_tab import PlaceholderEditor 

8from .selector_tab import OutputSelector 

9from .summary import show_summary 

10 

11 

12def run_gui(pipeline: Pipeline, tree: FileTree, **kwargs): 

13 """ 

14 Run terminal-based GUI, so the user can select which output files to produce. 

15 

16 Returns True if a pipeline actually ran. False if the user exited before running a pipeline. 

17 

18 :param pipeline: Collection of recipes contained in an `fsl-pipe` Pipeline object. 

19 :param tree: Description of the directory structure containing the input and output files. 

20 """ 

21 selector = PipelineSelector(pipeline, tree, **kwargs) 

22 current = AllPanes.PLACEHOLDER if len(tree.placeholders) > 0 else AllPanes.SELECTOR 

23 

24 while True: 

25 if current is None: 

26 print("Exiting FSL pipeline output selector") 

27 return False 

28 elif current == AllPanes.PLACEHOLDER: 

29 current = PlaceholderEditor(selector).run() 

30 elif current == AllPanes.SELECTOR: 

31 current = OutputSelector(selector).run() 

32 elif current == AllPanes.SUMMARY: 

33 current = show_summary(selector) 

34 elif current == AllPanes.RUN: 

35 selector.run() 

36 return True 

37 else: 

38 raise ValueError( 

39 f"Unexpected error: next pane is set to unknown value: {current}" 

40 )