diff --git a/metrics_layer/core/model/topic.py b/metrics_layer/core/model/topic.py index c1c0c56..20f6bfe 100644 --- a/metrics_layer/core/model/topic.py +++ b/metrics_layer/core/model/topic.py @@ -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( diff --git a/metrics_layer/core/model/view.py b/metrics_layer/core/model/view.py index 9ec33ec..db5fc31 100644 --- a/metrics_layer/core/model/view.py +++ b/metrics_layer/core/model/view.py @@ -32,6 +32,7 @@ class View(MetricsLayerBase, SQLReplacement): "model_name", "label", "description", + "zoe_description", "hidden", "sql_table_name", "derived_table", @@ -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( @@ -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( diff --git a/pyproject.toml b/pyproject.toml index 2950153..ff9a91a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] keywords = ["Metrics Layer", "Business Intelligence", "Analytics"] diff --git a/tests/test_project_validation.py b/tests/test_project_validation.py index 38f0ecb..a5b17bb 100644 --- a/tests/test_project_validation.py +++ b/tests/test_project_validation.py @@ -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." ], ), ], @@ -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" ], ), (