Skip to content

Comments

Pre-release packaging improvements for Dash for R#783

Merged
byronz merged 38 commits intomasterfrom
modify-R-deps-handling
Jul 5, 2019
Merged

Pre-release packaging improvements for Dash for R#783
byronz merged 38 commits intomasterfrom
modify-R-deps-handling

Conversation

@rpkyle
Copy link
Contributor

@rpkyle rpkyle commented Jun 19, 2019

This PR proposes several modifications to the R package generator invoked by dash-generate-components:

  • correct a 🐛 in assert_valid_wildcards (use names(args) instead of args)
  • correct a 🐛 in usage blocks for generated R documentation (duplicated component names)
  • support for dynamic (i.e. developer-specified) wildcards besides data-* and aria-*
  • support for documenting component-specific wildcards
  • replace assert_valid_wildcards with dash_assert_valid_wildcards in generated components
  • 🔪 filter_null in generated components, inline the logic provided by this function
  • remove the leading comma from the Imports: field, as only the Depends: field has a hardcoded entry (for the R binary itself)
  • add the option to specify a package Maintainer: field
  • add support for storing R package metadata in dash-info.yaml
  • remove a hardcoded dependency on dash package (CLI arguments to dash-generate-components may be used instead)

Closes #777, related to #788.

@rpkyle rpkyle requested a review from alexcjohnson June 19, 2019 22:41
@rpkyle rpkyle requested a review from byronz as a code owner June 19, 2019 22:41
@rpkyle rpkyle self-assigned this Jun 19, 2019
@rpkyle rpkyle changed the title Rename component helpers and remove dash dep Rename R component helpers and remove dependency on dash Jun 19, 2019

# Filter props to remove those we don't want to expose
for item in prop_keys[:]:
if item.endswith("-*") or item in r_keywords or item == "setProps":
Copy link
Collaborator

Choose a reason for hiding this comment

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

also not new in this PR, but item in r_keywords worries me to just be silently dropped - if nothing else it seems like this should log a warning. Do any of our own components use R keywords?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Added a warning if we drop something from r_keywords, in e35f040

We should keep an eye out for this when rebuilding all the components - if we never see this warning, perhaps we can lock the R keywords out by turning the warning into an error.

file_path = os.path.join("R", file_name)
with open(file_path, "w") as f:
f.write(function_string)
f.write(component_helpers)
Copy link
Collaborator

Choose a reason for hiding this comment

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

if has_wildcards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in c6a013a

Copy link
Collaborator

Choose a reason for hiding this comment

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

Somehow this change (only adding dash_assert_valid_wildcards to internal.R if needed by a component) was reverted - was that intended?

Copy link
Contributor Author

@rpkyle rpkyle Jun 26, 2019

Choose a reason for hiding this comment

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

Yes. I am uncertain about how to check for wildcards without passing props to methods that ordinarily would not require them; would making has_wildcards a global variable be appropriate in this case? I would like to avoid refactoring too much this week, I still have a bit to do outside of Python code maintenance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just looped through the metadata for wildcards again -> 15cbea8

@rpkyle rpkyle changed the title Rename R component helpers and remove dependency on dash Pre-release packaging improvements for Dash for R Jun 21, 2019
@rpkyle rpkyle requested a review from Marc-Andre-Rivet as a code owner June 29, 2019 02:09
@alexcjohnson
Copy link
Collaborator

I can't figure out what's going on with the python 3 tests here - some sort of error deep in Flask... what changed?

I notice BTW that our requirements call for Flask>=0.12 and yet we're getting Flask@1.0.

FWIW I see these same errors running the tests locally, yet in the same environment I can run a normal dash app just fine.

@byronz can you take a look?

import functools

import pkg_resources
import yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

@rpkyle I think the performance import pattern in official yaml doc is still valid.

try:
    from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
    from yaml import Loader, Dumper


# dash.testing
pytest
pytest<5.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

temporary ⬇️ pytest version until the fix in flask is released pallets/flask#3278

@rpkyle the unit tests all passed in circleci now

item_text += '\n\n\\item{...}{wildcards: `data-*` or `aria-*`}'
if any(key.endswith("-*") for key in prop_keys):
default_argtext += ', ...'
item_text += wildcard_help_template.format(get_wildcards_r(prop_keys))
Copy link
Contributor

Choose a reason for hiding this comment

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

🐄 minor: always try to use list for str operation += might be expensive if it's in a big loop

write_js_metadata(pkg_data, project_shortname, has_wildcards)

with open("NAMESPACE", "w") as f:
with open("NAMESPACE", "w+") as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

🐮 minor it's personal preference, but I would avoid f with numbers, maybe for example fp_ns, fp_desr

Copy link
Contributor

@byronz byronz left a comment

Choose a reason for hiding this comment

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

💃 LGTM

@byronz byronz merged commit b41a533 into master Jul 5, 2019
@byronz byronz deleted the modify-R-deps-handling branch July 5, 2019 19:20
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.

Generated R packages should support dynamic wildcards

3 participants