Skip to content

Commit

Permalink
Avoid entry_points deprecation warning (#14052)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
Co-authored-by: Akihiro Nitta <nitta@akihironitta.com>
  • Loading branch information
3 people committed Aug 15, 2022
1 parent 5a955df commit 4f5e101
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/pytorch_lightning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Updated compatibility for LightningLite to run with the latest DeepSpeed 0.7.0 ([13967](https://github.com/Lightning-AI/lightning/pull/13967))


- Avoid `metadata.entry_points` deprecation warning on Python 3.10 ([#14052](https://github.com/Lightning-AI/lightning/pull/14052))


- Fixed epoch-end logging results not being reset after the end of the epoch ([#14061](https://github.com/Lightning-AI/lightning/pull/14061))


## [1.7.1] - 2022-08-09

### Fixed
Expand Down
11 changes: 8 additions & 3 deletions src/pytorch_lightning/trainer/connectors/callback_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from pytorch_lightning.callbacks.rich_model_summary import RichModelSummary
from pytorch_lightning.callbacks.timer import Timer
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from pytorch_lightning.utilities.imports import _PYTHON_GREATER_EQUAL_3_8_0
from pytorch_lightning.utilities.imports import _PYTHON_GREATER_EQUAL_3_8_0, _PYTHON_GREATER_EQUAL_3_10_0
from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation, rank_zero_info

_log = logging.getLogger(__name__)
Expand Down Expand Up @@ -256,14 +256,19 @@ def _configure_external_callbacks() -> List[Callback]:
Return:
A list of all callbacks collected from external factories.
"""
group = "pytorch_lightning.callbacks_factory"

if _PYTHON_GREATER_EQUAL_3_8_0:
from importlib.metadata import entry_points

factories = entry_points().get("pytorch_lightning.callbacks_factory", ())
if _PYTHON_GREATER_EQUAL_3_10_0:
factories = entry_points(group=group) # type: ignore[call-arg]
else:
factories = entry_points().get(group, {}) # type: ignore[assignment]
else:
from pkg_resources import iter_entry_points

factories = iter_entry_points("pytorch_lightning.callbacks_factory")
factories = iter_entry_points(group) # type: ignore[assignment]

external_callbacks = []
for factory in factories:
Expand Down

0 comments on commit 4f5e101

Please sign in to comment.