Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "ValidMind Library"
license = "Commercial License"
name = "validmind"
readme = "README.pypi.md"
version = "2.8.9"
version = "2.8.10"

[tool.poetry.dependencies]
python = ">=3.8.1,<3.12"
Expand Down
2 changes: 1 addition & 1 deletion validmind/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.8.9"
__version__ = "2.8.10"
45 changes: 43 additions & 2 deletions validmind/vm_models/result/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class TestResult(Result):
metadata: Optional[Dict[str, Any]] = None
_was_description_generated: bool = False
_unsafe: bool = False
_client_config_cache: Optional[Any] = None

def __post_init__(self):
if self.ref_id is None:
Expand Down Expand Up @@ -329,13 +330,50 @@ def to_widget(self):

return VBox(widgets)

@classmethod
def _get_client_config(cls):
"""Get the client config, loading it if not cached"""
if cls._client_config_cache is None:
api_client.reload()
cls._client_config_cache = api_client.client_config

if cls._client_config_cache is None:
raise ValueError(
"Failed to load client config: api_client.client_config is None"
)

if not hasattr(cls._client_config_cache, "documentation_template"):
raise ValueError(
"Invalid client config: missing documentation_template"
)

return cls._client_config_cache

def check_result_id_exist(self):
"""Check if the result_id exists in any test block across all sections"""
client_config = self._get_client_config()

# Iterate through all sections
for section in client_config.documentation_template["sections"]:
blocks = section.get("contents", [])
# Check each block in the section
for block in blocks:
if (
block.get("content_type") == "test"
and block.get("content_id") == self.result_id
):
return

logger.info(
f"Test driven block with result_id {self.result_id} does not exist in model's document"
)

def _validate_section_id_for_block(
self, section_id: str, position: Union[int, None] = None
):
"""Validate the section_id exits on the template before logging"""
api_client.reload()
client_config = self._get_client_config()
found = False
client_config = api_client.client_config

for section in client_config.documentation_template["sections"]:
if section["id"] == section_id:
Expand Down Expand Up @@ -440,6 +478,9 @@ def log(self, section_id: str = None, position: int = None, unsafe: bool = False
unsafe (bool): If True, log the result even if it contains sensitive data
i.e. raw data from input datasets
"""

self.check_result_id_exist()

if not unsafe:
for table in self.tables or []:
check_for_sensitive_data(table.data, self._get_flat_inputs())
Expand Down