MCPcopy
hub / github.com/openai/improved-diffusion / configure

Function configure

improved_diffusion/logger.py:442–471  ·  view source on GitHub ↗

If comm is provided, average all numerical stats across that comm

(dir=None, format_strs=None, comm=None, log_suffix="")

Source from the content-addressed store, hash-verified

440
441
442def configure(dir=None, format_strs=None, comm=None, log_suffix=""):
443 """
444 If comm is provided, average all numerical stats across that comm
445 """
446 if dir is None:
447 dir = os.getenv("OPENAI_LOGDIR")
448 if dir is None:
449 dir = osp.join(
450 tempfile.gettempdir(),
451 datetime.datetime.now().strftime("openai-%Y-%m-%d-%H-%M-%S-%f"),
452 )
453 assert isinstance(dir, str)
454 dir = os.path.expanduser(dir)
455 os.makedirs(os.path.expanduser(dir), exist_ok=True)
456
457 rank = get_rank_without_mpi_import()
458 if rank > 0:
459 log_suffix = log_suffix + "-rank%03i" % rank
460
461 if format_strs is None:
462 if rank == 0:
463 format_strs = os.getenv("OPENAI_LOG_FORMAT", "stdout,log,csv").split(",")
464 else:
465 format_strs = os.getenv("OPENAI_LOG_FORMAT_MPI", "log").split(",")
466 format_strs = filter(None, format_strs)
467 output_formats = [make_output_format(f, dir, log_suffix) for f in format_strs]
468
469 Logger.CURRENT = Logger(dir=dir, output_formats=output_formats, comm=comm)
470 if output_formats:
471 log("Logging to %s" % dir)
472
473
474def _configure_default_logger():

Callers 2

scoped_configureFunction · 0.85

Calls 4

make_output_formatFunction · 0.85
LoggerClass · 0.85
logFunction · 0.85

Tested by

no test coverage detected