瀏覽代碼

reorganize targets an ensure up to date

main
Garrick Aden-Buie 2 年之前
父節點
當前提交
3f6def269c
沒有發現已知的金鑰在資料庫的簽署中
共有 4 個文件被更改,包括 95389 次插入9 次删除
  1. +14
    -3
      R/get.R
  2. +12
    -3
      _targets.R
  3. +95361
    -2
      _targets/meta/meta
  4. +2
    -1
      run.R

+ 14
- 3
R/get.R 查看文件

get_raw_report_all <- function(report_id) { get_raw_report_all <- function(report_id) {
delay() delay()


if (!identical(Sys.getenv("ALLOW_DOWNLOADS"), "true")) {
stop("Shouldn't be downloading reports now...")
}

res <- res <-
req_report_detail(report_id, "all") |> req_report_detail(report_id, "all") |>
req_perform() req_perform()
resp_body_string(res) resp_body_string(res)
} }


save_raw_report_all <- function(report_id, sboe_id) {
save_raw_report_all <- function(report_id, sboe_id, received) {
dir <- here::here("data-raw", "reports", sboe_id)
file_name <- paste0(report_id, "_", received)
path <- path(dir, file_name, ext = "txt")

if (file_exists(path)) {
# We don't need to re-download any reports
return(path)
}

res <- get_raw_report_all(report_id) res <- get_raw_report_all(report_id)


dir <- here::here("data-raw", "reports", sboe_id)
dir_create(dir) dir_create(dir)


path <- path(dir, report_id, ext = "txt")
brio::write_lines(res, path) brio::write_lines(res, path)


invisible(path) invisible(path)

+ 12
- 3
_targets.R 查看文件

), ),
tar_target(report_list_report_id, report_list$report_id), tar_target(report_list_report_id, report_list$report_id),
tar_target(report_list_sboe_id, report_list$sboe_id), tar_target(report_list_sboe_id, report_list$sboe_id),
tar_target(report_list_received, report_list$received),
tar_target( tar_target(
receipts_raw_path,
save_raw_report_all(report_list_report_id, report_list_sboe_id),
pattern = map(report_list_report_id, report_list_sboe_id),
reports_raw_path,
save_raw_report_all(
report_list_report_id,
report_list_sboe_id,
report_list_received
),
pattern = map(
report_list_report_id,
report_list_sboe_id,
report_list_received
),
format = "file_fast" format = "file_fast"
) )
) )

+ 95361
- 2
_targets/meta/meta
文件差異過大導致無法顯示
查看文件


+ 2
- 1
run.R 查看文件

# to learn about your options. # to learn about your options.


Sys.setenv("IN_TARGETS" = "true") Sys.setenv("IN_TARGETS" = "true")
Sys.setenv("ALLOW_DOWNLOADS" = "false")


targets::tar_make_future(workers = 8)
targets::tar_make() targets::tar_make()
# targets::tar_make_clustermq(workers = 2) # nolint # targets::tar_make_clustermq(workers = 2) # nolint
# targets::tar_make_future(workers = 2) # nolint

Loading…
取消
儲存