3030
3131import fiddle as fdl
3232import networkx as nx
33+ import rich
3334from fiddle ._src import daglish , diffing
3435from rich .console import Group
3536from rich .live import Live
6869)
6970
7071
72+ class DummyConsole :
73+ """A dummy console that mimics rich.console.Console but does nothing."""
74+
75+ def __getattr__ (self , name ):
76+ """Return a no-op function for any attribute access."""
77+
78+ def no_op (* args , ** kwargs ):
79+ pass
80+
81+ return no_op
82+
83+
7184class Experiment (ConfigurableMixin ):
7285 """
7386 A context manager to launch and manage multiple runs, all using pure Python.
@@ -280,6 +293,7 @@ def __init__(
280293 _reconstruct : bool = False ,
281294 jobs : list [Job | JobGroup ] | None = None ,
282295 base_dir : str | None = None ,
296+ clean_mode : bool = False ,
283297 ) -> None :
284298 """
285299 Initializes an experiment run by creating its metadata directory and saving the experiment config.
@@ -294,6 +308,7 @@ def __init__(
294308 log_level: Set log level for the experiment. Defaults to WARN.
295309 _reconstruct: Generally, the user does not need to specify this flag.
296310 This is only set to True when using run.Experiment.from_dir.
311+ clean_mode: If True, disables all console output (logs, progress bars, etc.). Defaults to False.
297312 """
298313 configure_logging (level = log_level )
299314 self ._reconstruct = _reconstruct
@@ -318,6 +333,9 @@ def __init__(
318333 self ._jobs : list [Job | JobGroup ] = jobs or []
319334 self .tunnels : dict [str , Tunnel ] = {}
320335 self .console = CONSOLE
336+ self .clean_mode = clean_mode
337+ if self .clean_mode :
338+ self .console = DummyConsole ()
321339 self ._launched = False
322340 self ._live_progress = None
323341 self ._current_experiment_token = None
@@ -329,6 +347,7 @@ def to_config(self) -> Config:
329347 id = self ._id ,
330348 executor = self .executor .to_config (),
331349 log_level = self .log_level ,
350+ clean_mode = self .clean_mode ,
332351 )
333352
334353 def _save_experiment (self , exist_ok : bool = False ):
@@ -1037,9 +1056,10 @@ def _initialize_live_progress(self):
10371056 if not self ._live_progress :
10381057 # Disable live progress if we are tailing logs for any task
10391058 # as tty output consistency can not be guaranteed as of now
1040- if any (map (lambda job : job .tail_logs , self .jobs )):
1059+ if self . clean_mode or any (map (lambda job : job .tail_logs , self .jobs )):
10411060 return
10421061
1062+ assert isinstance (self .console , rich .console .Console )
10431063 self ._progress = Progress (
10441064 "{task.description}" ,
10451065 SpinnerColumn (),
0 commit comments