Skip to content

Commit d485577

Browse files
committed
Frugal concertina display mode.
1 parent 8112be5 commit d485577

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

common/concertina_lib.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ def __init__(self, config, engine, display_mode='colab', iterations=None):
176176
self.all_actions = {a["name"] for a in self.config}
177177
self.complete_actions = set()
178178
self.running_actions = set()
179-
assert display_mode in ('colab', 'terminal', 'colab-text', 'silent'), (
179+
self.show_only_running = False
180+
if os.getenv('LOGICA_TERMINAL_ONELINE', 'no') == 'yes':
181+
self.show_only_running = True
182+
assert display_mode in ('colab', 'terminal',
183+
'colab-text', 'silent'), (
180184
'Unrecognized display mode: %s' % display_mode)
181185
self.display_mode = display_mode
182186
self.display_id = self.GetDisplayId()
@@ -293,6 +297,13 @@ def AsArtGraph():
293297
extra_lines = self.ProgressBar().split('\n')
294298
return AsArtGraph().GetPicture(updating=updating,
295299
extra_lines=extra_lines)
300+
def ShowRunning(self, updating):
301+
nodes, edges = self.AsNodesAndEdges()
302+
running = [n for n in nodes if n.startswith('\033[1m')]
303+
if not running:
304+
return '*'
305+
return '[%d / %d] ' % (len(self.complete_actions),
306+
len(self.all_actions)) + running[0]
296307

297308
def AsNodesAndEdges(self):
298309
"""Nodes and edges to display in terminal."""
@@ -405,14 +416,18 @@ def UpdateDisplay(self, final=False):
405416
self.display_update_period = min(0.5, self.display_update_period * 1.2)
406417
if (now - self.recent_display_update_seconds <
407418
self.display_update_period and
408-
not final):
419+
not final and
420+
not self.show_only_running):
409421
# Avoid frequent display updates slowing down execution.
410422
return
411423
self.recent_display_update_seconds = now
412424
if self.display_mode == 'colab':
413425
update_display(self.AsGraphViz(), display_id=self.display_id)
414426
elif self.display_mode == 'terminal':
415-
print(self.AsTextPicture(updating=True))
427+
if self.show_only_running:
428+
print(self.ShowRunning(updating=True))
429+
else:
430+
print(self.AsTextPicture(updating=True))
416431
elif self.display_mode == 'colab-text':
417432
update_display(
418433
self.StateAsSimpleHTML(),

0 commit comments

Comments
 (0)