-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R component generation - support different package structures #1125
Conversation
@tcbegley 🎉 This is great! I think you've opened our first community PR for contributions to the R package generator. I think this should be possible without too much effort on our end. |
Thanks very much @tcbegley! Very nice to see that these changes are all it takes to support a different structure like you have in Don't worry about that Percy diff - I actually have a fix for it in #1103, until we manage to merge that it's a known flakiness we can just approve when everything else is ready.
Absolutely, I appreciate seeing the code with minimal changes but you're right that we should rename them to match their actual meanings, as well as updating their descriptions in the And then we'll need to include tests of building a component suite using your structure. The test I have in mind doesn't quite exist using our base structure - I'd like to basically recreate a minimal repo in a subdirectory of the test dir here and call |
write_js_metadata copies javascript bundles and css etc. to inst/deps and hence needs the path to these artifacts, not just the project shortname
Oh cool! Very happy to have that distinction. I have been looking at this a bit more, I realised there was a problem with my first attempt. In
Yep that sounds like a good approach to me. I'm not in any particular rush (not least as I still have some work to do to understand how R packaging actually works in the first place...), so take all the time you need. |
I think @Marc-Andre-Rivet might be able to look into this one, which would be great! |
As part of writing tests for this PR, I've been having a look at the behavior of the generator for both standard and nested code generation. What I'm seeing is that the Py generator behaves fine for
What does not work with the Py generator is something like this: For the R generator, taking into consideration that the package name shouldn't be
would go a long way to ensure the R generated package has all artifacts. @tcbegley I think what I'm suggesting here would work with your project with some minor tweaks in the With the change above, I can now run:
This actually works but the js file seems to live in the wrong place, which is weird, assuming that something in DashR might be flattening the structure again? Test component code can be found in https://github.com/plotly/dash/tree/pr1125-tests/%40plotly/dash-generator-test-component-nested |
Thanks for looking into this @Marc-Andre-Rivet, sorry for being slow to get back to you. For reference I'm testing stuff out on a fork of dash-bootstrap-compoennts here. My current thinking is that we'll maintain a branch with the built R package that can be installed from with I pasted the changes you suggested into my fork of Dash and built mostly successfully. To get Specifically here I changed
to
and here I changed
to
Ideally I wouldn't have to change the Javascript bundle, so that the same code can be shared across Python, R, Julia versions, so I'm guessing there's probably a better way that I haven't figured out yet, but if you have a moment elaborate on what you had in mind for my EDIT - Oh, and FWIW I'm building with
|
@tcbegley I think the changes @Marc-Andre-Rivet has proposed will require component developers to stick with the original syntax instead, i.e.
but these proposed modifications within |
Yes. Definitely don't want component authors to have to go around and tweak the generated files for the various flavors of Dash or use a different project name. Should be as transparent as possible. In the same vein, you should always be able to generate by using your project's name With the
as discussed with @rpkyle it might be preferable for to generate this instead:
but it doesn't feel absolutely necessary. Started some work in DashR to support nested folders correctly: https://github.com/plotly/dashR/tree/pr1125-dashR, fingerprinting and file resolution on requests is working in most cases but needs debugging for the DashR internal resources. |
From the discussion in this PR with @rpkyle and @tcbegley, I propose supplanting this PR with #1203.
|
@tcbegley Will be closing this PR as superseded by #1203 and plotly/dashR#191. Thanks for pointing out and helping understanding the issue. In the next version of Dash, you should be able to generate your components package with the same name across all target languages with arbitrary artifact paths. Let us know if you run into additional issues! |
Thanks @Marc-Andre-Rivet! The tests you wrote were very helpful in clearing up my misunderstandings. By copying the structure of your
Clearly the dependency paths ought to be I ran with your changes to |
@tcbegley There is no code change in DashR, just added tests, so running DashR from |
Yes, I installed from your branch. I'll go back and check though, maybe I just messed up my virtual environments or something. I'll let you know if it doesn't work when I try it again. Thanks! |
@tcbegley I've forked / played around a bit with the dbc build here: Haven't tried to get all existing code working or anything (note the 🔪on component styles), but just to reach a point where the project builds and loads correctly in R. Sample app:
|
Thanks so much @Marc-Andre-Rivet! I've had pretty limited time for this recently and you are helping me get my head around the required changes much faster than I would by myself, really appreciate it! |
Hello,
I'd like to add support for dashR to dash-bootstrap-components. I hit a bit of a stumbling block though because we put the generated components in
dash_bootstrap_components/_components
, whereas the build pipeline in_r_components_generation.py
appears to use the project shortname as the assumed location of the generated components / package.json etc.Passing
dash_bootstrap_components/_components
as the project shortname doesn't resolve the issue as this is passed to importlib which then of course can't find a module by that name.This tentative PR contains what I believe to be a minimal change that allows me to build R components for dash-bootstrap-components. It splits the package name off from the front of the path to the generated components.
I have tested that my changes don't break the build processes for dash-core-components, dash-html-components and dash-table.
One point for discussion is that I think the variable names such as
project_shortname
are now misleading in some places, but I left them as is for now in the interest of making minimal changes.Anyway, very happy to discuss whether this is the right way forward or if there is a better solution.
Contributor Checklist
@rpkyle - I think this mostly falls under your remit? All of the changes are contained to
_r_components_generation.py
.