Skip to main content

A Python wrapper library for Microsoft Fabric (and Power BI) operations, providing a simple interface to the official Fabric REST APIs. Falls back to Power BI REST APIs where needed. Designed to run in Python notebooks, pure Python scripts or integrated into YAML-based workflows for CI/CD.

Project description

Welcome to pyfabricops

PyPI version License: MIT Python versions Typing status
Tests

A Python wrapper library for Microsoft Fabric (and Power BI) operations, providing a simple interface to the official Fabric REST APIs. Falls back to Power BI REST APIs where needed. Designed to run in Python notebooks, pure Python scripts or integrated into YAML-based workflows for CI/CD. Access to the repositoy on GitHub.

๐Ÿš€ Features

  • Authenticate using environment variables (GitHub Secrets, ADO Secrets, AzKeyVault, .env ...)
  • Manage workspaces, capacities, semantic models, lakehouses, reports and connections
  • Execute Git operations and automate Fabric deployment flows (Power BI inclusive)
  • Capture and Manage Git branches automatically for CI/CD scenarios
  • Many use cases and scenarios including yaml for test and deploy using GitHub Actions

๐Ÿ“ƒ Documentation

Access: https://pyfabricops.readthedocs.io/en/latest/

โœ… Requirements

  • Requires Python >= 3.10 <=3.12.10

โš’๏ธ Installation

pip install pyfabricops

โš™๏ธ Usage

Create a repository and clone it locally. Create a notebook or a script and import the library:

# Import the library
import pyfabricops as pf

Set the authentication provider

Set auth environment variables acording to your authentication method

Environment variables (.env, GitHub Secrets, Ado Secrets...)

pf.set_auth_provider("env")

This is the default behavior. You can set these in a .env file or directly in your environment (GitHub Secrets, ADO Secrets...).

Example .env file:

FAB_CLIENT_ID=your_client_id_here
FAB_CLIENT_SECRET=your_client_secret_here
FAB_TENANT_ID=your_tenant_id_here
FAB_USERNAME=your_username_here   # Necessary for some functions with no SPN support
FAB_PASSWORD=your_password_here   # Necessary for some functions with no SPN support

Azure Key Vault

pf.set_auth_provider("vault")

Ensure you have the required Azure Key Vault secrets set:

AZURE_CLIENT_ID=your_azure_client_id_here
AZURE_CLIENT_SECRET=your_azure_client_secret_here
AZURE_TENANT_ID=your_azure_tenant_id_here
AZURE_KEY_VAULT_NAME=your_key_vault_name_here

OAuth (Interactive)

pf.set_auth_provider("oauth")

This will open a browser window for user authentication.


> Create a repository and clone it locally.
> Prepare your environment with the required variables according to your authentication method (GitHub Secrets, ADO Secrets, AzKeyVault, .env ...)


### Branches configuration

Create a branches.json file in the root of your repository to define your branch mappings:

```json
{
    "main": "-PRD",
    "master": "-PRD",
    "dev": "-DEV",
    "staging": "-STG"
}

This file maps your local branches to Fabric branches, allowing the library to automatically manage branch names for CI/CD scenarios.

Logging configuration

This library uses the standard Python logging module. You can configure it in your script or notebook using the helper function:

import logging
pf.enable_notebook_logging(level=logging.INFO)

๐Ÿช„ Examples

Visit: https://github.com/alisonpezzott/pyfabricops-examples

๐Ÿงฌ Project Structure

src/
โ””โ”€โ”€ pyfabricops/
    โ”œโ”€โ”€ orchestration/
    โ”‚   โ”œโ”€โ”€ __init__.py
    โ”‚   โ””โ”€โ”€ _workspaces.py
    โ”œโ”€โ”€ tests/
    โ”‚   โ”œโ”€โ”€ __init__.py
    โ”‚   โ””โ”€โ”€ test_basic.py
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ _auth.py
    โ”œโ”€โ”€ _capacities.py
    โ”œโ”€โ”€ _connections.py
    โ”œโ”€โ”€ _core.py
    โ”œโ”€โ”€ _data_pipelines.py
    โ”œโ”€โ”€ _dataflows_gen1.py
    โ”œโ”€โ”€ _dataflows_gen2.py
    โ”œโ”€โ”€ _decorators.py
    โ”œโ”€โ”€ _encrypt_gateway_credentials.py
    โ”œโ”€โ”€ _exceptions.py
    โ”œโ”€โ”€ _fabric_items.py
    โ”œโ”€โ”€ _folders.py
    โ”œโ”€โ”€ _gateways.py
    โ”œโ”€โ”€ _git.py
    โ”œโ”€โ”€ _helpers.py
    โ”œโ”€โ”€ _items.py
    โ”œโ”€โ”€ _lakehouses.py
    โ”œโ”€โ”€ _logging_config.py
    โ”œโ”€โ”€ _notebooks.py
    โ”œโ”€โ”€ _reports.py
    โ”œโ”€โ”€ _scopes.py
    โ”œโ”€โ”€ _semantic_models.py
    โ”œโ”€โ”€ _shortcuts_payloads.py
    โ”œโ”€โ”€ _shortcuts.py
    โ”œโ”€โ”€ _utils.py
    โ”œโ”€โ”€ _version.py
    โ”œโ”€โ”€ _warehouses.py
    โ””โ”€โ”€ _workspaces.py

โค๏ธContributing

  1. Fork this repository
  2. Create a new branch (feat/my-feature)
  3. Run poetry install to set up the development environment
  4. Run poetry run task test to run tests
  5. Submit a pull request ๐Ÿš€

๐Ÿš€ Publishing

For Maintainers

To publish a new version to PyPI:

  1. Update the version in pyproject.toml and src/pyfabricops/_version.py
  2. Commit and push changes
  3. Create a new release on GitHub with a tag (e.g., v0.1.0)
  4. The GitHub Action will automatically:
    • Run tests
    • Build the package
    • Publish to PyPI

Testing with TestPyPI

# Configure TestPyPI
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi <your-testpypi-token>

# Build and publish to TestPyPI
poetry build
poetry publish -r testpypi

# Install from TestPyPI
pip install --index-url https://test.pypi.org/simple/ pyfabricops

Prerequisites for Publishing

๐Ÿž Issues

If you encounter any issues, please report them at https://github.com/alisonpezzott/pyfabricops/issues

โš–๏ธ License

This project is licensed under the MIT License โ€“ see the LICENSE file for details.

๐ŸŒŸ Acknowledgements

Created and maintained by Alison Pezzott Feedback, issues and stars are welcome ๐ŸŒŸ

YouTube subscribers GitHub followers LinkedIn Discord Telegram Instagram

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfabricops-0.1.8.tar.gz (67.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfabricops-0.1.8-py3-none-any.whl (88.3 kB view details)

Uploaded Python 3

File details

Details for the file pyfabricops-0.1.8.tar.gz.

File metadata

  • Download URL: pyfabricops-0.1.8.tar.gz
  • Upload date:
  • Size: 67.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.11.0-1018-azure

File hashes

Hashes for pyfabricops-0.1.8.tar.gz
Algorithm Hash digest
SHA256 62307ab73bef47b14b50fafe65bbf8e6f93465d98ee0e1ac68363a00d1b62867
MD5 237ad7d1119ff5b89ee00b0e35626a6f
BLAKE2b-256 b810e9aba07764ab2f94c96d2ea306e5a7f759ccc0599848bed9e4ba65cc09a9

See more details on using hashes here.

File details

Details for the file pyfabricops-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: pyfabricops-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 88.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.11.0-1018-azure

File hashes

Hashes for pyfabricops-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 eedcd8e4f8a004b439e46a3ac6489c86d9f9cf302cc3fa93ad576d8318bdfc91
MD5 447e6ff5d472a4dbaa72c8fa397cbbae
BLAKE2b-256 8e1764a68cb533d5be16392cd095040e4e239bf3646911bbad04d02b56c3398f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page