Skip to content

Commit

Permalink
catch error when aws credentials not set
Browse files Browse the repository at this point in the history
  • Loading branch information
khintz committed Dec 11, 2024
1 parent ae69f3f commit 6e16035
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions neural_lam/train_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Standard library
import json
import random
import sys
import time
from argparse import ArgumentParser

Expand Down Expand Up @@ -59,6 +60,7 @@ def log_image(self, key, images, step=None):
Step to log the image under. If None, logs under the key directly
"""
# Third-party
import botocore
from PIL import Image

if step is not None:
Expand All @@ -70,7 +72,11 @@ def log_image(self, key, images, step=None):
images[0].savefig(temporary_image)

img = Image.open(temporary_image)
mlflow.log_image(img, f"{key}.png")
try:
mlflow.log_image(img, f"{key}.png")
except botocore.exceptions.NoCredentialsError:
logger.error("Error logging image\nSet AWS credentials")
sys.exit(1)

def log_model(self, data_module, model):
input_example = self.create_input_example(data_module)
Expand Down Expand Up @@ -392,8 +398,8 @@ def main(input_args=None):
max_epochs=args.epochs,
deterministic=True,
strategy="ddp",
devices=4,
# devices=[1,2],
# devices=4,
devices=[0, 3],
# devices=[0, 1, 2],
# strategy="auto",
# devices=1, # For eval mode
Expand Down

0 comments on commit 6e16035

Please sign in to comment.