Skip to content

Commit f62576e

Browse files
committed
update instructions for updateplotlyjs command
1 parent bb7ee52 commit f62576e

1 file changed

Lines changed: 45 additions & 26 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -264,39 +264,58 @@ Two kinds of Jupyter support are included:
264264

265265
### Updating to a New Version of plotly.js
266266

267-
First, update the version of the `plotly.js` dependency in `js/package.json`.
268-
Once you have done that,
269-
run the `updateplotlyjs` command:
267+
We typically update the plotly.js version in plotly.py after every new plotly.js release.
270268

271-
```bash
272-
python commands.py updateplotlyjs
273-
```
269+
_Usually, the mostly-automated steps below are sufficient. However, in some cases, manual changes may be needed. For example, [plotly.js/#7580](https://github.com/plotly/plotly.js/pull/7580) required [#5464](https://github.com/plotly/plotly.py/pull/5464) and [#5465](https://github.com/plotly/plotly.py/pull/5465). This is most often the case when plotly.js is updated to accept additional value types for an attribute; plotly.py has its own validation layer which may need to be updated. When in doubt, test out a new plotly.js feature in plotly.py to verify that everything works._
274270

275-
This downloads new versions of `plot-schema.json` and `plotly.min.js` from the `plotly/plotly.js` GitHub repository
276-
and places them in `codegen/resources/` and `plotly/package_data/`, respectively.
271+
Steps to update plotly.js:
277272

278-
It then does the following:
279-
- Regenerates all of the `graph_objs` classes based on the new schema
280-
- Runs `npm install` in `js/` to refresh `js/package-lock.json` against the new `plotly.js`
281-
- Runs `npm run build` to rebuild the JupyterLab extension and FigureWidget bundles in `plotly/labextension` and `plotly/package_data/widgetbundle.js`.
273+
1. Create a new branch off of `main`.
282274

283-
Commit the updated files under:
284-
- `codegen/resources/`
285-
- `js/`
286-
- `plotly/graph_objs/`
287-
- `plotly/labextension/`
288-
- `plotly/offline/`
289-
- `plotly/package_data/`
275+
2. Manually update the version of the `plotly.js` dependency in `js/package.json`.
290276

291-
If you need to skip the `npm` steps entirely (e.g. `npm` isn't available),
292-
set the `SKIP_NPM=1` environment variable:
277+
3. Run the `updateplotlyjs` command:
293278

294-
```bash
295-
SKIP_NPM=1 python commands.py updateplotlyjs
296-
```
279+
```bash
280+
python commands.py updateplotlyjs
281+
```
297282

298-
If you do skip it, you'll need to find a way to manually run `npm install && npm run build` in `js/` before committing,
299-
so that the lockfile and build artifacts stay in sync with `js/package.json`.
283+
This command does the following:
284+
285+
- Downloads new versions of `plot-schema.json` and `plotly.min.js` from the [plotly.js GitHub repository](https://github.com/plotly/plotly.js)
286+
and places them in `codegen/resources/` and `plotly/package_data/`, respectively.
287+
- Updates `plotly/offline/_plotlyjs_version.py` with the new version
288+
- Regenerates all of the classes under `graph_objs/` (`go.Figure`, `go.Layout`, etc.), and `plotly/validators/_validators.json`, based on the new schema
289+
- Runs `npm install` in `js/` to update `js/package-lock.json`
290+
- Runs `npm run build` in `js/` to rebuild the JupyterLab extension and FigureWidget bundles, which updates the artifacts in `plotly/labextension` and `plotly/package_data/widgetbundle.js`.
291+
292+
> Note: To skip the `npm` steps entirely (e.g. if `npm` isn't available), you can set the `SKIP_NPM=1` environment variable:
293+
>
294+
> ```bash
295+
> SKIP_NPM=1 python commands.py updateplotlyjs
296+
> ```
297+
>
298+
> However, before proceeding further, you'll still need to somehow run `npm install && npm run build` in `js/` before committing, so that the lockfile and build artifacts stay in sync with `js/package.json`.
299+
300+
4. Commit the updated files under:
301+
- `codegen/resources/`
302+
- `js/`
303+
- `plotly/graph_objs/`
304+
- `plotly/labextension/`
305+
- `plotly/offline/`
306+
- `plotly/package_data/`
307+
308+
5. To double-check that the update worked properly, you can use this one-liner:
309+
310+
```bash
311+
pip install -e . && python -c "import plotly.graph_objects as go; fig = go.Figure([go.Scatter(y=[2,1,3])]); fig.show()"
312+
```
313+
314+
The plot will open in a browser window; hover over the Plotly logo in the modebar in the upper-right corner to verify that the plotly.js version is correct.
315+
316+
6. Open a PR into `main`.
317+
318+
7. Add a changelog entry to `CHANGELOG.md` with a link to the PR. We typically mention the version update, link to the plotly.js GitHub release page, and list out the most important changes. Follow the format of previous plotly.js version bump changelog updates.
300319

301320
### Using a Development Branch of Plotly.js
302321

0 commit comments

Comments
 (0)