Replies: 12 comments 16 replies
-
I'm not sure you are calling the function properly (even though I haven't seen your code). Here is the proper way to do this. Just enter in your semantic model name and workspace name in the corresponding parameters. You can also specify a measure or list of measures using the 'measure_name' parameter within the generate_measure_descriptions function. from sempy_labs.tom import connect_semantic_model
with connect_semantic_model(dataset='', workspace='', readonly=False) as tom:
tom.generate_measure_descriptions() |
Beta Was this translation helpful? Give feedback.
-
You need to run this on a paid F64 sku or higher. |
Beta Was this translation helpful? Give feedback.
-
Hmm, interesting. I'll have to check and get back to you - likely after the holidays. |
Beta Was this translation helpful? Give feedback.
-
This should be resolved in 0.9.0. |
Beta Was this translation helpful? Give feedback.
-
hi m-Kovalsky FabricHTTPException: 401 Unauthorized for url: https://msitapi.fabric.microsoft.com//explore/v202304/nl2nl/completions We are executing this in F256 capacity |
Beta Was this translation helpful? Give feedback.
-
Which region are you using? |
Beta Was this translation helpful? Give feedback.
-
West us
…On Wed, Apr 9, 2025, 11:46 PM m-kovalsky ***@***.***> wrote:
Which region are you using?
—
Reply to this email directly, view it on GitHub
<#383 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEYBVVI5TX2VKIEETT5FN32YYHS5AVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENZYG42DINY>
.
You are receiving this because you commented.Message ID:
<microsoft/semantic-link-labs/repo-discussions/383/comments/12787447@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Do you get this error immediately or after the function runs for some time? |
Beta Was this translation helpful? Give feedback.
-
So I tested for measures with double quotes and they work fine. Are you able to identify the measure which causes the issue? You can specify a measure or list of measures within the function’s parameter. Sharing the DAX of the problem measure would help a lot. |
Beta Was this translation helpful? Give feedback.
-
Could you try running this? It gets descriptions for 5 measures at a time. Before it runs the API to get the descriptions, it prints out the 5 measure names. Find the last printout of the measure names and within those you will find the culprit. Would then be great to see the DAX for those 5 measures (you can then run those 5 measures individually to find the specific culprit). from sempy_labs.tom import connect_semantic_model
import pandas as pd
from typing import Optional, List
import sempy_labs._icons as icons
dataset = ''
workspace = ''
with connect_semantic_model(dataset=dataset, workspace=workspace, readonly=True) as tom:
def generate_measure_descriptions(
measure_name: Optional[str | List[str]] = None,
max_batch_size: Optional[int] = 5,
) -> pd.DataFrame:
"""
Auto-generates descriptions for measures using an LLM. This function requires a paid F-sku (Fabric) of F64 or higher.
Setting the 'readonly' parameter in connect_semantic_model to True will allow you to see the auto-generated descriptions in a dataframe. Setting the 'readonly' parameter
to False will update the descriptions for the measures within the 'measure_name' parameter.
Parameters
----------
measure_name : str | List[str], default=None
The measure name (or a list of measure names).
Defaults to None which generates descriptions for all measures in the semantic model.
max_batch_size : int, default=5
Sets the max batch size for each API call.
Returns
-------
pandas.DataFrame
A pandas dataframe showing the updated measure(s) and their new description(s).
"""
df = pd.DataFrame(
columns=["Table Name", "Measure Name", "Expression", "Description"]
)
data = []
# import concurrent.futures
if measure_name is None:
measure_name = [m.Name for m in tom.all_measures()]
if isinstance(measure_name, str):
measure_name = [measure_name]
if len(measure_name) > max_batch_size:
measure_lists = [
measure_name[i : i + max_batch_size]
for i in range(0, len(measure_name), max_batch_size)
]
else:
measure_lists = [measure_name]
# Each API call can have a max of 5 measures
for measure_list in measure_lists:
payload = {
"scenarioDefinition": {
"generateModelItemDescriptions": {
"modelItems": [],
},
},
"workspaceId": tom._workspace_id,
"artifactInfo": {"artifactType": "SemanticModel"},
}
for m_name in measure_list:
expr, t_name = next(
(ms.Expression, ms.Parent.Name)
for ms in tom.all_measures()
if ms.Name == m_name
)
if t_name is None:
raise ValueError(
f"{icons.red_dot} The '{m_name}' measure does not exist in the '{tom._dataset_name}' semantic model within the '{tom._workspace_name}' workspace."
)
new_item = {
"urn": m_name,
"type": 1,
"name": m_name,
"expression": expr,
}
payload["scenarioDefinition"]["generateModelItemDescriptions"][
"modelItems"
].append(new_item)
print(measure_list)
response = _base_api(
request="/explore/v202304/nl2nl/completions",
method="post",
payload=payload,
)
for item in response.json().get("modelItems", []):
ms_name = item["urn"]
if ms_name.startswith("urn: "):
ms_name = ms_name[5:]
desc = item.get("description")
(table_name, expr) = next(
(m.Parent.Name, m.Expression)
for m in tom.all_measures()
if m.Name == ms_name
)
tom.model.Tables[table_name].Measures[ms_name].Description = desc
# Collect new descriptions in a dataframe
new_data = {
"Table Name": table_name,
"Measure Name": ms_name,
"Expression": expr,
"Description": desc,
}
data.append(new_data)
if data:
df = pd.concat([df, pd.DataFrame(data)], ignore_index=True)
return df
x = generate_measure_descriptions() |
Beta Was this translation helpful? Give feedback.
-
In msit
…On Mon, May 12, 2025, 1:03 AM m-kovalsky ***@***.***> wrote:
I cannot reproduce this error. I made a measure with essentially the same
code and it works just fine. In which environment are you running this
(prod/msit etc.)? And in which region?
image.png (view on web)
<https://github.com/user-attachments/assets/29f84800-f38a-47f0-b52a-1ec3476e6cf8>
—
Reply to this email directly, view it on GitHub
<#383 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEYBVTUSGVWCLEDH7YDQOL26BIWBAVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMJRGQ3DKNA>
.
You are receiving this because you commented.Message ID:
<microsoft/semantic-link-labs/repo-discussions/383/comments/13114654@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
In msit and west us
…On Mon, May 12, 2025, 1:59 PM sabarinathan R ***@***.***> wrote:
In msit
On Mon, May 12, 2025, 1:03 AM m-kovalsky ***@***.***> wrote:
> I cannot reproduce this error. I made a measure with essentially the same
> code and it works just fine. In which environment are you running this
> (prod/msit etc.)? And in which region?
>
> image.png (view on web)
> <https://github.com/user-attachments/assets/29f84800-f38a-47f0-b52a-1ec3476e6cf8>
>
> —
> Reply to this email directly, view it on GitHub
> <#383 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAEYBVTUSGVWCLEDH7YDQOL26BIWBAVCNFSM6AAAAABUETRAXCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMJRGQ3DKNA>
> .
> You are receiving this because you commented.Message ID:
> <microsoft/semantic-link-labs/repo-discussions/383/comments/13114654@
> github.com>
>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've firstly run the module "connect_semantic_model" in order to connect to a semantic model and being able to use TOM package.
After that, I've run the "labs.tom.TOMWrapper.generate_measure_descriptions" command but obtained this error:
TypeError: TOMWrapper.generate_measure_descriptions() missing 1 required positional argument: 'self'
What is the missing argument? Based on documentation, no argument is mandatory (measure_name and max_batch_size are optional)
Beta Was this translation helpful? Give feedback.
All reactions