-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic pipeline for data fetching
Signed-off-by: Liang Zhang <[email protected]>
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#' Create standard data fetching targets pipeline script | ||
#' | ||
#' This function creates a standard data fetching targets pipeline script | ||
#' for you to fill in. | ||
#' | ||
#' @return NULL (invisible). This function is called for its side effects. | ||
#' @export | ||
use_targets <- function() { | ||
script <- "_targets.R" | ||
if (file.exists(script)) { | ||
cli::cli_alert_info( | ||
sprintf("File {.file %s} exists. Stash and retry.", script) | ||
) | ||
return(invisible()) | ||
} | ||
copy_success <- file.copy( | ||
system.file( | ||
"pipelines", "use_targets.R", | ||
package = "tarflow.iquizoo" | ||
), | ||
script | ||
) | ||
if (!copy_success) { | ||
cli::cli_alert_danger("Sorry, copy template failed.") | ||
return(invisible()) | ||
} | ||
cli::cli_alert_success( | ||
sprintf("File {.file %s} crated successfully.", script) | ||
) | ||
return(invisible()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Created by tarflow.iquizoo::use_targets(). | ||
# Follow the comments below to fill in this target script. | ||
# Then follow the manual to check and run the pipeline: | ||
# https://books.ropensci.org/targets/walkthrough.html#inspect-the-pipeline | ||
|
||
# Load packages required to define the pipeline: | ||
library(targets) | ||
Check notice on line 7 in inst/pipelines/use_targets.R codefactor.io / CodeFactorinst/pipelines/use_targets.R#L7
|
||
# library(tarchetypes) # Load other packages as needed. | ||
Check warning on line 8 in inst/pipelines/use_targets.R GitHub Actions / lint
|
||
|
||
# Set target options: | ||
tar_option_set( | ||
packages = c("tarflow.iquizoo", "preproc.iquizoo") # packages that your targets need to run | ||
Check warning on line 12 in inst/pipelines/use_targets.R GitHub Actions / lint
|
||
# format = "qs", # Optionally set the default storage format. qs is fast. | ||
# | ||
# For distributed computing in tar_make(), supply a {crew} controller | ||
# as discussed at https://books.ropensci.org/targets/crew.html. | ||
# Choose a controller that suits your needs. For example, the following | ||
# sets a controller with 2 workers which will run as local R processes: | ||
# | ||
# controller = crew::crew_controller_local(workers = 2) | ||
Check warning on line 20 in inst/pipelines/use_targets.R GitHub Actions / lint
|
||
# | ||
# Set other options as needed. | ||
) | ||
|
||
# Run the R scripts in the R/ folder with your custom functions: | ||
tar_source() | ||
# source("other_functions.R") # Source other scripts as needed. | ||
Check warning on line 27 in inst/pipelines/use_targets.R GitHub Actions / lint
|
||
|
||
tbl_params <- tibble::tribble( | ||
~course_name, ~course_period, | ||
# replace course name and course period with your own | ||
"# COURSE NAME", "# COURSE PERIOD" | ||
) | ||
|
||
# Replace the target list below with your own: | ||
list( | ||
# change what to scores or raw_data if you want to | ||
tarflow.iquizoo::prepare_fetch_data(tbl_params, what = "all") | ||
# more targets goes here | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.