Skip to content

Commit b558ca5

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

1 file changed

Lines changed: 41 additions & 26 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -264,39 +264,54 @@ 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+
1. Create a new branch off of `main`.
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+
2. Manually update the version of the `plotly.js` dependency in `js/package.json`.
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+
3. Run the `updateplotlyjs` command:
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+
```bash
278+
python commands.py updateplotlyjs
279+
```
293280

294-
```bash
295-
SKIP_NPM=1 python commands.py updateplotlyjs
296-
```
281+
This command does the following:
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+
- Downloads new versions of `plot-schema.json` and `plotly.min.js` from the [plotly.js GitHub repository](https://github.com/plotly/plotly.js)
284+
and places them in `codegen/resources/` and `plotly/package_data/`, respectively.
285+
- Updates `plotly/offline/_plotlyjs_version.py` with the new version
286+
- Regenerates all of the classes under `graph_objs/` (`go.Figure`, `go.Layout`, etc.), and `plotly/validators/_validators.json`, based on the new schema
287+
- Runs `npm install` in `js/` to update `js/package-lock.json`
288+
- 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`.
289+
290+
> Note: To skip the `npm` steps entirely (e.g. if `npm` isn't available), you can set the `SKIP_NPM=1` environment variable:
291+
>
292+
> ```bash
293+
> SKIP_NPM=1 python commands.py updateplotlyjs
294+
> ```
295+
>
296+
> 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`.
297+
298+
4. Commit the updated files under:
299+
- `codegen/resources/`
300+
- `js/`
301+
- `plotly/graph_objs/`
302+
- `plotly/labextension/`
303+
- `plotly/offline/`
304+
- `plotly/package_data/`
305+
306+
5. To double-check that the update worked properly, you can use this one-liner:
307+
308+
```bash
309+
pip install -e . && python -c "import plotly.graph_objects as go; fig = go.Figure([go.Scatter(y=[2,1,3])]); fig.show()"
310+
```
311+
312+
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.
313+
314+
6. Open a PR into `main`.
300315

301316
### Using a Development Branch of Plotly.js
302317

0 commit comments

Comments
 (0)