{"id":6454,"library":"semantic-link","title":"Semantic Link (SemPy)","description":"Semantic Link, also known by its core Python library SemPy, facilitates seamless collaboration between data scientists and business analysts within Microsoft Fabric. It enables Python and Spark users in Synapse Data Science notebooks to connect directly to Power BI semantic models, access their underlying data, measures, and rich semantic information, eliminating the need to re-implement business logic. The library is actively developed, with version 0.14.0 as of the latest release, and is specifically designed for the Microsoft Fabric environment.","status":"active","version":"0.14.0","language":"en","source_language":"en","source_url":"https://github.com/microsoft/semantic-link","tags":["microsoft fabric","power bi","data science","business intelligence","data integration","pandas","pyspark","semantic model","etl"],"install":[{"cmd":"%pip install -U semantic-link","lang":"bash","label":"In Microsoft Fabric notebooks"},{"cmd":"pip install semantic-link","lang":"bash","label":"Standard Python environments (for development/local checks)"}],"dependencies":[{"reason":"Core data manipulation with FabricDataFrame, which extends pandas DataFrames.","package":"pandas","optional":false},{"reason":"For integration with Apache Spark ecosystems within Microsoft Fabric.","package":"pyspark","optional":false},{"reason":"Contains the core semantic link functionality; 'semantic-link' is a meta-package that includes this.","package":"semantic-link-sempy","optional":false},{"reason":"Provides semantic functions related to holidays.","package":"semantic-link-functions-holidays","optional":true},{"reason":"Provides semantic functions for geospatial data.","package":"semantic-link-functions-geopandas","optional":true}],"imports":[{"note":"Common alias for functions interacting with Fabric items like semantic models and workspaces.","symbol":"fabric","correct":"import sempy.fabric as fabric"},{"note":"Common alias for semantic functions provided by SemPy.","symbol":"functions","correct":"import sempy.functions as sf"}],"quickstart":{"code":"import sempy.fabric as fabric\n\n# List all semantic models (datasets) in the current workspace\ndf_datasets = fabric.list_datasets()\nprint(\"Available datasets:\")\nprint(df_datasets.head())\n\n# Assuming a dataset named 'Sales & Returns Sample' exists\n# Read a specific table from a semantic model\ndf_customers = fabric.read_table(dataset=\"Sales & Returns Sample\", table=\"Customer\")\nprint(\"\\nFirst 5 rows of the 'Customer' table:\")\nprint(df_customers.head())","lang":"python","description":"This quickstart demonstrates how to list available semantic models (datasets) in your Microsoft Fabric workspace and then read a specific table from one of those models using the `sempy.fabric` module. This code should be executed within a Microsoft Fabric notebook."},"warnings":[{"fix":"Ensure all development and execution involving Semantic Link occurs within a Microsoft Fabric workspace. For local testing or development, consider mocking Fabric interactions or adapting code to use alternative libraries.","message":"Semantic Link (SemPy) is exclusively supported within Microsoft Fabric notebooks and Spark environments. It will not run in standalone Python environments outside of Fabric. Attempting to use it locally will result in errors related to missing Fabric-specific components.","severity":"breaking","affected_versions":"All versions"},{"fix":"If `pip install semantic-link` causes issues, try `pip install semantic-link-sempy` and then install specific function packages (e.g., `semantic-link-functions-holidays`) as needed.","message":"The `semantic-link` package is a meta-package. For core functionality, `semantic-link-sempy` is sufficient. If you encounter dependency conflicts or only need specific features, consider installing `semantic-link-sempy` and other `semantic-link-functions-*` packages individually instead of the meta-package.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Check your Fabric Spark runtime version. If it's 3.4 or higher, the library is likely already available. Only run `%pip install -U semantic-link` if you need to upgrade or if you're on an older runtime.","message":"Semantic Link is pre-installed in Microsoft Fabric Runtimes 1.2 (Spark 3.4) and above. Explicitly installing it with `%pip install -U semantic-link` is only necessary for older runtimes (Spark 3.3 or below) or to ensure you have the very latest version.","severity":"gotcha","affected_versions":"All versions, specifically relevant for older Fabric Runtimes"},{"fix":"Verify that your Microsoft Fabric environment and Power BI workspace configurations meet the necessary prerequisites outlined in the official documentation.","message":"Using Semantic Link requires a Microsoft Fabric subscription with appropriate capacity (e.g., F64 for LLM samples) and Power BI datasets residing in a Premium or Fabric workspace within the same tenant. Certain advanced features may also require XMLA Read/Write enabled for your capacity.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be mindful of the experimental nature of `semantic-link-labs` features. For production-critical workflows, prioritize features available directly in the core `semantic-link` package.","message":"The `semantic-link-labs` library is an official extension offering early access to experimental features. While powerful, features in `Labs` may be less stable and subject to change or removal compared to the core `semantic-link` library.","severity":"gotcha","affected_versions":"All versions of `semantic-link-labs`"},{"fix":"Focus on utilizing `sempy` functions to compute Power BI measures, query with DAX, and propagate semantic metadata to ensure consistency and avoid duplicated effort.","message":"The primary goal of Semantic Link is to leverage the semantic information (measures, relationships, data categories) already defined in Power BI semantic models. A common anti-pattern is to extract raw data and re-implement business logic in Python/Spark, negating a key benefit of the library.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}