Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Circleci update #617

Merged
merged 7 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 15 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -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
25 changes: 0 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
49 changes: 15 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("description", package_name),
install_requires=[]
)
4 changes: 2 additions & 2 deletions src/components/Graph.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
22 changes: 22 additions & 0 deletions tests/integration/graph/test_graph_basics.py
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 6 additions & 4 deletions tests/test_dash_import.py
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 0 additions & 18 deletions tests/test_integration_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down