Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Helper syntax for setting options for groups of targets #215

@noamross

Description

@noamross

Prework

  • I understand and agree to help guide.
  • I understand and agree to contributing guide.
  • New features take time and effort to create, and they take even more effort to maintain. So if the purpose of the feature is to resolve a struggle you are encountering personally, please consider first posting a "trouble" or "other" issue so we can discuss your use case and search for existing solutions first.

Proposal

As we discussed in rOpenSci Slack, there's no way to apply options like cue or error to targets after creating them. In my case, the application of this was to apply options to groups of targets in a pipeline. For instance, all my targets to fetch updated data from online could have the same tar_cue_age(). For this application, we don't need to manipulate, just have a way to create them in bulk but not for all targets. You suggested:

tar_option_set(cue = tar_cue(...))

mytargs <- tar_plan(
  tar1 = x(),
  tar2 = y()
)

tar_option_set(cue = tar_cue())

Possible helpful ways tarchetypes could improve this syntax would be:

  1. A with_ function. (simplest)
mytargs <- with_targets_options(tar_cue = tar_cue("always"),
   tar_plan(
     tar1 = x(),
     tar2 = y()
))

2a) Incorporating this into tar_plan()

mytargs <- tar_plan(
     tar1 = x(),
     tar2 = y()
     .options = list(tar_cue = tar_cue("always"))

or 2b)

mytargs <- tar_plan(
     tar1 = x(),
     tar2 = y()
     .tar_cue = tar_cue("always")
)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions