Jai-Rathinavel's avatar
Jai-Rathinavel
Super User
11 months ago

Simplified Model Refresh Using Notebook Application

How cool would it be to refresh partitions of your semantic model the no-code way ?

 

The main goal is to provide a user-friendly "app" experience for data professionals to perform and monitor targeted refreshes of tables and partitions without leaving their Fabric Notebook. Yes the below app is rendered using a Notebook Cell !

 

App Demo

 

 

Please attach the lakehouse to your notebook before running the below codes

 

Python code starts..

%pip install semantic-link==0.11.2
%pip install semantic-link-labs==0.11.3
#Function to save the dependent utils files from my github repo to the lakehouse's resources section

def save_from_github(github_url: str,path:str,file_name: str, force: bool = False):
    """
    Downloads a file from GitHub and saves it under the mentioned path
    
    Args:
        url (str): The URL to download from (use raw.githubusercontent.com).
        file_name (str): The name of the file to save locally.
        force (bool): If True, always download and overwrite the file.
    """
    url = github_url.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/")
    dest_path = f"{path}{file_name}"
    file_exists = os.path.exists(dest_path)
    if file_exists and not force:
        print(f"❗'{file_name}' already exists. Skipping download.")
    os.makedirs(os.path.dirname(dest_path), exist_ok=True)
    response = requests.get(url)
    if response.status_code == 200:
        with open(dest_path, 'wb') as f:
            f.write(response.content)
        if file_exists & force:
            print(f"📝 Overwritten the existing '{file_name}' with the latest file.")
        elif not file_exists :
            print(f"📥 Downloaded and saved '{file_name}'.")
    else:
        print(f"🔴 Failed to download. Status: {response.status_code}, URL: {url}")
# Saves the "custom_utils.py" file from my repository to the Notebooks resources section 
# Use path as "./builtin/" to save file to notebook resources or "./" to save to notebook environment

save_from_github( github_url="https://github.com/jai-rathinavel/my-packages/blob/main/sempy/custom_utils.py",path="./",file_name='custom_utils.py',force=True)
#Importing all the functions and libraries from custom_utils.py file

from custom_utils import get_model_details, launch_enhanced_refresh_ui

#If saved to Notebook's resources run the below

#from builtin.custom_utils import get_model_details, launch_enhanced_refresh_ui
#Populating the dataframe

result_df = get_model_details(load_from_lakehouse=False,table_name='Model Details',only_premium_ws=True,workspace_list=['Financial Observations','Fabric Developers'])
#Launching the Application

launch_enhanced_refresh_ui(input_df=result_df)

#(Enable Visualize option to render the SSAS Trace output from sempy_labs package)

 

To get more details about the functions please refer my Github Notebook !

 

Core Frameworks Used: semantic-link, semantic-link-labs, ipywidgets

 

With my Notebook Application, you can:

  • Refresh partitions on demand without setting up a pipeline.

  • Works on Python Runtime.
  • Access and refresh models from any workspace you’re a member of.

  • Instantly view SSAS tracer output and a statistics DataFrame for better insights.

Features

      Interactive UI: A simple application interface built with ipywidgets for an intuitive user experience.

      Workspace & Model Discovery: Automatically fetches all accessible semantic models, tables, and partitions.

      Data Caching: Ability to save the model metadata to a Lakehouse table to speed up subsequent runs and avoid redundant API          calls.

      Granular Refreshes: Select specific workspaces, models, tables, and even individual partitions to refresh.

      Advanced Options: Configure advanced settings for each refresh operation, such as:

      Refresh Type, Retry Count, Max Parallelism, Commit Mode, Apply Refresh Policy

      Refresh Monitoring: Visualizes the SSAS trace output as a Gantt chart upon completion, showing the duration of each step.

 

Github Link: https://github.com/jai-rathinavel/Fabric-Notebooks/blob/main/Aug-2025-Contest/Model%20Refresh%20App%20Launcher.ipynb

Linkedin: https://www.linkedin.com/in/jai-rathinavel/

 

No RepliesBe the first to reply