amsnyder / ds-pipelines-targets-1

https://lab.github.com/USGS-R/intro-to-targets-pipelines
0 stars 0 forks source link

add targets file #7

Closed amsnyder closed 3 years ago

amsnyder commented 3 years ago

add _targets.R makefile to define dependencies, targets, and workflow order

github-learning-lab[bot] commented 3 years ago

So, what does this do for you? Well, if you had this _targets.R file in your current working directory (which you do), and you had defined the download_data(), process_data(), plot_data(), and generate_diagnostics() functions in code.R (which you haven't), it would look like this when you ran tar_make() from the targets package:

targets run image


Now - adding on to this PR by pushing up additional commits - add and modify code, folders, and this makefile so you can build your 3_visualize/out/figure_1.png with targets::tar_make() (BTW, if you haven't run into this syntax, {package_name}::{function_name} allows you to run a function without library({package_name})). Build on your existing folders, functions, and code from the previous sections by continuing with the phases 1_fetch, 2_process, and 3_visualize. Comment in the pull request with a screenshot of the build message, like we have in the message above :point_up:. Assign your course contact to review your PR, and we may ask for a few changes before merging.

There is a file in your repo called .gitignore. Add a line with _targets so that git doesn't track the contents of the targets directory. In addition, make sure that the contents of 1_fetch/out/* will be ignored by git because you don't want to store changes to your downloaded .csv files (you may have already added a more generic */out/* to your .gitignore that handles all out/ folders in this repo).

amsnyder commented 3 years ago

Any idea why these aren't running in the same order as they are defined in my _targets.R file? The figure_1_pngand model_summary_results_csv steps are switched. image

hcorson-dosch-usgs commented 3 years ago

Any idea why these aren't running in the same order as they are defined in my _targets.R file? The figure_1_pngand model_summary_results_csv steps are switched. image

Good eye!! You're right that targets ran those in a different order that you had specified them. targets is just paying attention to the dependencies, and since model_summary_results_csv and figure_1_png both depend on eval_data but don't depend on each other, it doesn't matter which is run first after eval_data is built.

amsnyder commented 3 years ago

I think I've made the requested updates! Let me know if you see anything else needed for approval.

github-learning-lab[bot] commented 3 years ago


When you are done poking around, check out the next issue.