Skip to content

main ¤

Nendo core main class.

Nendo ¤

Nendo(
    config: Optional[NendoConfig] = None,
    plugins: Optional[List[str]] = None,
    logger: Optional[Logger] = None,
)

Main class that runs nendo core.

Parameters:

Name Type Description Default
config NendoConfig

Custom settings to apply to this instance.

None
plugins str

list of plugins to load. Defaults to None.

None
logger Logger

Logger to use. Defaults to none.

None
Source code in src/nendo/main.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    config: Optional[NendoConfig] = None,
    plugins: Optional[List[str]] = None,
    logger: Optional[logging.Logger] = None,
) -> None:
    """Create a new nendo instance.

    Args:
        config (NendoConfig, optional): Custom settings to apply to this instance.
        plugins (str, optional): list of plugins to load. Defaults to None.
        logger (logging.Logger, optional): Logger to use. Defaults to none.
    """
    if hasattr(self, "_initialized") and self._initialized:
        return
    self.logger = logger or nendo_logger
    self.config = config or settings
    self.plugins = schema.NendoPluginRegistry()
    plugin_names = plugins or self.config.plugins
    if self.config.log_file_path == "":
        logging.basicConfig(
            level=self.config.log_level.upper(),
            datefmt="%Y-%m-%dT%H:%M:%S",
            format=log_fmt,
        )
    else:
        if (
            not os.path.isdir(os.path.dirname(self.config.log_file_path))
            or os.path.basename(self.config.log_file_path) == ""
        ):
            self.logger.error(
                "Config var log_file_path has been set but path is not "
                "valid or no filename specified. Please fix your configuration.",
            )
            sys.exit(-1)
        logging.basicConfig(
            filename=self.config.log_file_path,
            level=self.config.log_level.upper(),
            datefmt="%Y-%m-%dT%H:%M:%S",
            format=log_fmt,
        )
    self._load_plugins(plugin_names=plugin_names)
    # initialize nendo library
    if self.config.library_plugin == "default":
        self.logger.info("Using DuckDBLibrary")
        self.library = lib.DuckDBLibrary(
            nendo_instance=self,
            config=self.config,
            logger=self.logger,
            plugin_name="DuckDBLibrary",
            plugin_version="0.1.1",
        )
    else:
        self.logger.info(f"Loading {self.config.library_plugin}")
        self.library = self._load_plugin(module_name=self.config.library_plugin)
    self._initialized = True

get_nendo cached ¤

get_nendo()

Get the nendo instance singledton, cached.

Source code in src/nendo/main.py
162
163
164
165
@lru_cache()
def get_nendo():
    """Get the nendo instance singledton, cached."""
    return Nendo()