Skip to content

Commit

Permalink
Hotfix/sg 000 temporary mute upload print (#672)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* remove raise to debug

* fix

* undo unwanted change

* improve display of experiment_log epoch index

* fix

* redirect to DEBUG

* update comment

* fix typo in name
  • Loading branch information
Louis-Dupont authored Jan 31, 2023
1 parent f1ebda5 commit 21fa8ae
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/super_gradients/common/sg_loggers/deci_platform_sg_logger.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
import io
from contextlib import contextmanager
from typing import Optional

from super_gradients.common.abstractions.abstract_logger import get_logger
from super_gradients.common.sg_loggers.base_sg_logger import BaseSGLogger, EXPERIMENT_LOGS_PREFIX, LOGGER_LOGS_PREFIX, CONSOLE_LOGS_PREFIX
from super_gradients.common.environment.ddp_utils import multi_process_safe
from super_gradients.common.plugins.deci_client import DeciClient
from contextlib import redirect_stdout

logger = get_logger(__name__)

Expand Down Expand Up @@ -91,8 +94,7 @@ def _upload_latest_file_starting_with(self, start_with: str):
]

most_recent_file_path = max(files_path, key=os.path.getctime)
self.platform_client.save_experiment_file(file_path=most_recent_file_path)
logger.info(f"File saved to Deci platform: {most_recent_file_path}")
self._save_experiment_file(file_path=most_recent_file_path)

@multi_process_safe
def _upload_folder_files(self, folder_name: str):
Expand All @@ -107,5 +109,21 @@ def _upload_folder_files(self, folder_name: str):
return

for file in os.listdir(folder_path):
self.platform_client.save_experiment_file(file_path=f"{folder_path}/{file}")
logger.info(f"File saved to Deci platform: {folder_path}/{file}")
self._save_experiment_file(file_path=f"{folder_path}/{file}")

def _save_experiment_file(self, file_path: str):
with log_stdout(): # TODO: remove when platform_client remove prints from save_experiment_file
self.platform_client.save_experiment_file(file_path=file_path)
logger.info(f"File saved to Deci platform: {file_path}")


@contextmanager
def log_stdout():
"""Redirect stdout to DEBUG."""
buffer = io.StringIO()
with redirect_stdout(buffer):
yield

redirected_str = buffer.getvalue()
if redirected_str:
logger.debug(msg=redirected_str)

0 comments on commit 21fa8ae

Please sign in to comment.