PyTabular
PyTabular copied to clipboard
Issue in model documentation
Hi.. I'm not sure how useful this will be. I'm still digging to find out even what is causing this, or what is being pulled in as a "InferredPartitionSource" in my semantic model, so I'm not sure how I can help someone else to reproduce the issue. Everything that is working as expected is coming in as a "MPartitionSource" or "CalculatedPartitionSource".. I am getting this stack trace when attempting to generate documentation for some of our semantic models. If I can do anything to provide further info please let me know.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[6], line 2
1 docs = pytabular.ModelDocumenter(model)
----> 2 docs.generate_documentation_pages()
3 docs.save_documentation()
File c:\Users\kkemp\AppData\Local\Programs\Python\Python312\Lib\site-packages\pytabular\document.py:112, in ModelDocumenter.generate_documentation_pages(self)
110 """Generate Documentation for each specific part of the model."""
111 self.measure_page = self.generate_markdown_measure_page()
--> 112 self.table_page = self.generate_markdown_table_page()
113 self.general_page = self.generate_general_info_file()
File c:\Users\kkemp\AppData\Local\Programs\Python\Python312\Lib\site-packages\pytabular\document.py:464, in ModelDocumenter.generate_markdown_table_page(self)
447 """This function generates the markdown for table documentation.
448
449 Returns:
450 str: Will be appended to the page text.
451 """
452 markdown_template = [
453 "---",
454 "sidebar_position: 2",
(...)
461 f"# Tables {self.model.Name}",
462 ]
--> 464 markdown_template.extend(
465 self.create_markdown_for_table(table) for table in self.model.Tables
466 )
467 return "\n".join(markdown_template)
File c:\Users\kkemp\AppData\Local\Programs\Python\Python312\Lib\site-packages\pytabular\document.py:465, in <genexpr>(.0)
447 """This function generates the markdown for table documentation.
448
449 Returns:
450 str: Will be appended to the page text.
451 """
452 markdown_template = [
453 "---",
454 "sidebar_position: 2",
(...)
461 f"# Tables {self.model.Name}",
462 ]
464 markdown_template.extend(
--> 465 self.create_markdown_for_table(table) for table in self.model.Tables
466 )
467 return "\n".join(markdown_template)
File c:\Users\kkemp\AppData\Local\Programs\Python\Python312\Lib\site-packages\pytabular\document.py:429, in ModelDocumenter.create_markdown_for_table(self, object)
427 else:
428 partition_type = "sql"
--> 429 partition_source = object.Partitions[0].Source.Query
431 obj_text = [
432 f"### {object_caption}",
433 "**Description**: ",
(...)
441 "---",
442 ]
444 return "\n".join(obj_text)
AttributeError: 'InferredPartitionSource' object has no attribute 'Query'
For now, to achieve what I was trying to achieve locally, I change my code to exclude things where table.IsHidden
Hi,
Maybe I can help you with this. We still have to fix this, if it isn't already.
I am having the same issue with a Direct Lake model. I think it is due to this code assuming SQL. It looks to me that SourceType is "Entity" with direct lake and there is no query.
if str(object.Partitions[0].SourceType) == "Calculated": partition_type = "dax" partition_source = object.Partitions[0].Source.Expression elif str(object.Partitions[0].SourceType) == "M": partition_type = "powerquery" partition_source = object.Partitions[0].Source.Expression elif str(object.Partitions[0].SourceType) == "CalculationGroup": partition_type = "" partition_source = "" else: partition_type = "sql" partition_source = object.Partitions[0].Source.Query
@kevarnold972 I think you are on the money: Partition Source Types
We need to make sure to account for every possible type of partition:
Depending on the partition type, accessing the actual query or source can be different in the model. Old legacy partitions are partition.Source.Query, Calc groups, & M are partition.Source.Expression. Looks like Entity might be partition.ExpressionSource. Would need to play around with it.
Side note: It's probably time to beef up my little local adventure works pbix file and use a specific set of semantic models in Fabric for the testing.