Skip to content

Commit 4d3fb48

Browse files
Update demos and contributing (#548)
* Remove deprecated Bio.Alphabet module * Added assets, updated layout_helper import, and fixed dcc.Loading css * Remove common directory and update requirements * Adding back common directory * Remove unnecessary gallery scripts and add common template * Updated CONTRIBUTING and CHANGELOG * Add extract-meta * Linting * Update CONTRIBUTING.md Co-authored-by: Alex Johnson <[email protected]> Co-authored-by: Alex Johnson <[email protected]>
1 parent ab64f01 commit 4d3fb48

File tree

135 files changed

+12377
-614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+12377
-614
lines changed

.buildpacks

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
* [#554](https://github.com/plotly/dash-bio/pull/554) Added additional props and arbitrary layout arguments to VolcanoPlot.
1313

1414

15+
### Fixed
16+
- [#550](https://github.com/plotly/dash-bio/pull/548) Updated CONTRIBUTING.md andbasic demo app structure. In addition, removed residual code and pre-deploy scripts associated with now-discontinued Dash Bio gallery.
17+
18+
1519
## [0.6.1] - 2021-02-15
1620
### Fixed
1721
* [#544](https://github.com/plotly/dash-bio/pull/544) Miscellaneous fixes for NglMoleculeViewer component.

CONTRIBUTING.md

Lines changed: 94 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Development
1+
# Development
22

3-
#### Prerequisites
3+
### Prerequisites
44

55
- [Git](https://git-scm.com/)
66
- [node.js](https://nodejs.org/en/). We recommend using node.js v10.x, but all
@@ -17,93 +17,101 @@
1717
client
1818
([setup instructions](http://faculty.smu.edu/reynolds/unixtut/windows.html)).
1919

20-
#### Step 1: Clone the dash-bio repo and install its dependencies
20+
## Step 1: Clone the dash-bio repo and install its dependencies
2121

2222
```bash
2323
git clone https://github.com/plotly/dash-bio.git
2424
cd dash-bio
2525
npm ci
2626
```
2727

28-
#### Step 2: Develop
28+
## Step 2: Develop
2929

30-
Development of a component for this repository comprises two parts:
30+
Development of a component for this repository is composed of two parts:
3131
the component itself, and a sample application that showcases the capabilities
3232
of your component and how it interacts with Dash.
3333

34-
##### Components
34+
### Components
3535
Components can either be created using React, or they can be written
3636
in pure Python. React components are written in `src/lib/components`
3737
before being compiled into Python components that are in the
3838
`dash_bio` folder. Python components are written in
3939
`dash_bio/component_factory/` and must be imported in
4040
`dash_bio/__init__.py`.
4141

42-
##### Installing new npm packages
42+
### Installing new npm packages
4343

4444
If developing a new component based on a React library, please ensure
4545
that you have already installed the correct versions of the
46-
preexisting dependencies by running `npm ci`. Then, add the package to
46+
pre-existing dependencies by running `npm ci`. Then, add the package to
4747
`package.json` and run `npm i` to add it to the `package-lock.json` file.
4848

49-
###### Naming components
49+
### Naming components
5050
Components, regardless of whether they are written using React or
5151
Python, need to be named in upper camel case. This is incredibly
5252
important due to the amount of parsing we perform in our testing suite
5353
and app deployments.
5454

55-
##### Demo applications
56-
Instead of creating standalone Dash apps for each component, there is a file
57-
structure in place to create a main "gallery" page that contains links to each
58-
(component) application. Consequently, the implementation of a component needs
59-
to follow a specific file structure for the corresponding app to be displayed
60-
and run correctly.
61-
62-
###### Setup
63-
In the `tests/dashbio_demos/` subfolder, please create a file named
64-
`app_{your component name in snake case}.py`. In this file, please include the
65-
following functions:
66-
67-
* `layout()` should return whatever you would have in your `app.layout`. Due to
68-
the way the CSS is set up for each application, it is advisable to create a
69-
container `div` that will house your application, e.g.,
70-
```python
71-
def layout():
72-
return html.Div(id='my-component-container', children=[
73-
"A sample component",
74-
dash_bio.MyComponent(id='my-component'),
75-
html.Div(id='my-component-output'),
76-
])
77-
```
78-
* `callbacks(app)` should contain all of the callbacks in the application and
79-
not return anything, e.g.,
80-
```python
81-
def callbacks(app):
82-
@app.callback(
83-
Output('my-component-output', 'children'),
84-
[Input('my-component', 'someProperty')]
85-
)
86-
def update_output(property):
87-
return "Value: {}".format(str(property))
88-
```
89-
90-
###### Testing
55+
### Demo applications
56+
Dash Bio demo apps follow a standardized template and showcase the properties
57+
of the component and possible use-cases with sample datasets. The `assets` and
58+
`layout_helper.py` modules in the `common` subdirectory include the base CSS styling for
59+
demo apps and helper functions to generate the layout and callback structure to run
60+
the demo as a standalone Dash app. These should be added to your demo app directory
61+
to ensure that the layout and structure of your app is consistent when deployed
62+
to the Dash Gallery. See *Setup* below for more details on using `layout_helper.py`
63+
within your demo application.
64+
65+
### Setup
66+
In the `tests/dashbio_demos/common` subdirectory, you will find the minimal project structure for a Dash Bio demo app. This includes the following files:
67+
68+
* `app.py`: This contains your Python app code with the demo component. The `app.py` in this case contains a basic outline of the code required for a Dash Bio sample app, but it can be modified or replaced as necessary for a particular component or demo app. If you are using this template, please note the following:
69+
>* `layout()` should return whatever you would have in your `app.layout`. Due to
70+
>the way the CSS is set up for each application, it is advisable to create a
71+
>container `div` that will house your application, e.g.,
72+
>```python
73+
>def layout():
74+
> return html.Div(id='my-component-container', children=[
75+
> "A sample component",
76+
> dash_bio.MyComponent(id='my-component'),
77+
> html.Div(id='my-component-output'),
78+
> ])
79+
>```
80+
>* `callbacks(app)` should contain all of the callbacks in the application and
81+
>not return anything, e.g.,
82+
>```python
83+
>def callbacks(app):
84+
> @app.callback(
85+
> Output('my-component-output', 'children'),
86+
> [Input('my-component', 'someProperty')]
87+
> )
88+
> def update_output(property):
89+
> return "Value: {}".format(str(property))
90+
>```
91+
92+
* `requirements.txt`: A text file which includes all the Python dependencies that need to be installed in order to run the app.
93+
* `layout_helper.py`: A Python module with helper functions to generate the template app layout and callback structure for a Dash Bio gallery app.
94+
* `data`: A directory that can contain sample datasets.
95+
* `assets`: A directory which can contain custom CSS, JS, favicon, or styling assets. Dash will automatically serve all of the files that are included in this folder.
96+
* `Procfile`: Procfile is a required text file that declares which commands should be run by the server on startup like starting your app's web server, scheduling jobs and running background processes. For Dash Bio demo apps, it can remain unmodified.
97+
98+
99+
### Testing
91100
Test out your application by going to the repository's root directory and
92101
running
93102
94103
```bash
95-
python index.py
104+
python tests/dashbio_demos/{YOUR_DEMO_APP}/app.py
96105
```
97-
Then navigate to `localhost:8050` in your web browser. You should see the
98-
gallery page. To get to your application, click on the square that displays the
99-
name of your component upon hover.
106+
107+
Then navigate to `localhost:8050` in your web browser.
100108

101109
You will need to quit the Python application and rerun it if you have made
102110
changes to the Python file itself, or have recently rebuilt/reinstalled the
103111
Dash Bio package. To see updated CSS changes, you can simply reload the webpage
104-
in your browser.
112+
in your browser, or enable hot-reloading with [Dash Dev Tools](https://dash.plotly.com/devtools).
105113

106-
###### CSS
114+
### CSS
107115
All custom CSS stylesheets should go in the `assets/` folder. Please create a
108116
stylesheet with a filename specific to your component. In addition, all ids and
109117
class names in your application should be prefixed by the name of your
@@ -115,39 +123,39 @@ if you want to make a container `div` for your application as mentioned in the
115123
Setup subsection, please account for an extra height of `100px` that is taken
116124
up by the header when you are specifying the height of the container.
117125

118-
###### Final touches
126+
### Final touches
119127
In the `tests/dashbio_demos/images/` subfolder, please include a PNG file named
120128
`pic_{your component name in snake case}.png`.
121129

122130
In your demo app file, please include the following functions:
123-
* `description()` is responsible for the text that shows up on hovering over
131+
>* `description()` is responsible for the text that shows up on hovering over
124132
your application in the gallery page. It should return a short string with a
125133
description of the component, e.g.,
126-
```python
127-
def description():
128-
return "Display bioinformatics data with this component."
129-
```
130-
* `header_colors()` controls the appearance of the header for your application.
134+
>```python
135+
>def description():
136+
> return "Display bioinformatics data with this component."
137+
>```
138+
>* `header_colors()` controls the appearance of the header for your application.
131139
It should return a dictionary with any or all of the specified keys `bg_color`
132140
(string), `font_color` (string), and `light_logo` (boolean). Please change the
133141
background color from default, and try to choose one that isn't used for
134142
another application, e.g.,
135-
```python
136-
def header_colors():
137-
return {
138-
'bg_color': 'rgb(255, 0, 0)',
139-
'font_color': 'rgb(255, 255, 255)',
140-
'light_logo': True
141-
}
142-
```
143+
>```python
144+
>def header_colors():
145+
> return {
146+
> 'bg_color': 'rgb(255, 0, 0)',
147+
> 'font_color': 'rgb(255, 255, 255)',
148+
> 'light_logo': True
149+
> }
150+
>```
143151
144152
Please lint any additions to Python code with `pylint` and/or `flake8`.
145153
146154
Commit each changeset corresponding to a conceptual entity.
147155
Write commit messages at the imperative (e.g., "Document workflow").
148156
Each commit is small; a pull request typically consists of a few commits.
149157
150-
#### Step 3: Run tests locally
158+
## Step 3: Run tests locally
151159
152160
To run integration tests locally on, say, Google Chrome:
153161
```bash
@@ -160,7 +168,7 @@ pytest tests/integration #for testing all apps
160168
pytest tests/integration/test_yourNewApp #for testing only one app
161169
```
162170
Do not worry if you get errors running this last command. You will have to
163-
download a Chrome driver (Linux:chromium), install it, and add its path.
171+
download a Chrome driver (Linux:chromium), install it, and add it to your PATH.
164172
Follow what the error messages point to (this will be platform-specific).
165173
166174
To write more integration tests, please read this
@@ -173,26 +181,27 @@ python tests/unit/unit_test_data_setup.py
173181
npm run test
174182
```
175183
176-
#### Step 4: Rebuild the package if necessary
184+
## Step 4: Rebuild the package if necessary
177185
178186
If you have made changes to the JS code, then you need to rebuild the package:
179187
180188
```bash
181-
npm run build
189+
npm run build:all
182190
```
183191
184192
The auto-generated Python files will reflect your updates to the logic.
185193
If, instead, you have made changes to the layout, you do not need to rebuild
186194
the package.
187195
188-
#### Step 5: Submit a pull request (PR)
196+
## Step 5: Submit a pull request (PR)
189197
190-
Fill out the description template in the GitHub interface.
191-
When you submit the PR, a Heroku review app will be automatically created; it
192-
will remain available for 5 days.
198+
Fill out the description template in the GitHub interface. Please include a
199+
link to the original JavaScript component if your PR is porting a React component
200+
to Dash Bio, and any relevant details or sample datasets that might help with
201+
testing the component and demo app.
193202
194203
195-
### Deployment
204+
## Deployment
196205
197206
*Deployment is done from the `master` branch only.*
198207
@@ -207,39 +216,28 @@ remote add [app name]-test [deployment server git URL]`.
207216
208217
#### Step 2: Edit and commit app-specific files
209218
210-
##### Step 2a: Edit the `Procfile`
211-
Edit the `Procfile` at the root of the repository to say `gunicorn
212-
tests.dashbio_demos.app_name:server`, where `app_name` is the name of
213-
the app you want to deploy in the `tests/dashbio_demos/` folder.
214-
215-
##### Step 2b: Edit `config.py`
216-
Edit the `config.py` file at the root of the repository such that the variable
217-
`DASH_APP_NAME` be set to the name of your app, but with `app`
218-
replaced by `dash` and underscores (`_`) replaced by dashes
219-
(`-`). (e.g., for `app_manhattan_plot`, the `DASH_APP_NAME` variable
220-
should be set to `dash-manhattan-plot`.)
221-
222-
##### Step 2c: Commit the changes
223-
Commit the `Procfile` and `config.py`, but *do not push to the
224-
`dash-bio` repo*!
219+
>#### Step 2a: Edit the `Procfile`
220+
>Edit the `Procfile` at the root of the repository to say `web: gunicorn app:server`.
221+
>
222+
>#### Step 2b: Commit the changes
223+
>Commit the `Procfile` and other changes, but *do not push to the
224+
`dash-bio` repo* !
225225
226226
#### Step 3: Push to the playground server
227-
Run `git push [app name]-test master`. This will deploy the app
228-
on the playground server. Check that it works by visiting the URL that
229-
is displayed in the console. Try out a few of the callbacks to make
227+
Run `git subtree push --prefix tests/dashbio_demos/[app directory] [app name]-test master`. This will deploy the app on the playground server. Check that it works by visiting the URL that is displayed in the console. Try out a few of the callbacks to make
230228
sure that they are working.
231229
232230
#### Step 4: Initialize the app on the dash-gallery server and push to it
233231
Log into the `developers` account on
234232
[dash-gallery.plotly.host](dash-gallery.plotly.host) and follow the same
235233
instructions as in Step 1, but give this remote a different name
236-
(e.g., by running `git remote add gallery [deployment server git
237-
URL]`). Then, run `git push gallery master`.
234+
(e.g. by running `git remote add gallery [deployment server git
235+
URL]`). Then, run `git subtree push --prefix tests/dashbio_demos/[app directory] gallery master`.
238236
239237
#### Step 5: Undo the app-specific commit
240238
Run `git log` to find the ID of the commit prior to the one that you
241239
just made to change the `Procfile`. Then, reset your local branch to
242-
this commit so that the `index.py` app still deploys and runs
240+
this commit so that the `app.py` app still deploys and runs
243241
normally. You can do this by running `git reset --hard [commit ID]`.
244242
245243
#### Step 6: Ensure that your branch is even with `master`

Procfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

app.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)