Skip to content

Plugin

Bip Plugin class.

Attributes:

Name Type Description
logger Logger

Application logger. If the app has been executed with the sdk runner, the logger is handled by bip.mink.logs.

config dict

Plugin configuration dictionary, if the plugin descriptor defines a config template.

mapping dict

Plugin mapping dictionary, if the plugin descriptor defines a mapping template.

default_settings dict

Plugin default settings dictionary, if the plugin descriptor defines a setting template.

Parameters:

Name Type Description Default
plugin Plugin

Associated plugin data. It owns the config, mapping and any exposed parameter in the plugin descriptor.

required
logger Logger

Application logger. If the app has been executed with the sdk runner, the logger is handled by bip.mink.logs.

required
Source code in client/bip/sdk/_plugin.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def __init__(self, plugin, logger):
    """Initializes the plugin representation.

    Args:
        plugin (link.plugin.Plugin): Associated plugin data. It owns the config, mapping and any exposed parameter in the plugin descriptor.
        logger (logging.Logger): Application logger. If the app has been executed with the sdk runner, the logger is handled by `bip.mink.logs`.
    """
    if not self.slug or not isinstance(self.slug, str):
        raise ValueError('The class attribute "slug" (str) must be declared.')

    if not self.version or not isinstance(self.version, str):
        raise ValueError('The class attribute "version" (str) must be declared.')

    self._plugin = plugin
    self.config = deepcopy(plugin.config)
    self.default_settings = deepcopy(plugin.default_settings)
    self.mapping = deepcopy(plugin.mapping)
    self.dynamic_mapping = deepcopy(plugin.dynamic_mapping)
    self.name = plugin.name
    self.logger = logger

get_package_root() classmethod

Get the application package root.

Returns:

Name Type Description
Pathlib

package root.

Source code in client/bip/sdk/_plugin.py
46
47
48
49
50
51
52
53
54
55
56
@classmethod
def get_package_root(cls):
    """Get the application package root.

    Returns:
        Pathlib: package root.
    """
    file_ = inspect.getfile(cls)
    here = Path(file_).parent
    package_root = here.parent
    return package_root

get_plugin_descriptor() classmethod

Get the plugin descriptor.

Caution, this is the descriptor extracted from the file, not from the database plugin.

This method should only be used internally (it is used by the runner). If you need the raw descriptor, you should get it from the Plugin object associated with the application.

Returns:

Name Type Description
dict

raw plugin descriptor.

Source code in client/bip/sdk/_plugin.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@classmethod
def get_plugin_descriptor(cls):
    """Get the plugin descriptor.

    Caution, this is the descriptor extracted from the file, not from the database plugin.

    This method should only be used internally (it is used by the runner).
    If you need the raw descriptor, you should get it from the Plugin object associated with the application.

    Returns:
        dict: raw plugin descriptor.
    """
    package_root = cls.get_package_root()
    descriptor_path = package_root / "bip.yml"
    if not descriptor_path.exists():
        raise ValueError(f"Descriptor {descriptor_path} cannot be found.")

    return yaml.safe_load(open(descriptor_path))