Skip to content

Commit

Permalink
Make wandb work again with pytorch_lightning.logger
Browse files Browse the repository at this point in the history
  • Loading branch information
khintz committed Oct 3, 2024
1 parent 0f30259 commit 3fbe2d0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion neural_lam/models/ar_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,16 @@ def aggregate_and_plot_metrics(self, metrics_dict, prefix):
)
)

# Ensure that log_dict has structure for logging as dict(str, plt.Figure)
assert all(
isinstance(key, str) and isinstance(value, plt.Figure)
for key, value in log_dict.items()
)

if self.trainer.is_global_zero and not self.trainer.sanity_checking:
self.logger.log_image(log_dict) # Log all
for key, figure in log_dict.items():
self.logger.log_image(key=key, images=[figure])

plt.close("all") # Close all figs

def on_test_epoch_end(self):
Expand Down

0 comments on commit 3fbe2d0

Please sign in to comment.