Git Product home page Git Product logo

powerbi-jupyter's Introduction

powerbi-jupyter

Powerbi-jupyter is a python IPyWidget that enables customers to use Power BI embedding and reporting capabilities in a Jupyter notebook seamlessly.

Installation

You can install using pip:

pip install powerbiclient

If you are using jupyterlab:

pip install powerbiclient
jupyter labextension install @jupyter-widgets/jupyterlab-manager

If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable the nbextension:

jupyter nbextension enable --py [--sys-prefix|--user|--system] powerbiclient

For the full list of features, refer to the DOCUMENTATION.

  • Power BI report demo.ipynb: a Jupyter notebook that embeds a user's report. It demonstrates the complete flow of embedding and interacting with Power BI report i.e. embedding a Power BI report, setting report event handlers, getting a list of pages and visual, exporting and visualizing visual data and applying filters.
  • Visualize with Power BI demo.ipynb: a Jupyter notebook that creates a quick auto-generated Power BI report over pandas DataFrames. The created reports can be customized and saved to a Power BI workspace.

Required python packages:

  • pandas
  • matplotlib - only for report_demo.ipynb

To run the demo, first run the following commands:

cd demo
jupyter notebook

Then, open and run report_demo.ipynb or quick_visualize_demo.ipynb.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

Please read the contributing guide before starting.

We Value and Adhere to the Microsoft Open Source Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

powerbi-jupyter's People

Contributors

amit-shuster avatar anant-k-singh avatar bapat-atharva avatar cdrcc avatar kkd1215 avatar kotanasai21 avatar may-hartov avatar mayur007b avatar microsoftopensource avatar noamrav avatar orshemesh16 avatar pawankarkal avatar rad10wave avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powerbi-jupyter's Issues

Documentation and notebook links are broken

Failed to load model class 'QuickVisualizeModel' from module 'powerbi-jupyter-client'

Hello,

I'm currently trying to follow your demos for you powerbi widgets for jupyter.
Specifically I am running the Visualize with Power BI demo.ipynb.

I have followed the instructions for jupyter lab but if I attempt to run the following
code

# Create a Power BI report from your data
PBI_visualize = QuickVisualize(get_dataset_config(df), auth=device_auth)
PBI_visualize

I get the following error

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'QuickVisualizeModel' from module 'powerbi-jupyter-client'
loadClass@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25:1:74936
loadModelClass@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:10729
_make_model@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:7517
new_model@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:5137
handle_comm_open@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:3894
134/v/this._handleCommOpen@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25:1:73473
_handleCommOpen@http://localhost:8888/static/lab/jlab_core.c2628bfc928bd194fa79.js?v=c2628bfc928bd194fa79:1:1240940

Following the instructionsn and inspecting the browser debugger gives
image

I am running the notebook via jupyter lab within a poetry environment.
The poetry.lock file is attached.
lock.txt

Any help would be appreciated.

"Error displaying widget: model not found" in notebook launched in Jupyter Lab

Greetings--

I have had success running the demo code in a jupyter notebook launched via jupyter notebook. However, the very same demo code (in the exact same notebook that worked before!) fails when attempting to render the report when launched within Jupyter Lab. In place of rendering the embedded report, the cell instead outputs this generic Jupyter widget-fail message: "Error displaying widget: model not found"

I have followed the special installation instructions provided in the README for Jupyter Lab both in existing and brand new conda environments. In the Jupyter Lab UI, the extension shows as being installed and activated. The txt file attached documents a "fresh" conda environment with the package and lab extensions installed and jupyter lab successfully built, but where I'm still seeing the error. I'm working in a relatively new and updated Windows 10 environment.

Love this package! . . . and hope you can help me get it to run in Jupyter Lab. Thank you!

Steve
pbi_env.txt

powerbiclient installation

Hello all,
when install powerbiclient package, using this command "pip install powerbiclient"
this error is shown:
ERROR: Could not find a version that satisfies the requirement powerbiclient (from versions: none)
ERROR: No matching distribution found for powerbiclient

Best Regards.

Report does not render in Microsoft Fabric Notebook

Hi

I am trying to use powerbi-jupyter client in Microsoft Fabric Notebook (which are feature identical to Synapse Notebooks if I'm not mistaken).

I use following code:

# Setup for getting data from PowerBI
from powerbiclient import Report, models, authentication

# Authenticate to Power BI service using InteractiveLoginAuthentication
auth = authentication.DeviceCodeLoginAuthentication()

# Configure view mode
view_mode=models.EmbedMode.VIEW.value

# NewSales Report configuration
group_id = "GROUP-GUID"
report_id = "REPORT-GUID"

# Create a Power BI report object
report = Report(group_id=group_id, report_id=report_id, auth=auth)
report

The report does not render.

Any idea what can be done to make this work in Microsoft Fabric?

Running the notebook fails at different places

Hi!
I have tried running a notebook based on the wiki and the announcement page (using device auth) and on one computer it can embed the report but fails after running the get_filters code. On the other computer with the same notebook in 4 tries it could only once embed the report and the kernel dies. In both cases Anaconda was updated to the latest and the notebooks are strong machines.

``
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Import Report class and models\n",
"from powerbiclient import Report, models\n",
"import pandas as pd\n",
"# Import DeviceCodeLoginAuthentication class to authenticate to Power BI\n",
"from powerbiclient.authentication import DeviceCodeLoginAuthentication"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Performing interactive authentication. Please follow the instructions on the terminal.\n",
" To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code DET2UAPZW to authenticate.\n",
"You have logged in.\n",
"Interactive authentication successfully completed.\n"
]
}
],
"source": [
"# Initiate device authentication\n",
"device_auth = DeviceCodeLoginAuthentication()\n",
"\n",
"# Get access token from auth object\n",
"access_token = device_auth.get_access_token()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6e6e49334169493aad4821e8c91d7dff",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Report()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Set workspace Id and report Id\n",
"group_id="2c411c27-e41d-4d77-8c1b-c087fb6744ec"\n",
"report_id="aaae5a96-3e0d-4709-a727-9dd5e62f4509"\n",
"\n",
"# Create an instance of Power BI Report (Use either of the below instances)\n",
"# Use auth object\n",
"report = Report(group_id=group_id, report_id=report_id, auth=device_auth)\n",
"\n",
"# Use access token from device authentication\n",
"report = Report(group_id=group_id, report_id=report_id, access_token=access_token, token_type=models.TokenType.AAD.value)\n",
"\n",
"# Load the report in the output cell\n",
"report"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"report.set_dimensions(800, 1100)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'name': 'ReportSection1ef29e413d069478ab55',\n",
" 'displayName': 'Bar and column',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSectiond8b7c2eb140ac63223c0',\n",
" 'displayName': 'Matrix',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSectionf7a8e1b14d9ab030c5ed',\n",
" 'displayName': 'Matrix Details',\n",
" 'isActive': False,\n",
" 'visibility': 1,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSection0b7bb46c903b8ec5de08',\n",
" 'displayName': 'Line Charts',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSection98b20e874029520bada9',\n",
" 'displayName': 'Pie Donut Charts',\n",
" 'isActive': True,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSection86a83f5b4e955e81e232',\n",
" 'displayName': 'KPI Card and Gauge',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSection9be595fc50d900312a2b',\n",
" 'displayName': 'Maps',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSection7ee2636508467a9cb665',\n",
" 'displayName': 'Sales Tooltip',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'width': 320, 'height': 240},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSectionbd579275497cd0a23b79',\n",
" 'displayName': 'ArcGIS Map',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSection519fb7909a3879a736a7',\n",
" 'displayName': 'Time Intelligence',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSectionca74ca96ba2cca3b2de1',\n",
" 'displayName': 'Smart Narratives',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSection022294dfd722ac1c09d0',\n",
" 'displayName': 'Waterfall Chart',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSection38574311eb5a78276dce',\n",
" 'displayName': 'Ribbon Slicer filters',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSectionf7488c4d9e48e01a207a',\n",
" 'displayName': 'Percentage',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0},\n",
" {'name': 'ReportSectione196bfddc0ed64c0a685',\n",
" 'displayName': 'Conditional Formatting',\n",
" 'isActive': False,\n",
" 'visibility': 0,\n",
" 'defaultSize': {'type': 0, 'width': 1280, 'height': 720},\n",
" 'defaultDisplayOption': 0}]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pages = report.get_pages()\n",
"pages"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'name': '1dd4c239217de4004080',\n",
" 'title': 'Country sl',\n",
" 'type': 'slicer',\n",
" 'layout': {'x': 875.363748458693,\n",
" 'y': 0,\n",
" 'z': 0,\n",
" 'width': 131.3933415536375,\n",
" 'height': 103.87176325524044,\n",
" 'displayState': {'mode': 0}}},\n",
" {'name': '183f798992ebbdc7a0eb',\n",
" 'title': 'Manufacturer sl',\n",
" 'type': 'slicer',\n",
" 'layout': {'x': 317.82983970406906,\n",
" 'y': 0,\n",
" 'z': 3000,\n",
" 'width': 165.12946979038225,\n",
" 'height': 103.87176325524044,\n",
" 'displayState': {'mode': 0}}},\n",
" {'name': 'ef3a420088062841a78a',\n",
" 'title': 'Channel sl',\n",
" 'type': 'slicer',\n",
" 'layout': {'x': 173.11960542540075,\n",
" 'y': 0,\n",
" 'z': 4000,\n",
" 'width': 134.05672009864364,\n",
" 'height': 103.87176325524044,\n",
" 'displayState': {'mode': 0}}},\n",
" {'name': '7ff2944372857bc05308',\n",
" 'title': 'PBI logo',\n",
" 'type': 'image',\n",
" 'layout': {'x': 1026.0912453760789,\n",
" 'y': 0,\n",
" 'z': 1000,\n",
" 'width': 253.90875462392108,\n",
" 'height': 103.87176325524044,\n",
" 'displayState': {'mode': 0}}},\n",
" {'name': '781a42009bb013cbba21',\n",
" 'title': 'ProdCategory',\n",
" 'type': 'slicer',\n",
" 'layout': {'x': 669.3958076448829,\n",
" 'y': 0,\n",
" 'z': 1000,\n",
" 'width': 191.7632552404439,\n",
" 'height': 103.87176325524044,\n",
" 'displayState': {'mode': 0}}},\n",
" {'name': 'de45e472e0edde6b8817',\n",
" 'title': 'Brand sl',\n",
" 'type': 'slicer',\n",
" 'layout': {'x': 493.612823674476,\n",
" 'y': 0,\n",
" 'z': 2000,\n",
" 'width': 165.12946979038225,\n",
" 'height': 103.87176325524044,\n",
" 'displayState': {'mode': 0}}},\n",
" {'name': '842fbe1195501eb537a8',\n",
" 'title': 'Year-Month sl',\n",
" 'type': 'slicer',\n",
" 'layout': {'x': 0,\n",
" 'y': 0,\n",
" 'z': 5000,\n",
" 'width': 165.12946979038225,\n",
" 'height': 103.87176325524044,\n",
" 'displayState': {'mode': 0}}},\n",
" {'name': '344fe061214dca8e6566',\n",
" 'type': 'tableEx',\n",
" 'layout': {'x': 0,\n",
" 'y': 197.9778051787916,\n",
" 'z': 0,\n",
" 'width': 604.5869297163995,\n",
" 'height': 522.0221948212084,\n",
" 'displayState': {'mode': 0}}}]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"visuals = report.visuals_on_page('ReportSection519fb7909a3879a736a7')\n",
"visuals"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"from io import StringIO"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"exported_data = report.export_visual_data('ReportSection519fb7909a3879a736a7', '344fe061214dca8e6566', rows=100, export_data_type=models.ExportDataType.SUMMARIZED.value)\n",
"dataexp=StringIO(exported_data)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"

\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border="1" class="dataframe">\n",
" \n",
" <tr style="text-align: right;">\n",
" \n",
" Year\n",
" Month\n",
" Sales\n",
" Sales YTD\n",
" Sales PY\n",
" Sales PY YTD\n",
" \n",
" \n",
" \n",
" \n",
" 0\n",
" 2007\n",
" January\n",
" 269835263 Ft\n",
" 269835263 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 1\n",
" 2007\n",
" February\n",
" 298215968 Ft\n",
" 568051232 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 2\n",
" 2007\n",
" March\n",
" 300486927 Ft\n",
" 868538158 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 3\n",
" 2007\n",
" April\n",
" 400160332 Ft\n",
" 1268698490 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 4\n",
" 2007\n",
" May\n",
" 423429128 Ft\n",
" 1692127618 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 5\n",
" 2007\n",
" June\n",
" 409797546 Ft\n",
" 2101925163 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 6\n",
" 2007\n",
" July\n",
" 389617372 Ft\n",
" 2491542536 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 7\n",
" 2007\n",
" August\n",
" 388429827 Ft\n",
" 2879972363 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 8\n",
" 2007\n",
" September\n",
" 379144600 Ft\n",
" 3259116962 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 9\n",
" 2007\n",
" October\n",
" 423213241 Ft\n",
" 3682330203 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 10\n",
" 2007\n",
" November\n",
" 453750209 Ft\n",
" 4136080412 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 11\n",
" 2007\n",
" December\n",
" 425860543 Ft\n",
" 4561940955 Ft\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 12\n",
" 2008\n",
" January\n",
" 279460807 Ft\n",
" 279460807 Ft\n",
" 269835263 Ft\n",
" 269835263 Ft\n",
" \n",
" \n",
" 13\n",
" 2008\n",
" February\n",
" 288852634 Ft\n",
" 568313441 Ft\n",
" 298215968 Ft\n",
" 568051232 Ft\n",
" \n",
" \n",
" 14\n",
" 2008\n",
" March\n",
" 290060561 Ft\n",
" 858374002 Ft\n",
" 300486927 Ft\n",
" 868538158 Ft\n",
" \n",
" \n",
" 15\n",
" 2008\n",
" April\n",
" 356139170 Ft\n",
" 1214513172 Ft\n",
" 400160332 Ft\n",
" 1268698490 Ft\n",
" \n",
" \n",
" 16\n",
" 2008\n",
" May\n",
" 351096953 Ft\n",
" 1565610125 Ft\n",
" 423429128 Ft\n",
" 1692127618 Ft\n",
" \n",
" \n",
" 17\n",
" 2008\n",
" June\n",
" 338132827 Ft\n",
" 1903742952 Ft\n",
" 409797546 Ft\n",
" 2101925163 Ft\n",
" \n",
" \n",
" 18\n",
" 2008\n",
" July\n",
" 386024198 Ft\n",
" 2289767150 Ft\n",
" 389617372 Ft\n",
" 2491542536 Ft\n",
" \n",
" \n",
" 19\n",
" 2008\n",
" August\n",
" 359938154 Ft\n",
" 2649705304 Ft\n",
" 388429827 Ft\n",
" 2879972363 Ft\n",
" \n",
" \n",
" 20\n",
" 2008\n",
" September\n",
" 353421977 Ft\n",
" 3003127280 Ft\n",
" 379144600 Ft\n",
" 3259116962 Ft\n",
" \n",
" \n",
" 21\n",
" 2008\n",
" October\n",
" 326256368 Ft\n",
" 3329383648 Ft\n",
" 423213241 Ft\n",
" 3682330203 Ft\n",
" \n",
" \n",
" 22\n",
" 2008\n",
" November\n",
" 383063714 Ft\n",
" 3712447362 Ft\n",
" 453750209 Ft\n",
" 4136080412 Ft\n",
" \n",
" \n",
" 23\n",
" 2008\n",
" December\n",
" 398786173 Ft\n",
" 4111233535 Ft\n",
" 425860543 Ft\n",
" 4561940955 Ft\n",
" \n",
" \n",
" 24\n",
" 2009\n",
" January\n",
" 269770345 Ft\n",
" 269770345 Ft\n",
" 279460807 Ft\n",
" 279460807 Ft\n",
" \n",
" \n",
" 25\n",
" 2009\n",
" February\n",
" 266002676 Ft\n",
" 535773021 Ft\n",
" 288852634 Ft\n",
" 568313441 Ft\n",
" \n",
" \n",
" 26\n",
" 2009\n",
" March\n",
" 270769958 Ft\n",
" 806542979 Ft\n",
" 290060561 Ft\n",
" 858374002 Ft\n",
" \n",
" \n",
" 27\n",
" 2009\n",
" April\n",
" 309157751 Ft\n",
" 1115700730 Ft\n",
" 356139170 Ft\n",
" 1214513172 Ft\n",
" \n",
" \n",
" 28\n",
" 2009\n",
" May\n",
" 341560286 Ft\n",
" 1457261016 Ft\n",
" 351096953 Ft\n",
" 1565610125 Ft\n",
" \n",
" \n",
" 29\n",
" 2009\n",
" June\n",
" 331299979 Ft\n",
" 1788560995 Ft\n",
" 338132827 Ft\n",
" 1903742952 Ft\n",
" \n",
" \n",
" 30\n",
" 2009\n",
" July\n",
" 333374435 Ft\n",
" 2121935431 Ft\n",
" 386024198 Ft\n",
" 2289767150 Ft\n",
" \n",
" \n",
" 31\n",
" 2009\n",
" August\n",
" 325030343 Ft\n",
" 2446965774 Ft\n",
" 359938154 Ft\n",
" 2649705304 Ft\n",
" \n",
" \n",
" 32\n",
" 2009\n",
" September\n",
" 313780340 Ft\n",
" 2760746114 Ft\n",
" 353421977 Ft\n",
" 3003127280 Ft\n",
" \n",
" \n",
" 33\n",
" 2009\n",
" October\n",
" 326836388 Ft\n",
" 3087582502 Ft\n",
" 326256368 Ft\n",
" 3329383648 Ft\n",
" \n",
" \n",
" 34\n",
" 2009\n",
" November\n",
" 322166204 Ft\n",
" 3409748706 Ft\n",
" 383063714 Ft\n",
" 3712447362 Ft\n",
" \n",
" \n",
" 35\n",
" 2009\n",
" December\n",
" 330734413 Ft\n",
" 3740483119 Ft\n",
" 398786173 Ft\n",
" 4111233535 Ft\n",
" \n",
" \n",
"\n",
"
"
],
"text/plain": [
" Year Month Sales Sales YTD Sales PY Sales PY YTD\n",
"0 2007 January 269835263 Ft 269835263 Ft NaN NaN\n",
"1 2007 February 298215968 Ft 568051232 Ft NaN NaN\n",
"2 2007 March 300486927 Ft 868538158 Ft NaN NaN\n",
"3 2007 April 400160332 Ft 1268698490 Ft NaN NaN\n",
"4 2007 May 423429128 Ft 1692127618 Ft NaN NaN\n",
"5 2007 June 409797546 Ft 2101925163 Ft NaN NaN\n",
"6 2007 July 389617372 Ft 2491542536 Ft NaN NaN\n",
"7 2007 August 388429827 Ft 2879972363 Ft NaN NaN\n",
"8 2007 September 379144600 Ft 3259116962 Ft NaN NaN\n",
"9 2007 October 423213241 Ft 3682330203 Ft NaN NaN\n",
"10 2007 November 453750209 Ft 4136080412 Ft NaN NaN\n",
"11 2007 December 425860543 Ft 4561940955 Ft NaN NaN\n",
"12 2008 January 279460807 Ft 279460807 Ft 269835263 Ft 269835263 Ft\n",
"13 2008 February 288852634 Ft 568313441 Ft 298215968 Ft 568051232 Ft\n",
"14 2008 March 290060561 Ft 858374002 Ft 300486927 Ft 868538158 Ft\n",
"15 2008 April 356139170 Ft 1214513172 Ft 400160332 Ft 1268698490 Ft\n",
"16 2008 May 351096953 Ft 1565610125 Ft 423429128 Ft 1692127618 Ft\n",
"17 2008 June 338132827 Ft 1903742952 Ft 409797546 Ft 2101925163 Ft\n",
"18 2008 July 386024198 Ft 2289767150 Ft 389617372 Ft 2491542536 Ft\n",
"19 2008 August 359938154 Ft 2649705304 Ft 388429827 Ft 2879972363 Ft\n",
"20 2008 September 353421977 Ft 3003127280 Ft 379144600 Ft 3259116962 Ft\n",
"21 2008 October 326256368 Ft 3329383648 Ft 423213241 Ft 3682330203 Ft\n",
"22 2008 November 383063714 Ft 3712447362 Ft 453750209 Ft 4136080412 Ft\n",
"23 2008 December 398786173 Ft 4111233535 Ft 425860543 Ft 4561940955 Ft\n",
"24 2009 January 269770345 Ft 269770345 Ft 279460807 Ft 279460807 Ft\n",
"25 2009 February 266002676 Ft 535773021 Ft 288852634 Ft 568313441 Ft\n",
"26 2009 March 270769958 Ft 806542979 Ft 290060561 Ft 858374002 Ft\n",
"27 2009 April 309157751 Ft 1115700730 Ft 356139170 Ft 1214513172 Ft\n",
"28 2009 May 341560286 Ft 1457261016 Ft 351096953 Ft 1565610125 Ft\n",
"29 2009 June 331299979 Ft 1788560995 Ft 338132827 Ft 1903742952 Ft\n",
"30 2009 July 333374435 Ft 2121935431 Ft 386024198 Ft 2289767150 Ft\n",
"31 2009 August 325030343 Ft 2446965774 Ft 359938154 Ft 2649705304 Ft\n",
"32 2009 September 313780340 Ft 2760746114 Ft 353421977 Ft 3003127280 Ft\n",
"33 2009 October 326836388 Ft 3087582502 Ft 326256368 Ft 3329383648 Ft\n",
"34 2009 November 322166204 Ft 3409748706 Ft 383063714 Ft 3712447362 Ft\n",
"35 2009 December 330734413 Ft 3740483119 Ft 398786173 Ft 4111233535 Ft"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df=pd.read_csv(dataexp,sep=",")\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border="1" class="dataframe">\n",
" \n",
" <tr style="text-align: right;">\n",
" \n",
" Year\n",
" Month\n",
" Sales\n",
" Sales YTD\n",
" Sales PY\n",
" Sales PY YTD\n",
" \n",
" \n",
" \n",
" \n",
" 0\n",
" 2007\n",
" January\n",
" 269835263.0\n",
" 2.698353e+08\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 1\n",
" 2007\n",
" February\n",
" 298215968.0\n",
" 5.680512e+08\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 2\n",
" 2007\n",
" March\n",
" 300486927.0\n",
" 8.685382e+08\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 3\n",
" 2007\n",
" April\n",
" 400160332.0\n",
" 1.268698e+09\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
" 4\n",
" 2007\n",
" May\n",
" 423429128.0\n",
" 1.692128e+09\n",
" NaN\n",
" NaN\n",
" \n",
" \n",
"\n",
"
"
],
"text/plain": [
" Year Month Sales Sales YTD Sales PY Sales PY YTD\n",
"0 2007 January 269835263.0 2.698353e+08 NaN NaN\n",
"1 2007 February 298215968.0 5.680512e+08 NaN NaN\n",
"2 2007 March 300486927.0 8.685382e+08 NaN NaN\n",
"3 2007 April 400160332.0 1.268698e+09 NaN NaN\n",
"4 2007 May 423429128.0 1.692128e+09 NaN NaN"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[df.columns[2:]] = df[df.columns[2:]].replace('[ Ft,]','', regex=True).astype(float)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.plot.barh(y="Sales", x="Year", figsize=(10,15))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"filters = report.get_filters()\n",
"filters"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create a basic filter to filter the report with value "East" in column "Region" of table "Geo"\n",
"channel_filter = {\n",
" '$schema': "http://powerbi.com/product/schema#basic",\n",
" 'target': {\n",
" 'table': "Channel",\n",
" 'column': "Channel"\n",
" },\n",
" 'operator': "In",\n",
" 'values': ["Online"]\n",
"}\n",
"\n",
"# Apply the basic filter by passing it in a List of filters in update_filters() method\n",
"report.update_filters([channel_filter])\n",
"report"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Displaying reports under VS Code with Jupyter extension

Has anyone successfully been able to display a report under VS Code?

My setup:

  • VS code latest with python and jupyter extensions installed
  • python 3.7.
  • nodejs 16.4
  • starting with a blank conda environment

I successfully get device authentication. When I try to render a report:
image
I click on enable, then restart kernel, authenticate again but keep getting the same error.

Render report in Edge vs Chrome

Rendering a report in Edge doesn't seem to work.

Run notebook in Edge, report won;t render. It is picked up, can see the report object attributes etc.

Same code runs and renders correctly in Chrome.

On rerunning the notebook in Edge the report will render.

Not tried with closing/restarting jupyter.

Embed a specified report page or even a single visual

Hi, would it be possible when initializing the report, to preset filters and set it to a given report page? Or would that be accomplished by using a bookmark that takes the user to a certain page?

How about embedding only a specific visual from a given page?

If not possible today, is it in the backlog? Thank you.

SSL Self Signed Verification

Love that your creating this!!

Was working my way through the Quick Start in the documentation and made it to the # Use auth object. That is where it failed, not an SSL expert so was hoping you could help. Below is the error that I get whether using the device_auth or user_token.

Any Suggestions?

image

AttributeError: 'DataFrame' object has no attribute 'dtype'

Enviroment:
Python 3.10.11 (main, May 15 2023, 19:29:30) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help.

pandas 2.0.2

Function:

Create a Power BI report from your data

PBI_visualize = QuickVisualize(get_dataset_config(df_pbi_), auth=interactive_auth) # auth=device_auth

Render the new report

PBI_visualize

Error:
AttributeError: 'DataFrame' object has no attribute 'dtype'

Get a report with dataset Row-level security (RLS)

Hello guys,

I have a dataset that has row-level security.

embed_token_request_body = {"accessLevel": "View", "identities": [
{
"username": "[email protected]",
"roles": ["BVC"],
"datasets":[dataset_id]
}
]}

I passed embed_token_request_body parameter with json value (json.dumps(embed_token_request_body)) have "identities" (https://docs.microsoft.com/en-us/rest/api/power-bi/embed-token/reports-generate-token-in-group#generate-paginated-report-embedtoken-with-effectiveidentity), then received "message":"The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource."

Another way, I also passed embed_token_request_body parameter with dict value (embed_token_request_body itself), then received "message":"Creating embed token with multiple identities is not supported"

I read your report.py, then try to change line 751 (

response = requests.post(request_url, headers={'Authorization': 'Bearer ' + access_token}, data=token_request_body)
) with additional header.
headers={'Content-Type': 'application/json', 'Authorization': 'Bearer ' + access_token}
It works with embed_token_request_body parameter is json value.

Hope you guys will fix this.
Thanks.

Adding to Conda-Forge

I would like to know if it would be possible to get this added to Conda-Forge. I am willing to do the work to do it, if it is allowed. I will have to learn how first, but it is something that I have been wanting to learn.

Error with SSL certification

hi guys,

i'm trying to run a sample notebook with this code (same as the documentation sample).

from powerbiclient import Report, models

from powerbiclient.authentication import DeviceCodeLoginAuthentication

device_auth = DeviceCodeLoginAuthentication()

and I'm stucked on the following error
SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

already searched on countless pages to see if there would be something that helps me in this. no success.

is there any way that we can ignore the SSL verification? Something like requests.get(url,verify=False)

Complete log error below.

---------------------------------------------------------------------------
SSLCertVerificationError                  Traceback (most recent call last)
c:\python39\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    698             # Make the request on the httplib connection object.
--> 699             httplib_response = self._make_request(
    700                 conn,

c:\python39\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    381         try:
--> 382             self._validate_conn(conn)
    383         except (SocketTimeout, BaseSSLError) as e:

c:\python39\lib\site-packages\urllib3\connectionpool.py in _validate_conn(self, conn)
   1009         if not getattr(conn, "sock", None):  # AppEngine might not have  `.sock`
-> 1010             conn.connect()
   1011 

c:\python39\lib\site-packages\urllib3\connection.py in connect(self)
    410 
--> 411         self.sock = ssl_wrap_socket(
    412             sock=conn,

c:\python39\lib\site-packages\urllib3\util\ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir, key_password, ca_cert_data, tls_in_tls)
    427     if send_sni:
--> 428         ssl_sock = _ssl_wrap_socket_impl(
    429             sock, context, tls_in_tls, server_hostname=server_hostname

c:\python39\lib\site-packages\urllib3\util\ssl_.py in _ssl_wrap_socket_impl(sock, ssl_context, tls_in_tls, server_hostname)
    471     if server_hostname:
--> 472         return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
    473     else:

c:\python39\lib\ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,

c:\python39\lib\ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):

c:\python39\lib\ssl.py in do_handshake(self, block)
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
c:\python39\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    438             if not chunked:
--> 439                 resp = conn.urlopen(
    440                     method=request.method,

c:\python39\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    782             )
--> 783             return self.urlopen(
    784                 method,

c:\python39\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    754 
--> 755             retries = retries.increment(
    756                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]

c:\python39\lib\site-packages\urllib3\util\retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    572         if new_retry.is_exhausted():
--> 573             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    574 

MaxRetryError: HTTPSConnectionPool(host='login.microsoftonline.com', port=443): Max retries exceeded with url: /organizations/v2.0/.well-known/openid-configuration (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
<ipython-input-21-89c3807efee2> in <module>
      6 
      7 # Initiate device authentication
----> 8 device_auth = DeviceCodeLoginAuthentication()

c:\python39\lib\site-packages\powerbiclient\authentication.py in __init__(self, client_id, scopes, tenant)
    109             scopes = DEFAULT_SCOPES
    110         self.scopes = scopes
--> 111         auth_result = self._acquire_token_device_code()
    112         super().__init__(client_id, scopes, self.authority_uri, auth_result)
    113 

c:\python39\lib\site-packages\powerbiclient\authentication.py in _acquire_token_device_code(self)
    118             dict: authentication result
    119         """
--> 120         app = msal.PublicClientApplication(client_id=self.client_id, authority=self.authority_uri)
    121         flow = app.initiate_device_flow(self.scopes)
    122 

c:\python39\lib\site-packages\msal\application.py in __init__(self, client_id, client_credential, **kwargs)
   1294         if client_credential is not None:
   1295             raise ValueError("Public Client should not possess credentials")
-> 1296         super(PublicClientApplication, self).__init__(
   1297             client_id, client_credential=None, **kwargs)
   1298 

c:\python39\lib\site-packages\msal\application.py in __init__(self, client_id, client_credential, authority, validate_authority, token_cache, http_client, verify, proxies, timeout, client_claims, app_name, app_version, client_capabilities, azure_region, exclude_scopes)
    294         # Here the self.authority will not be the same type as authority in input
    295         try:
--> 296             self.authority = Authority(
    297                 authority or "https://login.microsoftonline.com/common/",
    298                 self.http_client, validate_authority=validate_authority)

c:\python39\lib\site-packages\msal\authority.py in __init__(self, authority_url, http_client, validate_authority)
     81                     ))
     82         try:
---> 83             openid_config = tenant_discovery(
     84                 tenant_discovery_endpoint,
     85                 self.http_client)

c:\python39\lib\site-packages\msal\authority.py in tenant_discovery(tenant_discovery_endpoint, http_client, **kwargs)
    140 def tenant_discovery(tenant_discovery_endpoint, http_client, **kwargs):
    141     # Returns Openid Configuration
--> 142     resp = http_client.get(tenant_discovery_endpoint, **kwargs)
    143     if resp.status_code == 200:
    144         payload = json.loads(resp.text)  # It could raise ValueError

c:\python39\lib\site-packages\requests\sessions.py in get(self, url, **kwargs)
    553 
    554         kwargs.setdefault('allow_redirects', True)
--> 555         return self.request('GET', url, **kwargs)
    556 
    557     def options(self, url, **kwargs):

c:\python39\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    540         }
    541         send_kwargs.update(settings)
--> 542         resp = self.send(prep, **send_kwargs)
    543 
    544         return resp

c:\python39\lib\site-packages\requests\sessions.py in send(self, request, **kwargs)
    653 
    654         # Send the request
--> 655         r = adapter.send(request, **kwargs)
    656 
    657         # Total elapsed time of the request (approximately)

c:\python39\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    512             if isinstance(e.reason, _SSLError):
    513                 # This branch is for urllib3 v1.22 and later.
--> 514                 raise SSLError(e, request=request)
    515 
    516             raise ConnectionError(e, request=request)

SSLError: HTTPSConnectionPool(host='login.microsoftonline.com', port=443): Max retries exceeded with url: /organizations/v2.0/.well-known/openid-configuration (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

Exception: Power BI report is not embedded

I try to open the PowerBI report but it gives error

Exception Traceback (most recent call last)
Cell In[12], line 1
----> 1 pages = report.get_pages()
2 display(pages)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\powerbiclient\report.py:562, in Report.get_pages(self)
556 """Returns pages list of the embedded Power BI report
557
558 Returns:
559 list: list of pages
560 """
561 if not self._embedded:
--> 562 raise Exception(self.REPORT_NOT_EMBEDDED_MESSAGE)
564 # Start getting pages on client side
565 self._get_pages_request = True

Exception: Power BI report is not embedded

Export all rows via export_visual_data API

Please provide the options to export all rows from visual data without having to feed number to rows keyword.

export_visual_data(page_name, visual_name, rows=all_rows, export_data_type=models.ExportDataType.SUMMARIZED.value)

The documentation doesnt explain about it.

Unable to move across report tabs in the embedded report

Hi team,

I have a Power BI report with multiple report tabs and the data I want to extract from a table is not on the active page by default. Is there an ability to set the active page to a page with a known page id through coding? I am aware it is possible by manually selecting the tab from the embedded visual but my goal is to eliminate this manual step by writing a code to switch to another page automatically.

Update_filters

Hello, is it normal that the report display doesn't update when you apply a filter and do an update_filters?

Dropdown slicer with single select is not working

when I am trying to use dropdown slicer with single select option it is not able to select and report coming as blank
def filter_report(filter_list1,filter_list2):
region_filter1 = {
'$schema': "http://powerbi.com/product/schema#basic",
'target': {
'table': "Roadmap_Allviewers",
'column': "Brand_divided"
},
'operator': "In",
'values': [filter_list1]
}
region_filter2 = {
'$schema': "http://powerbi.com/product/schema#basic",
'target': {
'table': "Roadmap_Allviewers",
'column': "Workstream"
},
'operator': "In",
'values': [filter_list2]
}

report.remove_filters()
report.update_filters([region_filter1,region_filter2])

extract visual data from report in python script and not in jupyter notebook widget.

Hi,
I have tried this library to embed report in jupyter notebooks. But I want to extract the data from report visuals in python script and run through commandline. Currently report is getting embedded after calling Report() on jupyter notebooks only. When i try to run the same thing in python script commandline it says report is not embedded.
Could you please suggest me some resource which i can use for reference to extract data from power report visuals in python .py script.

Resizing the embedded report

Great work on this, thank you so much!

How do I resize the embedded dashboard in Jupyter notebook? I did not see any arguments to specify the width and height. Can you please point to it if it exists, if not that would be a feature request. Thanks!

error displaying widget model not found

Getting error while running the bellow code and am also running the Jupiter lab in the container, so for that please also check the Dockerfile.

Tried many combination but none of the solution worked.

Code:

from powerbiclient import Report, models
from powerbiclient.authentication import DeviceCodeLoginAuthentication

device_auth = DeviceCodeLoginAuthentication()
group_id="Workspace ID"
report_id="Report ID"
report = Report(group_id=group_id, report_id=report_id, auth=device_auth)
report

Error:

error displaying widget model not found

Dockerfile:

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest

RUN microdnf update -y &&
microdnf install -y python38 wget tar gzip zip unzip git gcc-c++.x86_64 python38-devel python38-setuptools &&
microdnf clean all

RUN dnf module -y install nodejs:18

WORKDIR /

RUN pip3 install ipympl matplotlib jupyterlab virtualenv powerbiclient ipywidgets ipympl

RUN jupyter labextension install @jupyter-widgets/jupyterlab-manager &&
jupyter labextension install jupyter-matplotlib &&
jupyter labextension update --all &&
jupyter lab build

RUN mkdir -p /users/home /jupyter/kernels &&
chmod -R 755 /users /jupyter

EXPOSE 8880 8866

CMD ["jupyter", "lab", "--notebook-dir=/users", "--allow-root", "--port=8866", "--ip=0.0.0.0"]

passing bearer access token to auth fails

Hi team,

I have a service principal account and I would like to pass my bearer access token to Report() to avoid using either DeviceCodeLoginAuthentication or InteractiveLoginAuthenticationto prevent browser launching a page - so that I can perform this in remote machines.

group_id= ""
report_id= ""
report = Report(group_id=group_id, report_id=report_id, auth = access_token, view_mode=EmbedMode.VIEW.value)

Throws "LoadReportFailed - Fail to initialize - Could not resolve cluster".

Below is one of the methods I have used to obtain access token. (I have also used azure.identity ClientSecretCredential and adal libraries too which are not listed here, but failed to embed the report.)

Azure AD tenant ID and Power BI API resource URL

tenant_id = ""
resource = "https://analysis.windows.net/powerbi/api"

Azure AD application client ID and client secret

client_id = ""
client_secret = ""

Azure AD token endpoint

token_endpoint = f"https://login.microsoftonline.com/{tenant_id}/oauth2/token"

Request access token

headers = {"Content-Type": "application/x-www-form-urlencoded"}

data = {
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret,
"resource": resource
}
response = requests.post(token_endpoint, data=data)
access_token = response.json()["access_token"]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.