From 74f762af1a37c5387c6ba869d52f201d56288a8b Mon Sep 17 00:00:00 2001 From: Tai An Date: Sun, 6 Sep 2026 06:14:55 -0700 Subject: [PATCH] fix(util): import MetaflowInternalError in read_artifacts_module `read_artifacts_module` raises `MetaflowInternalError` on both of its error paths, but never imports it, so every failure surfaces as `NameError: name 'MetaflowInternalError' is not defined` instead. The function is reached from `spin-step --artifacts-module`, so a bad path or a module without an `ARTIFACTS` variable hits it. Add the deferred import, matching `compress_list` in the same file (the import is function-local there to avoid a circular import with metaflow.exception). --- metaflow/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metaflow/util.py b/metaflow/util.py index 8f310a63236..4cc96d8b0cf 100644 --- a/metaflow/util.py +++ b/metaflow/util.py @@ -611,6 +611,8 @@ def read_artifacts_module(file_path: str) -> Dict[str, Any]: import importlib.util import os + from metaflow.exception import MetaflowInternalError + try: module_name = os.path.splitext(os.path.basename(file_path))[0] spec = importlib.util.spec_from_file_location(module_name, file_path)