Skip to content

Commit

Permalink
Enable plugin loading in prefect module init (PrefectHQ#8569)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpeden committed Feb 17, 2023
1 parent 0fb5a77 commit f121cb4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/prefect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
# Ensure collections are imported and have the opportunity to register types
import prefect.plugins

# prefect.plugins.load_prefect_collections()
# prefect.plugins.load_extra_entrypoints()
prefect.plugins.load_prefect_collections()
prefect.plugins.load_extra_entrypoints()

# Configure logging
import prefect.logging.configuration
Expand Down
19 changes: 19 additions & 0 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import importlib
import pathlib
import textwrap
from unittest.mock import Mock

import pytest

import prefect
from prefect.plugins import load_extra_entrypoints
from prefect.settings import PREFECT_EXTRA_ENTRYPOINTS, temporary_settings
from prefect.testing.utilities import exceptions_equal
Expand Down Expand Up @@ -236,3 +238,20 @@ def test_load_extra_entrypoints_missing_attribute(capsys):
"Warning! Failed to load extra entrypoint 'test_module_name:missing_attr': "
"AttributeError"
) in stderr


def test_plugins_load_on_prefect_package_init(monkeypatch):
mock_load_prefect_collections = Mock()
mock_load_extra_entrypoints = Mock()

monkeypatch.setattr(
prefect.plugins, "load_prefect_collections", mock_load_prefect_collections
)
monkeypatch.setattr(
prefect.plugins, "load_extra_entrypoints", mock_load_extra_entrypoints
)

importlib.reload(prefect)

mock_load_prefect_collections.assert_called_once()
mock_load_extra_entrypoints.assert_called_once()

0 comments on commit f121cb4

Please sign in to comment.