Skip to content

Commit 25e2769

Browse files
committed
Fix bug with Celeris window being NoneType during HPC runs
1 parent 5addbc0 commit 25e2769

1 file changed

Lines changed: 30 additions & 31 deletions

File tree

modules/createEVENT/Celeris/celeris/runner.py

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -612,41 +612,40 @@ def Evolve_Display( # noqa: C901, N802, D102
612612
ON_HPC = any("TACC" in k for k in os.environ)
613613
use_ggui = not bool(ON_HPC)
614614
show_gui = not bool(ON_HPC)
615-
if show_gui:
615+
try:
616+
if bool(ON_HPC):
617+
raise Exception('Headless mode detected, reverting to legacy GUI.')
618+
if 'Windows' in os_name:
619+
# Throw exception to force legacy GUI
620+
raise Exception('Windows detected, reverting GGUI to legacy GUI for reliability.')
621+
window = ti.ui.Window('CelerisAi', (self.solver.nx, self.solver.ny)) # noqa: F405
622+
canvas = window.get_canvas()
623+
use_ggui = True
624+
show_gui = True
625+
except: # noqa: E722
626+
# TODO : Formal error handling and logging # noqa: TD002
627+
print('GGUI not available, reverting to legacy Taichi GUI.') # noqa: T201
628+
use_ggui = False
629+
use_fast_gui = False # Need ti.Vector.field equiv to self.solver.pixel to use fast_gui
630+
show_gui = True
616631
try:
617632
if bool(ON_HPC):
618633
raise Exception('Headless mode detected, reverting to legacy GUI.')
619-
if 'Windows' in os_name:
620-
# Throw exception to force legacy GUI
621-
raise Exception('Windows detected, reverting GGUI to legacy GUI for reliability.')
622-
window = ti.ui.Window('CelerisAi', (self.solver.nx, self.solver.ny)) # noqa: F405
623-
canvas = window.get_canvas()
624-
use_ggui = True
625-
show_gui = True
626-
except: # noqa: E722
627-
# TODO : Formal error handling and logging # noqa: TD002
628-
print('GGUI not available, reverting to legacy Taichi GUI.') # noqa: T201
629-
use_ggui = False
630-
use_fast_gui = False # Need ti.Vector.field equiv to self.solver.pixel to use fast_gui
631634
show_gui = True
632-
try:
633-
if bool(ON_HPC):
634-
raise Exception('Headless mode detected, reverting to legacy GUI.')
635-
show_gui = True
636-
print('Default: Show GUI window (e.g., for desktop use.')
637-
window = ti.GUI( # noqa: F405
638-
'CelerisAi', (self.solver.nx, self.solver.ny), fast_gui=use_fast_gui, show_gui=show_gui
639-
) # fast_gui - display directly on frame buffer if not drawing shapes or text
640-
except:
641-
show_gui = False
642-
print('Headless: Do not show GUI window (e.g., for command-line use on remote HPC systems.')
643-
window = ti.GUI( # noqa: F405
644-
'CelerisAi', (self.solver.nx, self.solver.ny), fast_gui=use_fast_gui, show_gui=show_gui
645-
) # fast_gui - display directly on frame buffer if not drawing shapes or text
646-
canvas = None
647-
print('Legacy GUI initialized.') # noqa: T201
648-
else:
649-
print('GGUI initialized without issues.') # noqa: T201
635+
print('Default: Show GUI window (e.g., for desktop use.')
636+
window = ti.GUI( # noqa: F405
637+
'CelerisAi', (self.solver.nx, self.solver.ny), fast_gui=use_fast_gui, show_gui=show_gui
638+
) # fast_gui - display directly on frame buffer if not drawing shapes or text
639+
except:
640+
show_gui = False
641+
print('Headless: Do not show GUI window (e.g., for command-line use on remote HPC systems.')
642+
window = ti.GUI( # noqa: F405
643+
'CelerisAi', (self.solver.nx, self.solver.ny), fast_gui=use_fast_gui, show_gui=show_gui
644+
) # fast_gui - display directly on frame buffer if not drawing shapes or text
645+
canvas = None
646+
print('Legacy GUI initialized.') # noqa: T201
647+
else:
648+
print('GGUI initialized without issues.') # noqa: T201
650649

651650
# Customized colormap
652651
if showSediment:

0 commit comments

Comments
 (0)