Merged PR 149937: Rename package to powerbiclient

## In this PR:
- Renamed widget
- Renamed traitlets
- Renamed frontend vars
- Updated test cases

**Note: Do not merge**

[Pipeline results](https://dev.azure.com/powerbi/Embedded/_build/results?buildId=2734029&view=results)

Related work items: #537728
This commit is contained in:
Mayur Garhwal 2021-03-04 06:24:01 +00:00
Родитель 29763851f9
Коммит b85f8949a9
36 изменённых файлов: 887 добавлений и 893 удалений

Просмотреть файл

@ -1,2 +1,2 @@
[run]
omit = powerbi_client/tests/*
omit = powerbiclient/tests/*

6
.gitignore поставляемый
Просмотреть файл

@ -145,15 +145,15 @@ $RECYCLE.BIN/
# ----
**/node_modules/
powerbi_client/nbextension/static/index.*
powerbi_client/labextension/*.tgz
powerbiclient/nbextension/static/index.*
powerbiclient/labextension/*.tgz
# Coverage data
# -------------
**/coverage/
# Packed lab extensions
powerbi_client/labextension
powerbiclient/labextension
# VS Code
.vscode

Просмотреть файл

@ -25,7 +25,7 @@ static_analysis_options:
- from: 'src\'
include:
- '**/*.*'
- from: 'powerbi_client\'
- from: 'powerbiclient\'
include:
- '**/*.*'
@ -35,7 +35,7 @@ static_analysis_options:
- 'demo\**\*' # Exclude path 'Localize'.
- 'test\**\*'
- 'node_modules\**\*'
- 'powerbi_client\tests\**\*'
- 'powerbiclient\tests\**\*'
binskim_options:
files_to_scan:
@ -43,7 +43,7 @@ static_analysis_options:
- 'examples\**\*' # Exclude path 'Localize'.
- 'tests\**\*'
- 'node_modules\**\*'
- 'powerbi_client\tests\**\*'
- 'powerbiclient\tests\**\*'
package_sources:
npm:
@ -87,7 +87,7 @@ build:
- '**/examples/**/*.*'
- '**/node_modules/**/*.*'
- '**/tests/**/*.*'
- '**/powerbi_client/tests/**/*.*'
- '**/powerbiclient/tests/**/*.*'
# All build stage artifacts get signed right after the build stage
# because the global signing profile is defined.

Просмотреть файл

@ -3,9 +3,9 @@ $exitCode = 0;
# TODO: Run front-end test script when available
# Run python kernel test scripts
Write-Host "start: pytest powerbi_client"
& python -m pytest powerbi_client --cov -v
Write-Host "done: pytest powerbi_client"
Write-Host "start: pytest powerbiclient"
& python -m pytest powerbiclient --cov -v
Write-Host "done: pytest powerbiclient"
$exitCode += $LASTEXITCODE;
exit $exitCode;

Просмотреть файл

@ -56,7 +56,7 @@ script:
if [[ $GROUP == python ]]; then
EXIT_STATUS=0
pushd $(mktemp -d)
py.test -l --cov-report xml:$TRAVIS_BUILD_DIR/coverage.xml --cov=powerbi_client --pyargs powerbi_client || EXIT_STATUS=$?
py.test -l --cov-report xml:$TRAVIS_BUILD_DIR/coverage.xml --cov=powerbiclient --pyargs powerbiclient || EXIT_STATUS=$?
popd
(exit $EXIT_STATUS)
elif [[ $GROUP == js ]]; then

Просмотреть файл

@ -8,7 +8,7 @@ include .coverage.rc
include tsconfig.json
include package.json
include webpack.config.js
include powerbi_client/labextension/*.tgz
include powerbiclient/labextension/*.tgz
# Documentation
graft docs
@ -25,7 +25,7 @@ graft tests
prune tests/build
# Javascript files
graft powerbi_client/nbextension
graft powerbiclient/nbextension
graft src
graft css
prune **/node_modules

Просмотреть файл

@ -8,20 +8,20 @@ A Custom Jupyter Widget Library
You can install using `pip`:
```bash
pip install powerbi_client
pip install powerbiclient
```
Or if you use jupyterlab:
```bash
pip install powerbi_client
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:
```bash
jupyter nbextension enable --py [--sys-prefix|--user|--system] powerbi_client
jupyter nbextension enable --py [--sys-prefix|--user|--system] powerbiclient
```
## Demo
@ -58,8 +58,8 @@ jupyter labextension install .
For classic notebook, you can run:
```
jupyter nbextension install --sys-prefix --symlink --overwrite --py powerbi_client
jupyter nbextension enable --sys-prefix --py powerbi_client
jupyter nbextension install --sys-prefix --symlink --overwrite --py powerbiclient
jupyter nbextension enable --sys-prefix --py powerbiclient
```
__Note__ that the `--symlink` flag doesn't work on Windows, so you will here have to run
@ -89,7 +89,7 @@ For classic jupyter notebook:
1. Copy output to jupyter directory
```bash
jupyter nbextension install --sys-prefix --overwrite --py powerbi_client
jupyter nbextension install --sys-prefix --overwrite --py powerbiclient
```
1. Reload webpage in browser
@ -111,4 +111,4 @@ If you make changes to the python code then you will need to restart the noteboo
`npm run debug`<br/>
#### Python:
1. `pytest powerbi_client --cov -v`
1. `pytest powerbiclient --cov -v`

Просмотреть файл

@ -48,14 +48,14 @@ build: off
before_test:
- git config --global user.email appveyor@fake.com
- git config --global user.name "AppVeyor CI"
- set "tmptestdir=%tmp%\powerbi_client-%RANDOM%"
- set "tmptestdir=%tmp%\powerbiclient-%RANDOM%"
- mkdir "%tmptestdir%"
- cd "%tmptestdir%"
# to run your custom scripts instead of automatic tests
test_script:
- 'py.test -l --cov-report xml:"%APPVEYOR_BUILD_FOLDER%\coverage.xml" --cov=powerbi_client --pyargs powerbi_client'
- 'py.test -l --cov-report xml:"%APPVEYOR_BUILD_FOLDER%\coverage.xml" --cov=powerbiclient --pyargs powerbiclient'
on_success:
- cd "%APPVEYOR_BUILD_FOLDER%"

Просмотреть файл

@ -9,4 +9,4 @@ coverage:
default:
target: 0%
ignore:
- "powerbi_client/tests"
- "powerbiclient/tests"

Просмотреть файл

@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = powerbi_client
SPHINXPROJ = powerbiclient
SOURCEDIR = source
BUILDDIR = build

Просмотреть файл

@ -1,5 +1,5 @@
name: powerbi_client_docs
name: powerbiclient_docs
channels:
- conda-forge
dependencies:

Просмотреть файл

@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" (
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=powerbi_client
set SPHINXPROJ=powerbiclient
if "%1" == "" goto help

Просмотреть файл

@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# powerbi_client documentation build configuration file
# powerbiclient documentation build configuration file
#
# This file is execfile()d with the current directory set to its
# containing dir.
@ -54,7 +54,7 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = 'powerbi_client'
project = 'powerbiclient'
copyright = '2020, Microsoft'
author = 'Microsoft'
@ -69,7 +69,7 @@ author = 'Microsoft'
import os
here = os.path.dirname(__file__)
repo = os.path.join(here, '..', '..')
_version_py = os.path.join(repo, 'powerbi_client', '_version.py')
_version_py = os.path.join(repo, 'powerbiclient', '_version.py')
version_ns = {}
with open(_version_py) as f:
exec(f.read(), version_ns)
@ -116,7 +116,7 @@ html_static_path = ['_static']
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'powerbi_clientdoc'
htmlhelp_basename = 'powerbiclientdoc'
# -- Options for LaTeX output ---------------------------------------------
@ -143,7 +143,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'powerbi_client.tex', 'powerbi_client Documentation',
(master_doc, 'powerbiclient.tex', 'powerbiclient Documentation',
'Microsoft', 'manual'),
]
@ -154,8 +154,8 @@ latex_documents = [
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc,
'powerbi_client',
'powerbi_client Documentation',
'powerbiclient',
'powerbiclient Documentation',
[author], 1)
]
@ -167,10 +167,10 @@ man_pages = [
# dir menu entry, description, category)
texinfo_documents = [
(master_doc,
'powerbi_client',
'powerbi_client Documentation',
'powerbiclient',
'powerbiclient Documentation',
author,
'powerbi_client',
'powerbiclient',
'A Custom Jupyter Widget Library',
'Miscellaneous'),
]

Просмотреть файл

@ -3,7 +3,7 @@ Developer install
=================
To install a developer version of powerbi_client, you will first need to clone
To install a developer version of powerbiclient, you will first need to clone
the repository::
git clone https://github.com/Microsoft/powerbi-jupyter
@ -17,9 +17,9 @@ Next, install it with a develop install using pip::
If you are planning on working on the JS/frontend code, you should also do
a link installation of the extension::
jupyter nbextension install [--sys-prefix / --user / --system] --symlink --py powerbi_client
jupyter nbextension install [--sys-prefix / --user / --system] --symlink --py powerbiclient
jupyter nbextension enable [--sys-prefix / --user / --system] --py powerbi_client
jupyter nbextension enable [--sys-prefix / --user / --system] --py powerbiclient
with the `appropriate flag`_. Or, if you are using Jupyterlab::

Просмотреть файл

@ -1,5 +1,5 @@
powerbi_client
powerbiclient
=====================================
Version: |release|
@ -10,13 +10,13 @@ A Custom Jupyter Widget Library
Quickstart
----------
To get started with powerbi_client, install with pip::
To get started with powerbiclient, install with pip::
pip install powerbi_client
pip install powerbiclient
or with conda::
conda install powerbi_client
conda install powerbiclient
Contents

Просмотреть файл

@ -5,22 +5,22 @@ Installation
============
The simplest way to install powerbi_client is via pip::
The simplest way to install powerbiclient is via pip::
pip install powerbi_client
pip install powerbiclient
or via conda::
conda install powerbi_client
conda install powerbiclient
If you installed via pip, and notebook version < 5.3, you will also have to
install / configure the front-end extension as well. If you are using classic
notebook (as opposed to Jupyterlab), run::
jupyter nbextension install [--sys-prefix / --user / --system] --py powerbi_client
jupyter nbextension install [--sys-prefix / --user / --system] --py powerbiclient
jupyter nbextension enable [--sys-prefix / --user / --system] --py powerbi_client
jupyter nbextension enable [--sys-prefix / --user / --system] --py powerbiclient
with the `appropriate flag`_. If you are using Jupyterlab, install the extension
with::

Просмотреть файл

@ -13,7 +13,7 @@
"metadata": {},
"outputs": [],
"source": [
"from powerbi_client import Report\n",
"from powerbiclient import Report\n",
"import requests\n",
"from io import StringIO\n",
"import pandas as pd\n",
@ -33,7 +33,7 @@
" \n",
" Code snippet:\n",
" ``` py\n",
" from powerbi_client.authentication import DeviceCodeLoginAuthentication\n",
" from powerbiclient.authentication import DeviceCodeLoginAuthentication\n",
" device_auth = DeviceCodeLoginAuthentication()\n",
" token_with_device_code = device_auth.get_access_token()\n",
" ```\n",
@ -41,7 +41,7 @@
" \n",
" Code snippet:\n",
" ``` py\n",
" from powerbi_client.authentication import InteractiveLoginAuthentication\n",
" from powerbiclient.authentication import InteractiveLoginAuthentication\n",
" interactive_auth = InteractiveLoginAuthentication()\n",
" token_with_redirect = interactive_auth.get_access_token()\n",
" \n",
@ -455,7 +455,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.8.6"
}
},
"nbformat": 4,

Просмотреть файл

@ -29,14 +29,14 @@
},
"scripts": {
"build": "npm run build:lib && npm run build:nbextension",
"build:labextension": "npm run clean:labextension && mkdirp powerbi_client/labextension && cd powerbi_client/labextension && npm pack ../..",
"build:labextension": "npm run clean:labextension && mkdirp powerbiclient/labextension && cd powerbiclient/labextension && npm pack ../..",
"build:lib": "tsc",
"build:nbextension": "webpack -p",
"build:all": "npm run build:labextension && npm run build:nbextension",
"clean": "npm run clean:lib && npm run clean:nbextension",
"clean:lib": "rimraf lib",
"clean:labextension": "rimraf powerbi_client/labextension",
"clean:nbextension": "rimraf powerbi_client/nbextension/static/index.js",
"clean:labextension": "rimraf powerbiclient/labextension",
"clean:nbextension": "rimraf powerbiclient/nbextension/static/index.js",
"lint": "eslint . --ext .ts,.tsx --fix",
"lint:check": "eslint . --ext .ts,.tsx",
"prepack": "npm run build:lib",

Просмотреть файл

@ -1,5 +0,0 @@
{
"load_extensions": {
"powerbi_client/extension": true
}
}

5
powerbiclient.json Normal file
Просмотреть файл

@ -0,0 +1,5 @@
{
"load_extensions": {
"powerbiclient/extension": true
}
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -8,6 +8,6 @@ def _jupyter_nbextension_paths():
return [{
'section': 'notebook',
'src': 'nbextension/static',
'dest': 'powerbi_client',
'require': 'powerbi_client/extension'
'dest': 'powerbiclient',
'require': 'powerbiclient/extension'
}]

Просмотреть файл

@ -6,7 +6,7 @@ define(function() {
window['requirejs'].config({
map: {
'*': {
'powerbi-client-frontend': 'nbextensions/powerbi_client/index',
'powerbi-client-frontend': 'nbextensions/powerbiclient/index',
},
}
});

Просмотреть файл

@ -86,10 +86,8 @@ class Report(DOMWidget):
container_width = Float(0).tag(sync=True)
# TODO: Add trait validation
# TODO: Start with _
export_visual_data_request = Dict(None).tag(sync=True)
# TODO: Start with _
visual_data = Unicode(VISUAL_DATA_DEFAULT_STATE).tag(sync=True)
_export_visual_data_request = Dict(None).tag(sync=True)
_visual_data = Unicode(VISUAL_DATA_DEFAULT_STATE).tag(sync=True)
_event_data = Dict(EVENT_DATA_DEFAULT_STATE).tag(sync=True)
@ -208,7 +206,7 @@ class Report(DOMWidget):
raise Exception(self.REPORT_NOT_EMBEDDED_MESSAGE)
# Start exporting data on client side
self.export_visual_data_request = {
self._export_visual_data_request = {
'pageName': page_name,
'visualName': visual_name,
'rows': rows,
@ -220,15 +218,15 @@ class Report(DOMWidget):
# Wait for client-side to send visual data
with ui_events() as ui_poll:
# While visual data is not received
while self.visual_data == self.VISUAL_DATA_DEFAULT_STATE:
while self._visual_data == self.VISUAL_DATA_DEFAULT_STATE:
ui_poll(self.PROCESS_EVENTS_ITERATION)
time.sleep(self.POLLING_INTERVAL)
exported_data = self.visual_data
exported_data = self._visual_data
# Reset the export_visual_data_request and visual_data's value
self.export_visual_data_request = dict(self.EXPORT_VISUAL_DATA_REQUEST_DEFAULT_STATE)
self.visual_data = self.VISUAL_DATA_DEFAULT_STATE
# Reset the _export_visual_data_request and _visual_data's value
self._export_visual_data_request = dict(self.EXPORT_VISUAL_DATA_REQUEST_DEFAULT_STATE)
self._visual_data = self.VISUAL_DATA_DEFAULT_STATE
return exported_data

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -7,7 +7,7 @@
def test_nbextension_path():
# Check that magic function can be imported from package root:
from powerbi_client import _jupyter_nbextension_paths
from powerbiclient import _jupyter_nbextension_paths
# Ensure that it can be called without incident:
path = _jupyter_nbextension_paths()
# Some sanity checks:

Просмотреть файл

@ -81,7 +81,7 @@ class TestSettingNewEmbedConfig:
new_embed_url = 'new_dummy_embed_url'
# Act
report.set_embed_config(access_token=new_access_token, embed_url=new_embed_url)
report._set_embed_config(access_token=new_access_token, embed_url=new_embed_url)
# Assert
assert report._embed_config == {
@ -175,7 +175,7 @@ class TestExportData:
# Arrange
report = Report(access_token=ACCESS_TOKEN, embed_url=EMBED_URL)
# Data sent by frontend (Setting this upfront will prevent extract_data from waiting for data)
report.visual_data = VISUAL_DATA
report._visual_data = VISUAL_DATA
report._embedded = True
# Act
@ -183,8 +183,8 @@ class TestExportData:
# Assert
assert returned_data == VISUAL_DATA
assert report.export_visual_data_request == report.EXPORT_VISUAL_DATA_REQUEST_DEFAULT_STATE
assert report.visual_data == report.VISUAL_DATA_DEFAULT_STATE
assert report._export_visual_data_request == report.EXPORT_VISUAL_DATA_REQUEST_DEFAULT_STATE
assert report._visual_data == report.VISUAL_DATA_DEFAULT_STATE
class TestGetPages:

Просмотреть файл

@ -1,4 +1,4 @@
[pytest]
testpaths = powerbi_client/tests examples
testpaths = powerbiclient/tests examples
norecursedirs = node_modules .ipynb_checkpoints
addopts = --nbval --current-env

Просмотреть файл

@ -19,7 +19,7 @@ from setuptools import setup
# The name of the project
name = 'powerbi_client'
name = 'powerbiclient'
# Ensure a valid python version
ensure_python('>=3.4')
@ -44,10 +44,10 @@ package_data_spec = {
}
data_files_spec = [
('share/jupyter/nbextensions/powerbi_client',
('share/jupyter/nbextensions/powerbiclient',
nb_path, '*.js*'),
('share/jupyter/lab/extensions', lab_path, '*.tgz'),
('etc/jupyter/nbconfig/notebook.d' , HERE, 'powerbi_client.json')
('etc/jupyter/nbconfig/notebook.d' , HERE, 'powerbiclient.json')
]

Просмотреть файл

@ -10,6 +10,6 @@
// dynamically.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(window as any).__webpack_public_path__ =
document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/powerbi_client';
document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/powerbiclient';
export * from './index';

Просмотреть файл

@ -52,8 +52,8 @@ export class ReportModel extends DOMWidgetModel {
_embedded: false,
container_height: 0,
container_width: 0,
export_visual_data_request: {},
visual_data: null,
_export_visual_data_request: {},
_visual_data: null,
_event_data: {
event_name: null,
event_details: null,
@ -124,17 +124,13 @@ export class ReportView extends DOMWidgetView {
this.reportContainer = newDivElement;
this.embed_configChanged();
this.embedConfigChanged();
// Observe changes in the traitlets in Python, and define custom callback.
this.model.on('change:_embed_config', this.embed_configChanged, this);
this.model.on('change:_embed_config', this.embedConfigChanged, this);
this.model.on('change:container_height', this.dimensionsChanged, this);
this.model.on('change:container_width', this.dimensionsChanged, this);
this.model.on(
'change:export_visual_data_request',
this.export_visual_data_requestChanged,
this
);
this.model.on('change:_export_visual_data_request', this.exportVisualDataRequestChanged, this);
this.model.on('change:_report_filters_request', this.reportFiltersChanged, this);
this.model.on('change:_get_pages_request', this.getPagesRequestChanged, this);
this.model.on('change:_get_visuals_page_name', this.getVisualsPageNameChanged, this);
@ -152,7 +148,7 @@ export class ReportView extends DOMWidgetView {
this.touch();
}
embed_configChanged(): void {
embedConfigChanged(): void {
const embedConfig = this.model.get('_embed_config');
const reportConfig = embedConfig as IReportEmbedConfiguration;
@ -249,31 +245,31 @@ export class ReportView extends DOMWidgetView {
this.touch();
}
async export_visual_data_requestChanged(): Promise<void> {
async exportVisualDataRequestChanged(): Promise<void> {
if (!this.report) {
console.error(REPORT_NOT_EMBEDDED_MESSAGE);
return;
}
const export_visual_data_request = this.model.get(
'export_visual_data_request'
const exportVisualDataRequest = this.model.get(
'_export_visual_data_request'
) as ExportVisualDataRequest;
// Check export visual data request object is null or empty
if (!export_visual_data_request || Object.keys(export_visual_data_request).length === 0) {
if (!exportVisualDataRequest || Object.keys(exportVisualDataRequest).length === 0) {
// This is the case of model reset
return;
}
if (!export_visual_data_request.pageName || !export_visual_data_request.visualName) {
if (!exportVisualDataRequest.pageName || !exportVisualDataRequest.visualName) {
console.error('Page and visual names are required');
return;
}
const pageName = export_visual_data_request.pageName;
const visualName = export_visual_data_request.visualName;
const dataRows = export_visual_data_request.rows;
const exportDataType = export_visual_data_request.underlyingData
const pageName = exportVisualDataRequest.pageName;
const visualName = exportVisualDataRequest.visualName;
const dataRows = exportVisualDataRequest.rows;
const exportDataType = exportVisualDataRequest.underlyingData
? models.ExportDataType.Underlying
: models.ExportDataType.Summarized;
@ -291,7 +287,7 @@ export class ReportView extends DOMWidgetView {
const data = await selectedVisual.exportData(exportDataType, dataRows);
// Update data
this.model.set('visual_data', data.data);
this.model.set('_visual_data', data.data);
this.touch();
} catch (error) {
console.error('Export visual data error:', error);

Просмотреть файл

@ -27,7 +27,7 @@ module.exports = [
entry: './src/extension.ts',
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'powerbi_client', 'nbextension', 'static'),
path: path.resolve(__dirname, 'powerbiclient', 'nbextension', 'static'),
libraryTarget: 'amd'
},
module: {