Check if log should be performed.
(main_process_only)
| 11 | |
| 12 | @staticmethod |
| 13 | def _should_log(main_process_only): |
| 14 | """Check if log should be performed.""" |
| 15 | if not dist.is_available() or not dist.is_initialized(): |
| 16 | is_main_process = True |
| 17 | else: |
| 18 | is_main_process = dist.get_rank() == 0 |
| 19 | return not main_process_only or (main_process_only and is_main_process) |
| 20 | |
| 21 | def log(self, level, msg, *args, **kwargs): |
| 22 | """Delegates logger call after checking if we should log. |