(msg, level=logging.INFO, flush=True)
| 125 | logger = configure_logging() |
| 126 | |
| 127 | def print_rank0(msg, level=logging.INFO, flush=True): |
| 128 | if isinstance(level, str): |
| 129 | level = getattr(logging, level.upper()) |
| 130 | if torch.distributed.is_initialized(): |
| 131 | msg = f"[RANK {torch.distributed.get_rank()}] {msg}" |
| 132 | if torch.distributed.get_rank() == 0: |
| 133 | logger.log(level=level, msg=msg) |
| 134 | if flush: |
| 135 | logger.handlers[0].flush() |
| 136 | else: |
| 137 | logger.log(level=level, msg=msg) |
| 138 | |
| 139 | def print_all(msg, level=logging.INFO, flush=True): |
| 140 | if isinstance(level, str): |
no test coverage detected