You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.7KB

  1. # Created by use_targets().
  2. # Follow the comments below to fill in this target script.
  3. # Then follow the manual to check and run the pipeline:
  4. # https://books.ropensci.org/targets/walkthrough.html#inspect-the-pipeline
  5. # Load packages required to define the pipeline:
  6. library(targets)
  7. # Set target options:
  8. tar_option_set(
  9. packages = strsplit(desc::desc_get_field("Depends"), ", ")[[1]],
  10. # For distributed computing in tar_make(), supply a {crew} controller
  11. # as discussed at https://books.ropensci.org/targets/crew.html.
  12. controller = crew::crew_controller_local(workers = 24),
  13. # debug = "path_receipts_parquet_8d195f7e",
  14. # cue = tar_cue(mode = "never")
  15. error = "null"
  16. )
  17. # Run the R scripts in the R/ folder with your custom functions:
  18. tar_source()
  19. # Replace the target list below with your own:
  20. list(
  21. tar_target(path_report_list_csv, "../data-raw/report_list.csv", format = "file"),
  22. tar_target(path_report_list_raw, prepare_report_list(path_report_list_csv)),
  23. tar_target(report_list_raw, arrow::read_parquet(path_report_list_raw)),
  24. tar_target(
  25. dirs_all,
  26. fs::dir_ls("../data-raw/reports", glob = "**/all", recurse = TRUE, type = "directory"),
  27. format = "file"
  28. ),
  29. tar_target(
  30. dirs_receipts,
  31. fs::dir_ls("../data-raw/reports", glob = "**/receipts", recurse = TRUE, type = "directory"),
  32. format = "file"
  33. ),
  34. tar_target(
  35. dirs_expenditures,
  36. fs::dir_ls("../data-raw/reports", glob = "**/expenditures", recurse = TRUE, type = "directory"),
  37. format = "file"
  38. ),
  39. tar_target(
  40. paths_all_parquet,
  41. write_prepared_report_export(dirs_all, report_list_raw),
  42. pattern = map(dirs_all),
  43. format = "file"
  44. ),
  45. tar_target(
  46. path_receipts_parquet,
  47. write_prepared_receipts_parquet(dirs_receipts, report_list_raw),
  48. pattern = map(dirs_receipts),
  49. format = "file"
  50. ),
  51. tar_target(
  52. path_expenditures_parquet,
  53. write_prepared_expenditures_parquet(dirs_expenditures, report_list_raw),
  54. pattern = map(dirs_expenditures),
  55. format = "file"
  56. ),
  57. tar_target(path_data_prep_cover, { paths_all_parquet; "../data-prep/cover" }, format = "file"),
  58. tar_target(path_data_prep_officers, { paths_all_parquet; "../data-prep/officers" }, format = "file"),
  59. tar_target(
  60. cover_raw,
  61. arrow::open_dataset(path_data_prep_cover, partitioning = "sboe_id") |> dplyr::collect()
  62. ),
  63. tar_target(
  64. report_dates,
  65. process_report_dates(report_list_raw, cover_raw)
  66. ),
  67. tar_target(
  68. report_amended_score,
  69. calc_report_amended_score(report_dates)
  70. ),
  71. tar_target(
  72. report_list,
  73. process_report_list(report_list_raw, report_amended_score)
  74. ),
  75. tar_target(committees, prepare_committees(cover_raw, report_list)),
  76. tar_target(candidates, prepare_candidates(path_data_prep_officers, report_list))
  77. )