Skip to content

Commit 746ecfe

Browse files
authored
fix: better error messages (#213)
1 parent db81c4c commit 746ecfe

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/anemoi/inference/provenance.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ def validate_environment(
158158

159159
if train_environment_version < inference_environment_version:
160160
invalid_messages["mismatch"].append(
161-
f"Version of module {module} was lower in training then in inference: {train_environment_version!s} <= {inference_environment_version!s}"
161+
f"Version of module {module} was lower in training than in inference: {train_environment_version!s} <= {inference_environment_version!s}"
162162
)
163163
elif train_environment_version > inference_environment_version:
164164
invalid_messages["critical mismatch"].append(
165-
f"CRITICAL: Version of module {module} was greater in training then in inference: {train_environment_version!s} > {inference_environment_version!s}"
165+
f"CRITICAL: Version of module {module} was greater in training than in inference: {train_environment_version!s} > {inference_environment_version!s}"
166166
)
167167

168168
for git_record in train_environment["git_versions"].keys():

src/anemoi/inference/runner.py

+2
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ def model(self) -> torch.nn.Module:
451451
try:
452452
model = torch.load(self.checkpoint.path, map_location=self.device, weights_only=False).to(self.device)
453453
except Exception as e: # Wildcard exception to catch all errors
454+
if self.report_error:
455+
self.checkpoint.report_error()
454456
validation_result = self.checkpoint.validate_environment(on_difference="return")
455457
error_msg = f"Error loading model - {validation_result}"
456458
raise RuntimeError(error_msg) from e

0 commit comments

Comments
 (0)