mirror of https://github.com/milvus-io/milvus.git
fix PluginBase import bug
parent
63997d55ec
commit
4c774a77f5
|
@ -1,9 +1,7 @@
|
|||
import os
|
||||
import logging
|
||||
from functools import partial
|
||||
# from pluginbase import PluginBase
|
||||
# import importlib
|
||||
from utils.pluginextension import MiPluginBase
|
||||
from utils.pluginextension import MiPluginBase as PluginBase
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -11,8 +9,8 @@ here = os.path.abspath(os.path.dirname(__file__))
|
|||
get_path = partial(os.path.join, here)
|
||||
|
||||
PLUGIN_PACKAGE_NAME = 'router.plugins'
|
||||
plugin_base = MiPluginBase(package=PLUGIN_PACKAGE_NAME,
|
||||
searchpath=[get_path('./plugins')])
|
||||
plugin_base = PluginBase(package=PLUGIN_PACKAGE_NAME,
|
||||
searchpath=[get_path('./plugins')])
|
||||
|
||||
|
||||
class RouterFactory(object):
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
import logging
|
||||
from functools import partial
|
||||
from pluginbase import PluginBase
|
||||
from utils.pluginextension import MiPluginBase as PluginBase
|
||||
# from pluginbase import PluginBase
|
||||
from tracer import Tracer
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import importlib
|
||||
import importlib.util
|
||||
from pluginbase import PluginBase, PluginSource
|
||||
|
||||
|
||||
class MiPluginSource(PluginSource):
|
||||
def load_plugin(self, name):
|
||||
if '.' in name:
|
||||
raise ImportError('Plugin names cannot contain dots.')
|
||||
with self:
|
||||
return importlib.import_module(self.base.package + '.' + name)
|
||||
plugin = super().load_plugin(name)
|
||||
spec = importlib.util.spec_from_file_location(self.base.package + '.' + name, plugin.__file__)
|
||||
plugin = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(plugin)
|
||||
return plugin
|
||||
|
||||
|
||||
class MiPluginBase(PluginBase):
|
||||
|
|
Loading…
Reference in New Issue