Skip to content

Commit 2527a9b

Browse files
committed
refactor: log removed-module guidance at debug, not warning
The raised ModuleNotFoundError is the loud, authoritative signal (it stops execution and carries the full message with the v3 replacement + migration link). Logging the same message at WARNING duplicated it noisily on a path that always raises. Downgrade the logger call to debug in both raise_removed_in_v3 (tombstones) and the fallback finder (catch-all), leaving a breadcrumb for log-captured environments without the noise. The DeprecationWarning and the raise are unchanged.
1 parent b642f20 commit 2527a9b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎sagemaker-core/src/sagemaker/core/deprecations.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ def raise_removed_in_v3(module, replacement=None, v3_import=None):
6262
msg += f"\nSee {V3_MIGRATION_URL} for the migration guide."
6363

6464
warnings.warn(msg, DeprecationWarning, stacklevel=2)
65-
logger.warning(msg)
65+
# The raised ModuleNotFoundError below is the loud, authoritative signal
66+
# (it stops execution and carries the full message). Log at debug only, to
67+
# leave a breadcrumb for log-captured environments without duplicating the
68+
# message at WARNING level.
69+
logger.debug(msg)
6670
raise ModuleNotFoundError(msg, name=module)
6771

6872

@@ -99,7 +103,9 @@ def find_spec(self, fullname, path=None, target=None):
99103
f"\nSee {V3_MIGRATION_URL} for the migration guide."
100104
)
101105
warnings.warn(msg, DeprecationWarning, stacklevel=2)
102-
logger.warning(msg)
106+
# See raise_removed_in_v3: the raised error is the loud signal; log at
107+
# debug to avoid duplicating the message at WARNING level.
108+
logger.debug(msg)
103109
raise ModuleNotFoundError(msg, name=fullname)
104110

105111

0 commit comments

Comments
 (0)