Skip to content

A simpler DSL for translating imperative scripts into declarative pipelines #226

@wlandau

Description

@wlandau

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

Proposed in ropensci/targets#1521. Would accept a decorated set of imperative expressions as input:

#| format: file
#| deployment: main
file <- "data.csv"

#| deployment: main
data <- read_csv(file, col_types = cols()) |>
  filter(!is.na(Ozone))

#| storage: worker
model <- lm(Ozone ~ Temp, data) |>
  coefficients()

#| deployment: main
plot <- ggplot(data) +
  geom_point(aes(x = Temp, y = Ozone)) +
  geom_abline(intercept = model[1], slope = model[2]) +
  theme_gray(24)

And return a simple pipeline:

list(
  tar_target(
    name = file,
    command = "data.csv",
    format = "file",
    deployment = "main"
  ),
  tar_target(
    name = data,
    command = read_csv(file, col_types = cols()) |>
      filter(!is.na(Ozone)),
    deployment = "main"
  ),
  tar_target(
    name = model,
    command = lm(Ozone ~ Temp, data) |>
      coefficients(),
    storage = "worker"
  ),
  tar_target(
    name = plot,
    command = ggplot(data) +
      geom_point(aes(x = Temp, y = Ozone)) +
      geom_abline(intercept = model[1], slope = model[2]) +
      theme_gray(24),
    deployment = "main"
  )
)

Remarks:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions