File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -307,16 +307,18 @@ def wrapped(*args, **kwargs):
307307 @classmethod
308308 def register_plugin_entry_point (cls , entry_point , modifier = identity ):
309309 def stub (* args , ** kwargs ):
310+ """ Entrypoints-based streamz plugin. Will be loaded on first call. """
310311 node = entry_point .load ()
311312 if not issubclass (node , Stream ):
312313 raise TypeError (
313314 f"Error loading { entry_point .name } "
314315 f"from module { entry_point .module_name } : "
315316 f"{ node .__class__ .__name__ } must be a subclass of Stream"
316317 )
317- cls .register_api (
318- modifier = modifier , attribute_name = entry_point .name
319- )(node )
318+ if getattr (cls , entry_point .name ).__name__ == "stub" :
319+ cls .register_api (
320+ modifier = modifier , attribute_name = entry_point .name
321+ )(node )
320322 return node (* args , ** kwargs )
321323 cls .register_api (modifier = modifier , attribute_name = entry_point .name )(stub )
322324
Original file line number Diff line number Diff line change 1+ import inspect
2+
13import pytest
24from streamz import Source , Stream
35
@@ -31,16 +33,12 @@ def test_register_plugin_entry_point_modifier():
3133 class test_source (Source ):
3234 pass
3335
34- def modifier (fn ):
35- fn .__name__ = 'modified_name'
36- return staticmethod (fn )
37-
3836 entry_point = MockEntryPoint ("from_test" , test_source )
39- Stream .register_plugin_entry_point (entry_point , modifier )
37+ Stream .register_plugin_entry_point (entry_point , staticmethod )
4038
4139 Stream .from_test ()
4240
43- assert Stream .from_test . __name__ == "modified_name"
41+ assert inspect . isfunction ( Stream () .from_test )
4442
4543
4644def test_register_plugin_entry_point_raises ():
@@ -53,17 +51,3 @@ class invalid_node:
5351
5452 with pytest .raises (TypeError ):
5553 Stream .test ()
56-
57-
58- def test_register_plugin_entry_point_already_registered ():
59- @Stream .register_api ()
60- class test (Stream ):
61- pass
62-
63- entry_point = MockEntryPoint ("test_double" , test , "test_module" )
64-
65- Stream .register_plugin_entry_point (entry_point )
66-
67- assert Stream .test_double .__name__ == "stub"
68- Stream .test_double ()
69- assert Stream .test_double .__name__ == "test"
You can’t perform that action at this time.
0 commit comments