Skip to main content

codepbi

Code-first Power BI. Define pages and visuals in Python, get a working PBIP/PBIR report that opens and edits normally in Power BI Desktop.

from codepbi import Field, Filter, Position, Report

report = Report(name="Sales Overview", semantic_model_path="../Sales.SemanticModel")
page = report.add_page("Overview")
page.add_slicer(Field("Orders", "Region"), Position(x=0, y=0, width=200, height=400))
page.add_table(
    fields=[Field("Orders", "Region"), Field("Orders", "Order Amount")],
    position=Position(x=220, y=0, width=800, height=400),
    filters=[Filter.equals("Orders", "Status", "Active")],
)
report.save("output_dir")

codepbi.semantic

A separate module for the other half of the workflow: syncing a Power BI TMDL semantic model from a dbt project, via the Tabular Object Model (TOM). Treats dbt's schema YAML as the source of truth for columns, and a dbt-semantic-layer- style semantic_models/*.yml (entities + measures) as the source of truth for joins and DAX measures.

from codepbi.semantic import TmdlProjectConfig, sync_descriptions, sync_measures, sync_relationships

config = TmdlProjectConfig(
    dbt_project_dir="path/to/dbt_project",
    semantic_model_definition_dir="path/to/Model.SemanticModel/definition",
    tom_lib_dir="path/to/analysis-services-dlls",
)

sync_measures.sync(config)
sync_descriptions.sync(config)   # also validates the resulting model
sync_relationships.sync(config)

Requires the semantic extra (pip install codepbi[semantic]) plus the Microsoft.AnalysisServices.NetCore.retail.amd64 NuGet package's DLLs, obtained separately and pointed at via tom_lib_dir (not redistributed here).

Install

pip install -e .           # report/visual builder only
pip install -e ".[semantic]"  # + the dbt-to-TMDL sync module

License

MIT

Metadata

Release files for codepbi 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codepbi 0.1.7
File Size Uploaded Provenance Actions
codepbi-0.1.7.tar.gz 32.3 kB Without provenance Details for codepbi-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codepbi 0.1.7
File Interpreter ABI Platform Actions
codepbi-0.1.7-py3-none-any.whl Python 3 none any Details for codepbi-0.1.7-py3-none-any.whl

Total release size: 65.1 kB

Release files / codepbi-0.1.7.tar.gz

Download URL codepbi-0.1.7.tar.gz
Size 32.3 kB
Tags Source
SHA-256 checksum
How to use checksums
05f4ec12cebb1396bfaadff5332cc57b0c8e4c83f4d733576b328d0cfb53c1c0
BLAKE2b-256 checksum
How to use checksums
6cd1c29999305b0fad057767b30bcf7f1c2107cf5fc842e35325eb4c0147eb15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / codepbi-0.1.7-py3-none-any.whl

Download URL codepbi-0.1.7-py3-none-any.whl
Size 32.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67fd30868552ca9f51c2f90fce212936e08890d43ddeeef1ffbf77552e62af37
BLAKE2b-256 checksum
How to use checksums
7f80a1630238c347bf515e9633f2dc61fc35e287f7c4ab3441a8b5da8f6c9d1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for codepbi 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page