Skip to content

Commit

Permalink
make mlflow use same experiment run id as pl.logger.MLFlowLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
khintz committed Oct 7, 2024
1 parent e0284a8 commit 7eed79b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion neural_lam/train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def log_image(self, key, images):
import mlflow
import io
from PIL import Image

# Retrieve the active run ID from the logger
run_id = self.run_id
# Ensure mlflow uses the same run
mlflow.start_run(run_id=run_id)

# Need to save the image to a temporary file, then log that file
# mlflow.log_image, should do this automatically, but it doesn't work
temporary_image = f"{key}.png"
Expand All @@ -39,6 +45,7 @@ def log_image(self, key, images):
mlflow.log_image(img, f"{key}.png")

#mlflow.log_figure(images[0], key)
mlflow.end_run()


def _setup_training_logger(config, datastore, args, run_name):
Expand Down Expand Up @@ -346,7 +353,7 @@ def main(input_args=None):
deterministic=True,
#strategy="ddp",
#devices=2,
devices=[1, 3],
devices=[0, 1],
strategy="auto",
accelerator=device_name,
logger=training_logger,
Expand Down

0 comments on commit 7eed79b

Please sign in to comment.