Skip to content
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

[WIP] Revised version of R 'transpiler' with support for generator methods #483

Merged
merged 57 commits into from
Dec 18, 2018

Conversation

rpkyle
Copy link
Contributor

@rpkyle rpkyle commented Dec 6, 2018

OK, I've taken a stab at using the new generator method approach to component generation for R. If you two don't mind having another look, would be much appreciated. Closes #445.

@rmarren1 @T4rk1n

(N.B. This PR is the up-to-date version of this closed PR)

@rpkyle rpkyle changed the title R2 [WIP] Revised version of R 'transpiler' with support for generator methods Dec 6, 2018
Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Move big templates string as global at top of the file to make methods logic more readable.
  • Improve the docstrings.
  • Add --r-prefix option.
  • Call os.makedirs only once in component_generator.
  • Imports at top of files.
  • Copy the whole js/css dist.
  • generate_rpkg should use .get for field access, can't be sure that a package.json will contain some the fields used.

dash/development/_r_components_generation.py Outdated Show resolved Hide resolved
dash/development/_r_components_generation.py Outdated Show resolved Hide resolved
dash/development/_r_components_generation.py Outdated Show resolved Hide resolved
dash/development/_r_components_generation.py Outdated Show resolved Hide resolved
dash/development/_r_components_generation.py Outdated Show resolved Hide resolved
dash/development/_r_components_generation.py Outdated Show resolved Hide resolved
dash/development/component_generator.py Outdated Show resolved Hide resolved
dash/development/component_generator.py Outdated Show resolved Hide resolved
dash/development/component_generator.py Outdated Show resolved Hide resolved
dash/development/component_generator.py Outdated Show resolved Hide resolved
Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just need to fix json_to_r_type and I think we're good to go.

Copy link
Contributor

@rmarren1 rmarren1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments, looks good overall!

dash/development/_r_components_generation.py Show resolved Hide resolved
dash/development/_r_components_generation.py Outdated Show resolved Hide resolved
@rpkyle
Copy link
Contributor Author

rpkyle commented Dec 14, 2018

Thanks for the additional reviews, I think the code has improved a lot -- both due to the useful factoring of the component generation in dash, but also because of the suggestions here and in the earlier PR.

@T4rk1n and I had a nice chat about json_to_r_type, before we 💃, I think I need to make some changes to this method, to handle two cases I missed previously:

  • if ['type']['name'] is custom, and the value is raw, the parameter type in R should be numeric() (or, more specifically, could be integer() or numeric())
  • if ['type']['name'] is enum, a bit more complicated to address: need to check option type in the value field, i.e. if option is 'click' the option type should be character(), but it could also be numeric(), or even an object in JSON

As for the other options:

  • if ['type']['name'] is func, node, or object, we're passing NULL for the time being

@rpkyle
Copy link
Contributor Author

rpkyle commented Dec 17, 2018

@T4rk1n Following up on our conversation from Friday, how does this version of props_to_r_type look?

dash/development/component_generator.py Outdated Show resolved Hide resolved
dash/development/component_generator.py Outdated Show resolved Hide resolved
dash/development/component_generator.py Outdated Show resolved Hide resolved
@rpkyle
Copy link
Contributor Author

rpkyle commented Dec 18, 2018

@T4rk1n Following up on our conversation from Friday, how does this version of props_to_r_type look?

Following productive discussion with @T4rk1n, PR appears ready to merge. Will now do so as all requested changes to code have been made.

@rpkyle rpkyle merged commit 7654c22 into master Dec 18, 2018
@rpkyle rpkyle deleted the R2 branch December 18, 2018 19:43
AnnMarieW pushed a commit to AnnMarieW/dash that referenced this pull request Jan 6, 2022
Modified Graph.react.js to include restyle event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

R code generation
4 participants