Skip to content

Commit

Permalink
daxa-ai#514: use importlib to validate weasyprint install
Browse files Browse the repository at this point in the history
  • Loading branch information
aram yegiazaryan authored and srics committed Sep 1, 2024
1 parent c41ab04 commit 3bcddba
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions pebblo/app/config/config_validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.util
import logging
import os
import sys
Expand Down Expand Up @@ -112,13 +113,9 @@ def validate(self):

def validate_optional_weasyprint_dependency(self):
"""Check if WeasyPrint is installed"""
try:
from weasyprint import CSS, HTML
except ImportError:
error = """Could not import weasyprint package. Please install weasyprint and Pango to generate
report using weasyprint.
Follow documentation for more details - https://daxa-ai.github.io/pebblo/installation"
"""
if importlib.util.find_spec("weasyprint") is None:
error = """Error: `renderer: weasyprint` was specified, but weasyprint was not found.
Follow documentation for more details - https://daxa-ai.github.io/pebblo/installation"""
self.errors.append(error)

@staticmethod
Expand Down Expand Up @@ -152,7 +149,7 @@ def validate_config(config_dict):
"logging": LoggingConfig,
"reports": ReportsConfig,
"classifier": ClassifierConfig,
"storage": StorageConfig
"storage": StorageConfig,
}

validation_errors = []
Expand Down

0 comments on commit 3bcddba

Please sign in to comment.