Dash: [BUG] R component generation fails due to empty alldist variable

Created on 17 Dec 2019  路  3Comments  路  Source: plotly/dash

Environment:

dash                 1.7.0
dash-core-components 1.6.0
dash-html-components 1.0.2
dash-renderer        1.2.2
dash-table           4.5.1

Describe the bug

This bug occurs when building a new dash component.

When running npm run build the generation of the r package failed with:

TypeError: sequence item 1: expected str instance, list found

Tip: _r_components_generation.py looks strange if neither mod._js_dist nor mod._css_dist is defined.

Expected behavior

The new component get's build without errors.

dash-type-bug

Most helpful comment

Hi @rpkyle, I'm not sure from your comment how to resolve this issue? Following the Dash component cookiecutter, it doesn't seem like there are separate build commands available: npm run build makes both the Python and R versions and we run into this error above.

All 3 comments

@lochbrunner Hello Matthias, thanks for filing this report. I'm sorry that you've run into a snag here, but I'll try to explain why this occurs.

When I originally wrote the R package generator, I took advantage of the existing Python build process -- the Python code which builds the R packages uses _js_dist and _css_dist (when present) to define metadata necessary for loading *.js, *.js.map and *.css assets from generated packages. That occurs here:

https://github.com/plotly/dash/blob/e622f2a31202302d0c305c56e738d1ea369403e6/dash/development/_r_components_generation.py#L260

The end result is an R function which returns a list object with all dependencies for a given package, such as dashCoreComponents:::.dashCoreComponents_js_metadata(), seen here:

https://github.com/plotly/dash-core-components/blob/c107e0fc5e5c6e7a238e5570ea6a619533121575/R/internal.R

Initially, this was done for compatibility with htmltools, but also to avoid a component developer needing to use R at any stage of the build process. We've retained this feature for the latter reason.

Ideally, we would store R-related metadata like this in dash-info.yaml, but originally we lacked a uniform mechanism for automated import of dependencies, examples, and package descriptions, etc. A YAML file is now used for any items that are irrelevant to Python development, but required for full automation of R packaging.

We have discussed eventually migrating the package generation code to JavaScript, for all backends, to avoid developers having to install either R or Python to build component libraries, but it's not a current priority.

For now, we recommend building R components _after_ building the Python version of the component library. This is what we do for dashHtmlComponents, dashCoreComponents, and dashTable using the command

npm run build

... for other Dash libraries, you'll just want to break this into two steps:

npm run build
npm run build:r

In closing, I'd say this is not a bug _per se_, but the current behaviour required by the generator. I'm going to close this issue as a result, but feel free to reply if I've misunderstood or I can assist in some way.

(I've made a few additional improvements in plotly/dash#1048 for R packaging, but please do let us know if you have any suggestions or comments regarding the current approach.)

Hi @rpkyle, I'm not sure from your comment how to resolve this issue? Following the Dash component cookiecutter, it doesn't seem like there are separate build commands available: npm run build makes both the Python and R versions and we run into this error above.

@rpkyle the bug is fact the build procedure is not working as intended (or at all). The comment did not address how to solve the problem, which still persists half a year later. I feel like the issue should be reopened until a solution is provided - as currently, it means that the library does not work at all...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ninjakx picture ninjakx  路  3Comments

Mondrik picture Mondrik  路  3Comments

Jerry-Ma picture Jerry-Ma  路  3Comments

ncdingari picture ncdingari  路  4Comments

T4rk1n picture T4rk1n  路  3Comments