Giter Site home page Giter Site logo

Batched replication about tarchetypes HOT 4 CLOSED

ropensci avatar ropensci commented on June 4, 2024
Batched replication

from tarchetypes.

Comments (4)

wlandau avatar wlandau commented on June 4, 2024

Under the hood, we could create 2 targets instead of 3. This will make interaction with #13 less burdensome. We could express tar_rep_tbl(data_continuous, simulate_data_continuous(), batches = 2, reps_per_batch = 4) as:

list(
  tar_target(
    data_continuous_batch,
    seq_len(2),
    deployment = "local"
  ),
  tar_target(
    data_continuous,
    tarchetypes::tar_rep_df_run(simulate_data_continuous(), 4),
    pattern = map(index_batch),
    format = "fst_tbl"
  )
)

where

tar_rep_df_run <- function(command, reps) {
  expr <- substitute(command)
  envir <- parent.frame()
  do.call(vctrs::vec_c, tar_rep_run(expr, envir, reps))
}

tar_rep_list_run <- function(command, reps) {
  expr <- substitute(command)
  envir <- parent.frame()
  tar_rep_run(expr, envir, reps)
}

tar_rep_run <- function(expr, envir, reps) {
  lapply(seq_len(reps), tar_rep, expr = expr, envir = envir)
}

tar_rep <- function(expr, envir, rep) {
  out <- eval(expr, envir = envir)
  out$rep <- rep
  out
}

from tarchetypes.

wlandau avatar wlandau commented on June 4, 2024

If we infer the iteration type for the reps within batch from the iteration type of the target spec, then I think we can actually simplify this down into tar_rep() and tar_rep_raw().

from tarchetypes.

wlandau avatar wlandau commented on June 4, 2024

Let's call it tar_batch() instead of tar_rep().

from tarchetypes.

wlandau avatar wlandau commented on June 4, 2024

Nope: tar_rep() is better because it emphasizes that the command stays identical across batches.

from tarchetypes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.