Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions rl4lms/envs/text_generation/logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from rich.logging import RichHandler


LOGGER = logging.getLogger(__name__)


class Tracker:
def __init__(self,
base_path_to_store_results: str,
Expand Down Expand Up @@ -76,9 +79,9 @@ def log_predictions(self, epoch: int,
# randomly display few predictions for logging
predictions_ = copy.deepcopy(predictions)
random.shuffle(predictions_)
logging.info(f"Split {split_name} predictions")
LOGGER.info(f"Split {split_name} predictions")
for pred in predictions_[:10]:
logging.info(pred)
LOGGER.info(pred)

# for wandb logging, we create a table consisting of predictions
# we can create one table per split per epoch
Expand Down Expand Up @@ -119,10 +122,10 @@ def log_metrics(self, epoch: int,
wandb.log(metric_dict_)

# logger
logging.info(f"{split_name} metrics: {metrics_dict_}")
LOGGER.info(f"{split_name} metrics: {metrics_dict_}")

def log_rollout_infos(self, rollout_info: Dict[str, float]):
logging.info(f"Rollout Info: {rollout_info}")
LOGGER.info(f"Rollout Info: {rollout_info}")
rollout_info_file = os.path.join(
self._run_path, "rollout_info.jsonl")
with jsonlines.open(rollout_info_file, mode="a") as writer:
Expand All @@ -133,7 +136,7 @@ def log_rollout_infos(self, rollout_info: Dict[str, float]):
wandb.log(rollout_info)

def log_training_infos(self, training_info: Dict[str, float]):
logging.info(f"Training Info: {training_info}")
LOGGER.info(f"Training Info: {training_info}")
training_info_file = os.path.join(
self._run_path, "training_info.jsonl")
with jsonlines.open(training_info_file, mode="a") as writer:
Expand All @@ -156,7 +159,7 @@ def checkpoint_base_path(self):
return os.path.join(self._run_path, "checkpoints")

def log_info(self, msg: str):
logging.info(msg)
LOGGER.info(msg)


if __name__ == "__main__":
Expand Down