m-kovalsky / fabric_cat_tools

Supercharge your Microsoft Fabric development with the fabric_cat_tools library
MIT License
110 stars 15 forks source link

run_model_bpa - KeyError: 'To Cardinality' #6

Closed GilbertQue closed 6 months ago

GilbertQue commented 7 months ago

Hi there, thanks for your awesome tools.

I was trying to use the "run_model_bpa" and when I ran it I get the following error below. This is connecting to a DirectLake semantic model. It only has got a single table. I think it is failing because there are no relationships to traverse (I did try this on a semantic model which does have relationships and it works as expected)

`--------------------------------------------------------------------------- KeyError Traceback (most recent call last) File ~/cluster-env/trident_env/lib/python3.10/site-packages/pandas/core/indexes/base.py:3653, in Index.get_loc(self, key) 3652 try: -> 3653 return self._engine.get_loc(casted_key) 3654 except KeyError as err:

File ~/cluster-env/trident_env/lib/python3.10/site-packages/pandas/_libs/index.pyx:147, in pandas._libs.index.IndexEngine.get_loc()

File ~/cluster-env/trident_env/lib/python3.10/site-packages/pandas/_libs/index.pyx:176, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:7080, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:7088, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'To Cardinality'

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last) Cell In[25], line 2 1 import fabric_cat_tools as fct ----> 2 fct.run_model_bpa( 3 dataset = 'OneLake Storage Semantic Model' 4 # ,workspace = 'NYC-Taxi' 5 ,return_dataframe = True 6 )

File /nfs4/pyenv-ecefaf67-281f-4ba1-9ddb-c957bfa6b98a/lib/python3.10/site-packages/fabric_cat_tools/ModelBPA.py:394, in run_model_bpa(dataset, rules_dataframe, workspace, **kwargs) 391 dfP['Has Date Table'] = hasDateTable 393 # Set dims to dual mode --> 394 dfR_one = dfR[dfR['To Cardinality'] == 'One'] 395 dfTP = dfP_imp.groupby('Table Name')['Partition Name'].count().reset_index() 396 dfTP.rename(columns={'Partition Name': 'Import Partitions'}, inplace=True)

File ~/cluster-env/trident_env/lib/python3.10/site-packages/pandas/core/frame.py:3761, in DataFrame.getitem(self, key) 3759 if self.columns.nlevels > 1: 3760 return self._getitem_multilevel(key) -> 3761 indexer = self.columns.get_loc(key) 3762 if is_integer(indexer): 3763 indexer = [indexer]

File ~/cluster-env/trident_env/lib/python3.10/site-packages/pandas/core/indexes/base.py:3655, in Index.get_loc(self, key) 3653 return self._engine.get_loc(casted_key) 3654 except KeyError as err: -> 3655 raise KeyError(key) from err 3656 except TypeError: 3657 # If we have a listlike key, _check_indexing_error will raise 3658 # InvalidIndexError. Otherwise we fall through and re-raise 3659 # the TypeError. 3660 self._check_indexing_error(key)

KeyError: 'To Cardinality'`

m-kovalsky commented 7 months ago

Thanks for reporting. This will be fixed in the next version.

GilbertQue commented 7 months ago

Thank you!

m-kovalsky commented 6 months ago

This is resolved in 0.3.2