Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-André Rivet committed Jun 17, 2020
2 parents 404791b + 447a1d5 commit c69402f
Show file tree
Hide file tree
Showing 147 changed files with 9,809 additions and 4,870 deletions.
140 changes: 124 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

artifacts:
docker:
- image: circleci/python:3.7-stretch-node-browsers
- image: circleci/python:3.7.6-stretch-node-browsers
environment:
PYVERSION: python37
steps:
Expand All @@ -27,8 +27,9 @@ jobs:
lint-unit-37: &lint-unit
working_directory: ~/dash
docker:
- image: circleci/python:3.7-stretch-node-browsers
- image: circleci/python:3.7.6-stretch-node-browsers
environment:
PYLINTRC: .pylintrc37
PYVERSION: python37

steps:
Expand Down Expand Up @@ -58,30 +59,29 @@ jobs:
name: 🐍 Python Unit Tests & ☕ JS Unit Tests
command: |
. venv/bin/activate
npm run test.unit
npm run citest.unit
lint-unit-36:
<<: *lint-unit
docker:
- image: circleci/python:3.6-stretch-node-browsers
- image: circleci/python:3.6.9-stretch-node-browsers
environment:
PYLINTRC: .pylintrc
PYVERSION: python36

lint-unit-27:
<<: *lint-unit
docker:
- image: circleci/python:2.7-stretch-node-browsers
- image: circleci/python:2.7.18-stretch-node-browsers
environment:
PYLINTRC: .pylintrc
PYVERSION: python27

build-core-37: &build-core
working_directory: ~/dash
docker:
- image: circleci/python:3.7-stretch-node-browsers
- image: circleci/python:3.7.6-stretch-node-browsers
environment:
PYLINTRC: .pylintrc37
PYVERSION: python37
steps:
- checkout
Expand Down Expand Up @@ -115,21 +115,21 @@ jobs:
build-core-36:
<<: *build-core
docker:
- image: circleci/python:3.6-stretch-node-browsers
- image: circleci/python:3.6.9-stretch-node-browsers
environment:
PYVERSION: python36

build-core-27:
<<: *build-core
docker:
- image: circleci/python:2.7-stretch-node-browsers
- image: circleci/python:2.7.18-stretch-node-browsers
environment:
PYVERSION: python27

build-misc-37: &build-misc
working_directory: ~/dash
docker:
- image: circleci/python:3.7-stretch-node-browsers
- image: circleci/python:3.7.6-stretch-node-browsers
environment:
PYVERSION: python37

Expand Down Expand Up @@ -165,14 +165,14 @@ jobs:
build-misc-36:
<<: *build-misc
docker:
- image: circleci/python:3.6-stretch-node-browsers
- image: circleci/python:3.6.9-stretch-node-browsers
environment:
PYVERSION: python36

build-misc-27:
<<: *build-misc
docker:
- image: circleci/python:2.7-stretch-node-browsers
- image: circleci/python:2.7.18-stretch-node-browsers
environment:
PYVERSION: python27

Expand Down Expand Up @@ -213,10 +213,116 @@ jobs:
paths:
- packages/*.tar.gz

build-dashr:
working_directory: ~/dashr
docker:
- image: plotly/dashr:ci
environment:
PERCY_PARALLEL_TOTAL: -1
PYVERSION: python37
_R_CHECK_FORCE_SUGGESTS_: FALSE

steps:
- checkout

- run:
name: ️️🏭 clone and npm build core for R
command: |
python -m venv venv
. venv/bin/activate
npm ci
pip install --no-cache-dir --upgrade -e .[dev,testing] --progress-bar off
git clone --depth 1 https://github.com/plotly/dashR.git -b dev dashR
git clone --depth 1 https://github.com/plotly/dash-html-components.git
git clone --depth 1 https://github.com/plotly/dash-core-components.git
git clone --depth 1 https://github.com/plotly/dash-table.git
shopt -s extglob
cd dash-html-components; npm ci && npm run build; rm -rf !(.|..|DESCRIPTION|LICENSE.txt|LICENSE|NAMESPACE|.Rbuildignore|R|man|inst|vignettes|build)
cd ../dash-core-components; npm ci && npm run build; rm -rf !(.|..|DESCRIPTION|LICENSE.txt|LICENSE|NAMESPACE|.Rbuildignore|R|man|inst|vignettes|build)
cd ../dash-table; npm ci && npm run build; rm -rf !(.|..|DESCRIPTION|LICENSE.txt|LICENSE|NAMESPACE|.Rbuildignore|R|man|inst|vignettes|build); cd ..
- run:
name: 🔧fix up dash metadata
command: |
sudo Rscript -e 'dash_desc <- read.dcf("dashR/DESCRIPTION"); dt_version <- read.dcf("dash-table/DESCRIPTION")[,"Version"]; dcc_version <- read.dcf("dash-core-components/DESCRIPTION")[,"Version"]; dhc_version <- read.dcf("dash-html-components/DESCRIPTION")[,"Version"]; imports <- dash_desc[,"Imports"][[1]]; imports <- gsub("((?<=dashHtmlComponents )(\\\\(.*?\\\\)))", paste0("(= ", dhc_version, ")"), imports, perl = TRUE); imports <- gsub("((?<=dashCoreComponents )(\\\\(.*?\\\\)))", paste0("(= ", dcc_version, ")"), imports, perl = TRUE); imports <- gsub("((?<=dashTable )(\\\\(.*?\\\\)))", paste0("(= ", dt_version, ")"), imports, perl = TRUE); dash_desc[,"Imports"][[1]] <- imports; dhc_hash <- system("cd dash-html-components; git rev-parse HEAD | tr -d '\''\n'\''", intern=TRUE); dcc_hash <- system("cd dash-core-components; git rev-parse HEAD | tr -d '\''\n'\''", intern=TRUE); dt_hash <- system("cd dash-table; git rev-parse HEAD | tr -d '\''\n'\''", intern=TRUE); remotes <- dash_desc[,"Remotes"][[1]]; remotes <- gsub("((?<=plotly\\\\/dash-html-components@)([a-zA-Z0-9]+))", dhc_hash, remotes, perl=TRUE); remotes <- gsub("((?<=plotly\\\\/dash-core-components@)([a-zA-Z0-9]+))", dcc_hash, remotes, perl=TRUE); remotes <- gsub("((?<=plotly\\\\/dash-table@)([a-zA-Z0-9]+))", dt_hash, remotes, perl=TRUE); dash_desc[,"Remotes"][[1]] <- remotes; write.dcf(dash_desc, "dashR/DESCRIPTION")'
- run:
name: 🎛 set environment variables
command: |
Rscript --vanilla \
-e 'dash_dsc <- read.dcf("dashR/DESCRIPTION")' \
-e 'cat(sprintf("export DASH_TARBALL=%s_%s.tar.gz\n", dash_dsc[,"Package"], dash_dsc[,"Version"]))' \
-e 'cat(sprintf("export DASH_CHECK_DIR=%s.Rcheck\n", dash_dsc[,"Package"]))' \
-e 'dhc_dsc <- read.dcf("dash-html-components/DESCRIPTION")' \
-e 'cat(sprintf("export DHC_TARBALL=%s_%s.tar.gz\n", dhc_dsc[,"Package"], dhc_dsc[,"Version"]))' \
-e 'cat(sprintf("export DHC_CHECK_DIR=%s.Rcheck\n", dhc_dsc[,"Package"]))' \
-e 'dcc_dsc <- read.dcf("dash-core-components/DESCRIPTION")' \
-e 'cat(sprintf("export DCC_TARBALL=%s_%s.tar.gz\n", dcc_dsc[,"Package"], dcc_dsc[,"Version"]))' \
-e 'cat(sprintf("export DCC_CHECK_DIR=%s.Rcheck\n", dcc_dsc[,"Package"]))' \
-e 'dt_dsc <- read.dcf("dash-table/DESCRIPTION")' \
-e 'cat(sprintf("export DT_TARBALL=%s_%s.tar.gz\n", dt_dsc[,"Package"], dt_dsc[,"Version"]))' \
-e 'cat(sprintf("export DT_CHECK_DIR=%s.Rcheck\n", dt_dsc[,"Package"]))' \
>> ${BASH_ENV}
- run:
name: ️️📋 run CRAN package checks
command: |
R CMD build dash-core-components
R CMD build dash-html-components
R CMD build dash-table
R CMD build dashR
sudo R CMD INSTALL dash-core-components
sudo R CMD INSTALL dash-html-components
sudo R CMD INSTALL dash-table
sudo R CMD INSTALL dashR
R CMD check "${DHC_TARBALL}" --as-cran --no-manual
R CMD check "${DCC_TARBALL}" --as-cran --no-manual
R CMD check "${DT_TARBALL}" --as-cran --no-manual
R CMD check "${DASH_TARBALL}" --as-cran --no-manual
- run:
name: 🕵 detect failures
command: |
Rscript -e "message(devtools::check_failures(path = '${DHC_CHECK_DIR}'))"
Rscript -e "message(devtools::check_failures(path = '${DCC_CHECK_DIR}'))"
Rscript -e "message(devtools::check_failures(path = '${DT_CHECK_DIR}'))"
Rscript -e "message(devtools::check_failures(path = '${DASH_CHECK_DIR}'))"
# warnings are errors; enable for stricter checks once CRAN submission finished
# if grep -q -R "WARNING" "${DHC_CHECK_DIR}/00check.log"; then exit 1; fi
# if grep -q -R "WARNING" "${DCC_CHECK_DIR}/00check.log"; then exit 1; fi
# if grep -q -R "WARNING" "${DT_CHECK_DIR}/00check.log"; then exit 1; fi
# if grep -q -R "WARNING" "${DASH_CHECK_DIR}/00check.log"; then exit 1; fi
- run:
name: 🔎 run unit tests
command: |
sudo Rscript -e 'res=devtools::test("dashR/tests/", reporter=default_reporter());df=as.data.frame(res);if(sum(df$failed) > 0 || any(df$error)) {q(status=1)}'
- run:
name: ⚙️ Integration tests
command: |
python -m venv venv
. venv/bin/activate
npm run setup-tests.R
export PATH=$PATH:/home/circleci/.local/bin/
pytest --nopercyfinalize --junitxml=test-reports/dashr.xml dashR/tests/integration/dopsa/
- store_artifacts:
path: test-reports
- store_test_results:
path: test-reports
- store_artifacts:
path: /tmp/dash_artifacts

- run:
name: 🦔 percy finalize
command: npx percy finalize --all
when: on_fail


test-37: &test
working_directory: ~/dash
docker:
- image: circleci/python:3.7-stretch-node-browsers
- image: circleci/python:3.7.6-stretch-node-browsers
environment:
PERCY_PARALLEL_TOTAL: -1
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: True
Expand All @@ -243,7 +349,7 @@ jobs:
name: 🧪 Run Integration Tests
command: |
. venv/bin/activate
npm run test.integration
npm run citest.integration
- store_artifacts:
path: test-reports
- store_test_results:
Expand All @@ -258,15 +364,15 @@ jobs:
test-36:
<<: *test
docker:
- image: circleci/python:3.6-stretch-node-browsers
- image: circleci/python:3.6.9-stretch-node-browsers
environment:
PERCY_ENABLE: 0
PYVERSION: python36

test-27:
<<: *test
docker:
- image: circleci/python:2.7-stretch-node-browsers
- image: circleci/python:2.7.18-stretch-node-browsers
environment:
PERCY_ENABLE: 0
PYVERSION: python27
Expand All @@ -279,12 +385,14 @@ workflows:
- build-core-37
- build-windows-37
- build-misc-37
- build-dashr
- test-37:
requires:
- build-core-37
- build-misc-37
- percy-finalize:
requires:
- build-dashr
- test-37
- artifacts:
requires:
Expand Down
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ ignore-docstrings=yes
ignore-imports=no

# Minimum lines number of a similarity.
min-similarity-lines=10
min-similarity-lines=20


[SPELLING]
Expand Down Expand Up @@ -466,4 +466,4 @@ known-third-party=enchant

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=Exception
5 changes: 2 additions & 3 deletions .pylintrc37
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ ignore-docstrings=yes
ignore-imports=no

# Minimum lines number of a similarity.
min-similarity-lines=10

min-similarity-lines=20

[SPELLING]

Expand Down Expand Up @@ -565,4 +564,4 @@ known-third-party=enchant

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception".
overgeneral-exceptions=Exception
overgeneral-exceptions=Exception
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.13.0] - 2020-06-17
### Added
- [#1289](https://github.com/plotly/dash/pull/1289) Supports `DASH_PROXY` env var to tell `app.run_server` to report the correct URL to view your app, when it's being proxied. Throws an error if the proxy is incompatible with the host and port you've given the server.
- [#1240](https://github.com/plotly/dash/pull/1240) Adds `callback_context` to clientside callbacks (e.g. `dash_clientside.callback_context.triggered`). Supports `triggered`, `inputs`, `inputs_list`, `states`, and `states_list`, all of which closely resemble their serverside cousins.

### Changed
- [#1237](https://github.com/plotly/dash/pull/1237) Closes [#920](https://github.com/plotly/dash/issues/920): Converts hot reload fetch failures into a server status indicator showing whether the latest fetch succeeded or failed. Callback fetch failures still appear as errors but have a clearer message.
- [#1254](https://github.com/plotly/dash/pull/1254) Modifies the callback chain implementation and improves performance for apps with a lot of components

### Fixed
- [#1255](https://github.com/plotly/dash/pull/1255) Hard hot reload targets only the current window, not the top - so if your app is in an iframe you will only reload the app
- [#1249](https://github.com/plotly/dash/pull/1249) Fixes [#919](https://github.com/plotly/dash/issues/919) so `dash.testing` is compatible with more `pytest` plugins, particularly `pytest-flake8` and `pytest-black`.
- [#1248](https://github.com/plotly/dash/pull/1248) Fixes [#1245](https://github.com/plotly/dash/issues/1245), so you can use prop persistence with components that have dict IDs, ie for pattern-matching callbacks.
- [#1185](https://github.com/plotly/dash/pull/1185) Sort asset directories, same as we sort files inside those directories. This way if you need your assets loaded in a certain order, you can add prefixes to subdirectory names and enforce that order.
- [#1288](https://github.com/plotly/dash/pull/1288) Closes [#1285](https://github.com/plotly/dash/issues/1285): Debug=True should work in the __main__ module.

## [1.12.0] - 2020-05-05
### Added
- [#1228](https://github.com/plotly/dash/pull/1228) Adds control over firing callbacks on page (or layout chunk) load. Individual callbacks can have their initial calls disabled in their definition `@app.callback(..., prevent_initial_call=True)` and similar for `app.clientside_callback`. The app-wide default can also be changed with `app=Dash(prevent_initial_callbacks=True)`, then individual callbacks may disable this behavior.
Expand Down
17 changes: 10 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ $ pip install -e .[testing,dev] # in some shells you need \ to escape []
$ cd dash-renderer
# build renderer bundles, this will build all bundles from source code
# the only true source of npm version is defined in package.json
$ npm install
$ npm run build # or `renderer build`
# install dash-renderer for development
$ pip install -e .
# build and install components used in tests
$ cd .. # should be back in dash/ root directory
$ npm install
$ npm run setup-tests
# you should see both dash and dash-renderer are pointed to local source repos
$ pip list | grep dash
Expand Down Expand Up @@ -48,9 +51,7 @@ When a change in renderer code doesn't reflect in your browser as expected, this

Writing Python 2/3 compatible code might be a challenging task for contributors used to working on one particular version, especially new learners who start directly with Python 3.

From the #892, we started to adopt `python-future` instead of `six` as our tool to better achieve the goal where we can mainly write Python 3 code and make it back-compatible in Python 2.7 (last Python 2 version Dash supports before it gets deprecated).

Please refer to [this list of idioms](https://python-future.org/compatible_idioms.html "https://python-future.org/compatible_idioms.html") for more details on working with `python-future`.
We use `python-future` as our tool to mainly write Python 3 code and make it back-compatible to Python 2.7 (the only Python 2 version Dash supports). Please refer to [this list of idioms](https://python-future.org/compatible_idioms.html "https://python-future.org/compatible_idioms.html") for more details on working with `python-future`.

## Git

Expand Down Expand Up @@ -98,13 +99,15 @@ Emojis make the commit messages :cherry_blossom:. If you have no idea about what

### Coding Style

We use both `flake8` and `pylint` for basic linting check, please refer to the relevant steps in `.circleci/config.yml`.

Note that we also start using [`black`](https://black.readthedocs.io/en/stable/) as formatter during the test code migration.
We use `flake8`, `pylint`, and [`black`](https://black.readthedocs.io/en/stable/) for linting. please refer to the relevant steps in `.circleci/config.yml`.

## Tests

We started migrating to [pytest](https://docs.pytest.org/en/latest/) from `unittest` as our test automation framework. You will see more testing enhancements in the near future.
Our tests use Google Chrome via Selenium. You will need to install [ChromeDriver](http://chromedriver.chromium.org/getting-started) matching the version of Chrome installed on your system. Here are some helpful tips for [Mac](https://www.kenst.com/2015/03/installing-chromedriver-on-mac-osx/) and [Windows](http://jonathansoma.com/lede/foundations-2018/classes/selenium/selenium-windows-install/).

We use [pytest](https://docs.pytest.org/en/latest/) as our test automation framework, plus [jest](https://jestjs.io/) for a few renderer unit tests. You can `npm run test` to run them all, but this command simply runs `pytest` with no arguments, then `cd dash-renderer && npm run test` for the renderer unit tests.

Most of the time, however, you will want to just run a few relevant tests and let CI run the whole suite. `pytest` lets you specify a directory or file to run tests from (eg `pytest tests/unit`) or a part of the test case name using `-k` - for example `pytest -k cbcx004` will run a single test, or `pytest -k cbcx` will run that whole file. See the [testing tutorial](https://dash.plotly.com/testing) to learn about the test case ID convention we use.

### Unit Tests

Expand Down
9 changes: 9 additions & 0 deletions dash-renderer/@Types/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare module 'cookie' {
const value: {
parse: (cookie: string) => {
_csrf_token: string
}
};

export default value;
}
5 changes: 5 additions & 0 deletions dash-renderer/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
module.exports = {
presets: [
'@babel/preset-typescript',
'@babel/preset-env',
'@babel/preset-react'
],
plugins: [
'@babel/plugin-proposal-class-properties',
],
env: {
test: {
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-modules-commonjs'
]
}
Expand Down
Loading

0 comments on commit c69402f

Please sign in to comment.