From c53cdc9a0e0565e7a64dcc24c73eb70f2d6470f1 Mon Sep 17 00:00:00 2001 From: byron Date: Mon, 26 Aug 2019 14:32:23 -0400 Subject: [PATCH 1/7] rework on the graph id cases, the behavior has been changed with alex's fix --- tests/integration/graph/test_graph_basics.py | 22 ++++++++++++++++++++ tests/test_integration_2.py | 18 ---------------- 2 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 tests/integration/graph/test_graph_basics.py diff --git a/tests/integration/graph/test_graph_basics.py b/tests/integration/graph/test_graph_basics.py new file mode 100644 index 000000000..960e22ee3 --- /dev/null +++ b/tests/integration/graph/test_graph_basics.py @@ -0,0 +1,22 @@ +import dash +import dash_html_components as html +import dash_core_components as dcc + + +def test_grbs001_graph_without_ids(dash_duo): + app = dash.Dash(__name__) + app.layout = html.Div( + [ + dcc.Graph(className="graph-no-id-1"), + dcc.Graph(className="graph-no-id-2"), + ] + ) + + dash_duo.start_server(app) + + assert not dash_duo.wait_for_element(".graph-no-id-1").get_attribute( + "id" + ), "the graph should contain no more auto-generated id" + assert not dash_duo.wait_for_element(".graph-no-id-2").get_attribute( + "id" + ), "the graph should contain no more auto-generated id" diff --git a/tests/test_integration_2.py b/tests/test_integration_2.py index 79d2e59c7..0670d84a8 100644 --- a/tests/test_integration_2.py +++ b/tests/test_integration_2.py @@ -230,24 +230,6 @@ def show_relayout_data(data): "#relayout-data", '{"xaxis.autorange": true}' ) - def test_graphs_without_ids(self): - app = dash.Dash(__name__) - app.layout = html.Div( - [ - dcc.Graph(className="graph-no-id-1"), - dcc.Graph(className="graph-no-id-2"), - ] - ) - - self.startServer(app=app) - - graph_1 = self.wait_for_element_by_css_selector(".graph-no-id-1") - graph_2 = self.wait_for_element_by_css_selector(".graph-no-id-2") - - self.assertNotEqual( - graph_1.get_attribute("id"), graph_2.get_attribute("id") - ) - def test_interval(self): app = dash.Dash(__name__) app.layout = html.Div( From ebd450c13593bd88b32891eb6250c0c32c785633 Mon Sep 17 00:00:00 2001 From: byron Date: Mon, 26 Aug 2019 14:32:59 -0400 Subject: [PATCH 2/7] adda the dash import test back, but only for python3 --- tests/test_dash_import.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_dash_import.py b/tests/test_dash_import.py index 64fb350ec..cad72f553 100644 --- a/tests/test_dash_import.py +++ b/tests/test_dash_import.py @@ -1,23 +1,25 @@ import os +import sys import unittest class TestDashImport(unittest.TestCase): def setUp(self): - with open('dash.py', 'w') as f: + with open("dash.py", "w") as _: pass def tearDown(self): try: - os.remove('dash.py') - os.remove('dash.pyc') + os.remove("dash.py") + os.remove("dash.pyc") except OSError: pass + @unittest.skipIf(sys.version_info[0] == 2, "only run in python3") def test_dash_import(self): """Test that program exits if the wrong dash module was imported""" with self.assertRaises(SystemExit) as cm: - import dash_core_components + import dash_core_components # noqa self.assertEqual(cm.exception.code, 1) From a71232f1f21c1e2feca09a78bbe9000dbdacc218 Mon Sep 17 00:00:00 2001 From: byron Date: Mon, 26 Aug 2019 14:33:07 -0400 Subject: [PATCH 3/7] lint --- src/components/Graph.react.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Graph.react.js b/src/components/Graph.react.js index 4aedd046e..1086c9010 100644 --- a/src/components/Graph.react.js +++ b/src/components/Graph.react.js @@ -105,8 +105,8 @@ class PlotlyGraph extends Component { } // in case we've made a new DOM element, transfer events - if(this._hasPlotted && gd !== this._prevGd) { - if(this._prevGd && this._prevGd.removeAllListeners) { + if (this._hasPlotted && gd !== this._prevGd) { + if (this._prevGd && this._prevGd.removeAllListeners) { this._prevGd.removeAllListeners(); Plotly.purge(this._prevGd); } From 95cdad985b468f49c59c3409f69e59eb697208fc Mon Sep 17 00:00:00 2001 From: byron Date: Mon, 26 Aug 2019 14:33:27 -0400 Subject: [PATCH 4/7] editor config aligned with dash one --- .editorconfig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 5b462cccd..6a663e566 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,18 @@ -root = true +# EditorConfig is awesome: https://EditorConfig.org +# Unix-style newlines with a newline ending every file [*] +end_of_line = lf insert_final_newline = true + +# Matches multiple files with brace expansion notation +# Set default charset +[*.{js,py}] +charset = utf-8 +indent_style = space +indent_size = 4 + +# Matches the exact files either package.json or .travis.yml +[{package.json,.circleci/config.yml}] +indent_style = space +indent_size = 2 \ No newline at end of file From 28ad505b44185c742de85eb5919e058e4229345f Mon Sep 17 00:00:00 2001 From: byron Date: Mon, 26 Aug 2019 14:33:53 -0400 Subject: [PATCH 5/7] :wrench: adapt to new renderer change --- .circleci/config.yml | 7 ++++--- package.json | 6 +++--- setup.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3c31a50a9..2af0df611 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,7 +31,7 @@ jobs: name: 🌸 Lint command: | . venv/bin/activate - npm i --ignore-scripts && npm i --ignore-scripts --only=dev + npm i --ignore-scripts npm run format:test && npm run lint flake8 --ignore=E501,F401,F841,F811,W503 tests - run: @@ -80,8 +80,8 @@ jobs: . venv/bin/activate && pip install --upgrade -e . --quiet && mkdir packages # build main dash git clone --depth 1 https://github.com/plotly/dash.git dash-main - cd dash-main && pip install -e .[ci,testing] && python setup.py sdist && mv dist/* ../packages/ - cd dash-renderer && npm i --ignore-scripts && npm run build + cd dash-main && pip install -e .[dev,testing] && python setup.py sdist && mv dist/* ../packages/ + cd dash-renderer && npm run build python setup.py sdist && mv dist/* ../../packages/ && cd ../.. # build dcc npm i --ignore-scripts && npm run build && python setup.py sdist && mv dist/* ./packages @@ -175,6 +175,7 @@ jobs: . venv/bin/activate && cd packages && ls -la && mv dash-*.tar.gz main.tar.gz pip install main.tar.gz[testing] --quiet && pip list | grep dash | xargs pip uninstall -y find . -name "dash*.gz" | xargs pip install && pip install main.tar.gz && pip list | grep dash && cd .. + npm run test:pyimport TESTFILES=$(circleci tests glob "tests/test_integration_*.py" | circleci tests split --split-by=timings) pytest --durations=10 --junitxml=test-reports/junit_legacy.xml ${TESTFILES} - store_artifacts: diff --git a/package.json b/package.json index 798d7e3ed..fa0b8d5a7 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,10 @@ "start": "webpack-serve ./webpack.serve.config.js --open", "lint": "eslint src tests", "lint:py": "flake8 --ignore=E501,F401,F841,F811,W503 tests", - "test": "run-s -c lint lint:py format:test test-unit test:py test:intg", - "test:py": "pytest tests/test_integration.py", + "test": "run-s -c lint lint:py format:test test-unit test:legacy test:intg test:pyimport", + "test:legacy": "pytest tests/test_integration*.py", "test:intg": "pytest --nopercyfinalize --headless tests/integration", - "test:pyimport": "pytest tests/test_dash_import.py", + "test:pyimport": "python -m unittest tests.test_dash_import", "test-unit": "jest", "format": "prettier --config .prettierrc --write src/**/*.js tests/unit/*.js", "format:test": "prettier --config .prettierrc src/**/*.js tests/unit/*.js --list-different", diff --git a/setup.py b/setup.py index f6a4c32a7..6a8d1d753 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,6 @@ packages=[package_name], include_package_data=True, license=package['license'], - description=package['description'] if 'description' in package else package_name, + description=package.get("descirption", package_name), install_requires=[] ) From bc6bdc49b697604e704cc4e72830db02df77dcc1 Mon Sep 17 00:00:00 2001 From: byron Date: Mon, 26 Aug 2019 14:34:18 -0400 Subject: [PATCH 6/7] :memo: paper work --- CONTRIBUTING.md | 25 ------------------------- LICENSE.txt | 2 +- README.md | 49 +++++++++++++++---------------------------------- 3 files changed, 16 insertions(+), 60 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6ec88965..489b4e1d3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,31 +24,6 @@ you've pulled from upstream otherwise you may be running with an out of date `bundle.js`. See the instructions for building `bundle.js` in the [Testing Locally](README.md#testing-locally) section of README.md. -You also need to set the environment variable `TOX_PYTHON_27` and with the -location of the Python 2 installations you want tox to use for creating the -virtualenv that will be used to run the tests. Note that this means you do not -need to install any dependencies into the installation yourself. - -If you're using pyenv to manage Python installations, you would do something -like this: - -``` -export TOX_PYTHON_27=~/.pyenv/versions/2.7.14/bin/python -``` - -## Local configuration -You can configure the test server with the following variables: -### DASH_TEST_CHROMEPATH -If you run a special chrome set the path to your chrome binary with this environment variable. - -### DASH_TEST_PROCESSES -If you encounter errors about Multi-server + Multi-processing when running under Python 3 try running the tests with the number of server processes set to 1. - -### Example: single test run with configuration -``` -DASH_TEST_CHROMEPATH=/bin/google-chrome-beta DASH_TEST_PROCESSES=1 python -m unittest -v test.test_integration.Tests.test_inputs -``` - ## Publishing New Components/Features For now, multiple steps are necessary for publishing to NPM and PyPi, diff --git a/LICENSE.txt b/LICENSE.txt index e8c2b74ec..69aae53a6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 MIT +Copyright (c) 2019 MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index d3184f749..de0d95a2b 100644 --- a/README.md +++ b/README.md @@ -6,40 +6,27 @@ This package provides the core React component suite for [Dash][]. ## Development -### Testing Locally +The `dash` package contains some tools to build components and drive the bundles build process. +To avoid the circular dependency situation, we don't add `dash` as a required install in the `dash-core-components` setup. +But, in order to do development locally, you need to install `dash` before everything. 1. Install the dependencies with: -``` -$ npm i -``` - -2. Build the code: - -``` -$ npm run build -``` - -3. Install the library - -``` -$ python setup.py install -``` +```bash +# it's recommended to install your python packages in a virtualenv +# python 2 +$ pip install virtualenv --user && virtualenv venv && . venv/bin/activate +# python 3 +$ python -m venv && . venv/bin/activate -I recommend installing the library and running the examples in a fresh virtualenv in a separate folder: - -``` -$ mkdir dash_examples # create a new folder to test examples -$ cd dash_examples -$ virtualenv venv # create a virtual env -$ source venv/bin/activate # use the virtual env -``` +# make sure dash is installed with dev and testing dependencies +$ pip install dash[dev,testing] # in some shells you need \ to escape [] -(and then repeat step 3). +# run the build process +$ npm i --ignore-scripts && npm run build -4. Add the following line to your Dash app -``` -app.scripts.config.serve_locally = True +# install dcc in editable mode +$ pip install -e . ``` ### Demo server @@ -74,12 +61,6 @@ npm run test-unit # Import dash_core_components to your layout, then run it: $ python my_dash_layout.py -## Installing python package locally - -You can run - $ python setup.py install -to install the package locally, so you can test it out in your current environment. - ## Uninstalling python package locally ```sh From 10e17542d694c15c46097f859007572b2c601424 Mon Sep 17 00:00:00 2001 From: Byron Zhu Date: Mon, 26 Aug 2019 14:59:30 -0400 Subject: [PATCH 7/7] Update setup.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Marc-André Rivet --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6a8d1d753..60c37593a 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,6 @@ packages=[package_name], include_package_data=True, license=package['license'], - description=package.get("descirption", package_name), + description=package.get("description", package_name), install_requires=[] )