Skip to content

Commit dd2912a

Browse files
authored
Remove legacy version check for lightning_utilities >= 0.10 (#20823)
1 parent 3b37c3e commit dd2912a

File tree

3 files changed

+3
-35
lines changed

3 files changed

+3
-35
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ node_modules/
198198
**/events.out.tfevents.*
199199
examples/**/*.png
200200

201-
# instalation artifacts
201+
# installation artifacts
202202
requirements/base.txt
203203

204204
# CI

src/lightning/fabric/utilities/imports.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,3 @@
3737
_TORCH_LESS_EQUAL_2_6 = compare_version("torch", operator.le, "2.6.0")
3838

3939
_PYTHON_GREATER_EQUAL_3_10_0 = (sys.version_info.major, sys.version_info.minor) >= (3, 10)
40-
41-
_UTILITIES_GREATER_EQUAL_0_10 = compare_version("lightning_utilities", operator.ge, "0.10.0")

src/lightning/fabric/utilities/rank_zero.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
import logging
1717
import os
18-
from functools import wraps
19-
from typing import Callable, Optional, TypeVar, overload
18+
from typing import Optional
2019

2120
import lightning_utilities.core.rank_zero as rank_zero_module
2221

@@ -29,9 +28,6 @@
2928
rank_zero_info,
3029
rank_zero_warn,
3130
)
32-
from typing_extensions import ParamSpec
33-
34-
from lightning.fabric.utilities.imports import _UTILITIES_GREATER_EQUAL_0_10
3531

3632
rank_zero_module.log = logging.getLogger(__name__)
3733

@@ -48,33 +44,7 @@ def _get_rank() -> Optional[int]:
4844
return None
4945

5046

51-
if not _UTILITIES_GREATER_EQUAL_0_10:
52-
T = TypeVar("T")
53-
P = ParamSpec("P")
54-
55-
@overload
56-
def rank_zero_only(fn: Callable[P, T]) -> Callable[P, Optional[T]]:
57-
"""Rank zero only."""
58-
59-
@overload
60-
def rank_zero_only(fn: Callable[P, T], default: T) -> Callable[P, T]:
61-
"""Rank zero only."""
62-
63-
def rank_zero_only(fn: Callable[P, T], default: Optional[T] = None) -> Callable[P, Optional[T]]:
64-
@wraps(fn)
65-
def wrapped_fn(*args: P.args, **kwargs: P.kwargs) -> Optional[T]:
66-
rank = getattr(rank_zero_only, "rank", None)
67-
if rank is None:
68-
raise RuntimeError("The `rank_zero_only.rank` needs to be set before use")
69-
if rank == 0:
70-
return fn(*args, **kwargs)
71-
return default
72-
73-
return wrapped_fn
74-
75-
rank_zero_module.rank_zero_only.rank = getattr(rank_zero_module.rank_zero_only, "rank", _get_rank() or 0)
76-
else:
77-
rank_zero_only = rank_zero_module.rank_zero_only
47+
rank_zero_only = rank_zero_module.rank_zero_only
7848

7949
# add the attribute to the function but don't overwrite in case Trainer has already set it
8050
rank_zero_only.rank = getattr(rank_zero_only, "rank", _get_rank() or 0)

0 commit comments

Comments
 (0)