In this blog post I am going to show you how to use the powerful Semantic Link Labs library for Tabular Object Model (TOM) for semantic model manipulation.

The goal of this blog post is to give you an understanding of how to connect using TOM, then based on the documentation use one of the functions.

Don’t get me wrong the documentation is great, but when implementing it, it works a little differently and I want others to know how to use it, so it can automate and simplify some repetitive tasks.

This can be done using a Python notebook, which is very fast, as well as consuming very little capacity units.

Some of the tasks you can complete with Semantic Link Labs are:

  • Connecting to TOM
  • Show Incremental Refresh on Tables
  • Update Incremental Refresh policy
  • Add calculated columns
  • Managing metadata and more

You can reference the documentation here: sempy_labs.tom package — semantic-link-labs 0.11.3 documentation

Working Example

In this blog post I am first going to show you how to install Semantic Link Labs.

Then connect using TOM and show a list of tables in my semantic model.

And finally show the refresh policy on my table called “Order”

Installing Semantic Link Labs

The first step is to create my Python notebook and install semantic link labs.

I create my notebook and change it to be using Python as shown below.

Next, I install Semantic Link Labs with the code below.

A screenshot of a computer

AI-generated content may be incorrect.

NOTE: The reason for the -q is that it is quiet and I do not see any of the installation output.

Next, I put my semantic model’s name and workspace name into variables as shown below.

Connect to the Tabular Object Model and show the Incremental Refresh Policy

When I look at the documentation to show the incremental refresh policy it shows the following below.

A screenshot of a computer program

AI-generated content may be incorrect.

As shown above, while this is great documentation, if I try and run this in my notebook I get the following error.

A screenshot of a computer program

AI-generated content may be incorrect.

This can be rather confusing, especially for new users.

To get this working successfully as mentioned in the documentation, I first need to connect using TOM and then run the function.

To do this I did the following in my code cell below with details below.

A computer screen shot of a code

AI-generated content may be incorrect.

LINES 4-5

  • This is where I am importing Semantic Link Labs and the connect_semantic_model.

LINE 8

  • This is where I am putting my table name into a variable.

LINE 10

  • This is where I am connecting to the TOM using my dataset name and workspace name.
  • NOTE: You would need to use this each time you want to use the TOM functionality

LINE 11

  • I am first using the reference “tom” which has connected to the Tabular Object Model to my semantic model in the relevant app workspace.
  • I am then using the function “show_incremtnal_refresh_policy” and in order to get it to work instead of using the “:” I change it to “=” and put in my table variable name

I can then see this has run successfully with the output showing me the incremental refresh policy

A white background with black text

AI-generated content may be incorrect.

Summary

In this blog post I have shown you how to connect to the Tabular Object model using Semantic Link Labs and a Python notebook in Microsoft Fabric.

If there are any other Semantic Link Labs functions, you would like me to blog about please let me know in the comments section!

Here is a link to an example of the notebook I was using in this blog post: Fabric/BLOG – Show Table with IR Policy.ipynb at main · GilbertQue/Fabric

Thanks for reading.