Skip to content

Commit b94dcb2

Browse files
committed
replace exempt_from_compat_check for/in favor of internal_ap
Signed-off-by: Pablo Garay <[email protected]>
1 parent f951ab2 commit b94dcb2

File tree

2 files changed

+17
-33
lines changed

2 files changed

+17
-33
lines changed

megatron/core/utils.py

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,31 +2159,6 @@ async def wrapper(*args, **kwargs):
21592159
# ============================================================================
21602160

21612161

2162-
def exempt_from_compat_check(func: Callable) -> Callable:
2163-
"""
2164-
Mark a function as exempt from backward compatibility checks.
2165-
2166-
Use this decorator for:
2167-
- Internal APIs not intended for external use
2168-
- Experimental features that may change
2169-
- Functions explicitly documented as unstable
2170-
2171-
Args:
2172-
func: The function to mark as exempt
2173-
2174-
Returns:
2175-
The original function with an exemption marker
2176-
2177-
Example:
2178-
@exempt_from_compat_check
2179-
def experimental_api():
2180-
'''This API may change without notice'''
2181-
pass
2182-
"""
2183-
func._exempt_from_compat_check = True
2184-
return func
2185-
2186-
21872162
def deprecated(
21882163
version: str,
21892164
removal_version: Optional[str] = None,
@@ -2254,23 +2229,32 @@ def wrapper(*args, **kwargs):
22542229

22552230
def internal_api(func: Callable) -> Callable:
22562231
"""
2257-
Mark a function as internal API (not for external use).
2232+
Mark a function or class as internal API (not for external use).
2233+
2234+
Use this decorator for:
2235+
- Internal APIs not intended for public consumption
2236+
- Experimental features that may change without notice
2237+
- Implementation details that are not part of the stable API
22582238
2259-
This is semantically similar to exempt_from_compat_check but
2260-
more explicitly communicates that the function is internal.
2239+
Objects marked with this decorator will be exempt from backward
2240+
compatibility checks.
22612241
22622242
Args:
2263-
func: The function to mark as internal
2243+
func: The function or class to mark as internal
22642244
22652245
Returns:
2266-
The original function with an internal API marker
2246+
The original function/class with an internal API marker
22672247
22682248
Example:
22692249
@internal_api
22702250
def _internal_helper():
22712251
'''For internal use only'''
22722252
pass
2253+
2254+
@internal_api
2255+
class ExperimentalFeature:
2256+
'''This API may change without notice'''
2257+
pass
22732258
"""
22742259
func._internal_api = True
2275-
func._exempt_from_compat_check = True # Also exempt from checks
22762260
return func

scripts/check_api_backwards_compatibility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Megatron Core API Compatibility Checker
44
55
Simple checker using Griffe to find breaking changes between two versions.
6-
Objects decorated with @exempt_from_compat_check are excluded from checks.
6+
Objects decorated with @internal_api or @deprecated are excluded from checks.
77
88
Usage:
99
python scripts/check_api_backwards_compatibility.py --baseline core_v0.14.0
@@ -43,7 +43,7 @@
4343

4444

4545
# Decorators that exempt objects from compatibility checks
46-
EXEMPT_DECORATORS = ['exempt_from_compat_check', 'deprecated', 'internal_api']
46+
EXEMPT_DECORATORS = ['internal_api', 'deprecated']
4747

4848

4949
def has_exempt_decorator(obj: Object) -> bool:

0 commit comments

Comments
 (0)