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 metrics_layer/core/model/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def collect_errors(self):
)

# This value is pulled from the VIEW_DESCRIPTION_MAX_CHARS constant in Zenlytic
topic_description_max_chars = 2048
topic_description_max_chars = 10000
if "description" in self._definition:
if not isinstance(self.description, str):
errors.append(
Expand Down
26 changes: 25 additions & 1 deletion metrics_layer/core/model/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class View(MetricsLayerBase, SQLReplacement):
"model_name",
"label",
"description",
"zoe_description",
"hidden",
"sql_table_name",
"derived_table",
Expand Down Expand Up @@ -387,7 +388,7 @@ def collect_errors(self, metrics_must_have_dates: bool = True):
)

# This value is pulled from the VIEW_DESCRIPTION_MAX_CHARS constant in Zenlytic
view_description_max_chars = 2048
view_description_max_chars = 10000
if "description" in self._definition and isinstance(self.description, str):
if len(self.description) > view_description_max_chars:
errors.append(
Expand All @@ -401,6 +402,29 @@ def collect_errors(self, metrics_must_have_dates: bool = True):
),
)
)
if "zoe_description" in self._definition and not isinstance(self.zoe_description, str):
errors.append(
self._error(
self._definition["zoe_description"],
(
f"View {self.name} has an invalid zoe_description"
f" {self.zoe_description}. zoe_description must be a string."
),
)
)
if "zoe_description" in self._definition and isinstance(self.zoe_description, str):
if len(self.zoe_description) > view_description_max_chars:
errors.append(
self._error(
self._definition["zoe_description"],
(
f"Warning: View {self.name} has a zoe_description that is too long"
f" ({len(self.zoe_description)} characters). Descriptions must be"
f" {view_description_max_chars} characters or less. It will be truncated to the"
f" first {view_description_max_chars} characters."
),
)
)
if "hidden" in self._definition and not isinstance(self._definition.get("hidden", False), bool):
errors.append(
self._error(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metrics_layer"
version = "0.16.33"
version = "0.16.34"
description = "The open source metrics layer."
authors = ["Paul Blankley <paul@zenlytic.com>"]
keywords = ["Metrics Layer", "Business Intelligence", "Analytics"]
Expand Down
47 changes: 40 additions & 7 deletions tests/test_project_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,10 +1340,32 @@ def test_validation_with_replaced_model_properties(connection, name, value, erro
"Eleventh, this is a really long description aimed at testing the warning on the length of "
" description, so I will keep writing more content to make sure I get to the maximum length"
),
[],
),
(
"description",
"x" * 10001,
[
"Warning: View order_lines has a description that is too long (10001 characters)."
" Descriptions must be 10000 characters or less. It will be truncated to the "
"first 10000 characters."
],
),
(
"zoe_description",
None,
[
"View order_lines has an invalid zoe_description None. zoe_description must be a string."
],
),
("zoe_description", "My View Zoe Description", []),
(
"zoe_description",
"x" * 10001,
[
"Warning: View order_lines has a description that is too long (2769 characters)."
" Descriptions must be 2048 characters or less. It will be truncated to the "
"first 2048 characters."
"Warning: View order_lines has a zoe_description that is too long (10001 characters)."
" Descriptions must be 10000 characters or less. It will be truncated to the "
"first 10000 characters."
],
),
],
Expand Down Expand Up @@ -2984,11 +3006,22 @@ def test_validation_with_replaced_field_properties(connection, field_name, prope
"Tenth, this is a really long description aimed at testing the warning on the length of the"
" description, so I will keep writing more content to make sure I get to the maximum length"
),
[],
),
(
"description",
"x" * 10001,
[
(
"Warning: The description property, must be 2048 characters or less in the topic Order"
" lines Topic"
),
"Warning: The description property, must be 10000 characters or less in the topic Order"
" lines Topic"
],
),
(
"zoe_description",
"x" * 10001,
[
"Warning: The zoe_description property, must be 10000 characters or less in the topic Order"
" lines Topic"
],
),
(
Expand Down
Loading