Skip to content

Index

LoggingSettings

Bases: BaseSettings

This class defines the logging settings of the nessy Framework.

Attributes:

Name Type Description
target_log_analytics bool

Whether to log to Azure Log Analytics.

target_unity_catalog_table bool

Whether to log to the Unity Catalog Table.

log_analytics_workspace_id str | None

The workspace ID for Azure Log Analytics.

log_analytics_shared_key str | None

The shared key for Azure Log Analytics.

uc_workspace_url AnyUrl | None

The workspace URL for the Unity Catalog Table.

uc_warehouse_id str | None

The warehouse ID for the Unity Catalog Table.

uc_catalog_name str | None

The catalog name for the Unity Catalog Table.

uc_schema_name str | None

The schema name for the Unity Catalog Table.

log_level_console int

The log level for the console logger.

log_level_tabular int

The log level for the tabular logger.

log_format_console str

The format of the console logger.

Source code in src/cloe_nessy/settings/settings.py
class LoggingSettings(BaseSettings):
    """This class defines the logging settings of the nessy Framework.

    Attributes:
        target_log_analytics: Whether to log to Azure Log Analytics.
        target_unity_catalog_table: Whether to log to the Unity Catalog Table.
        log_analytics_workspace_id: The workspace ID for Azure Log Analytics.
        log_analytics_shared_key: The shared key for Azure Log Analytics.
        uc_workspace_url: The workspace URL for the Unity Catalog Table.
        uc_warehouse_id: The warehouse ID for the Unity Catalog Table.
        uc_catalog_name: The catalog name for the Unity Catalog Table.
        uc_schema_name: The schema name for the Unity Catalog Table.
        log_level_console: The log level for the console logger.
        log_level_tabular: The log level for the tabular logger.
        log_format_console: The format of the console logger.
    """

    model_config = SettingsConfigDict(env_prefix="nessy_")

    target_log_analytics: bool = Field(default=False)
    target_unity_catalog_table: bool = Field(default=False)

    log_analytics_workspace_id: str | None = Field(default=None)
    log_analytics_shared_key: str | None = Field(default=None)
    # log_type is not implement on purpose, because separate loggers will
    # require different schemas, that can't be in the same table

    uc_workspace_url: AnyUrl | None = Field(default=None)
    uc_warehouse_id: str | None = Field(default=None)
    uc_catalog_name: str | None = Field(default=None)
    uc_schema_name: str | None = Field(default=None)
    # table is not implement on purpose, because separate logger will require
    # different schemas, that can't be in the same table

    log_level_console: int = Field(default=logging.INFO)
    log_level_tabular: int = Field(default=logging.INFO)

    log_format_console: str = "%(asctime)s - %(message)s"

    @model_validator(mode="before")
    def _convert_log_levels(cls, settings):
        """Convert the log levels to integers."""
        settings["log_level_console"] = get_log_level(settings.get("log_level_console", logging.INFO))
        settings["log_level_tabular"] = get_log_level(settings.get("log_level_tabular", logging.INFO))
        return settings

    @model_validator(mode="after")
    def _validate_log_analytics_settings(cls, settings):
        if settings.target_log_analytics is True:
            if not settings.log_analytics_workspace_id or not settings.log_analytics_shared_key:
                raise ValueError(
                    "`NESSY_LOG_ANALYTICS_WORKSPACE_ID` and `NESSY_LOG_ANALYTICS_SHARED_KEY` environment variables must be set if `NESSY_LOG_TO_LOG_ANALYTICS_WORKSPACE` is set to true."
                )
        return settings

_convert_log_levels(settings)

Convert the log levels to integers.

Source code in src/cloe_nessy/settings/settings.py
@model_validator(mode="before")
def _convert_log_levels(cls, settings):
    """Convert the log levels to integers."""
    settings["log_level_console"] = get_log_level(settings.get("log_level_console", logging.INFO))
    settings["log_level_tabular"] = get_log_level(settings.get("log_level_tabular", logging.INFO))
    return settings

NessySettings

Bases: BaseSettings

This class defines the settings of the nessy Framework.

Attributes:

Name Type Description
logging LoggingSettings

The logging settings of the nessy Framework.

Source code in src/cloe_nessy/settings/settings.py
class NessySettings(BaseSettings):
    """This class defines the settings of the nessy Framework.

    Attributes:
        logging: The logging settings of the nessy Framework.
    """

    model_config = SettingsConfigDict(env_prefix="nessy_")

    logging: LoggingSettings = Field(default_factory=LoggingSettings)