Sometimes an external change will occur and a target will no longer be able to be created.
An example of this is cpi which relies on the BLS API. If a change is made to the API -- and it hasn't been addressed by the blsAPI package -- this may result a command that no longer works.
This type of dependency is one of the primary motivators for the project's architecture that separates the original code used to create input data (data_source_plan) from the code used to import a stored version of the input data (data_cache_plan).
While this system works well, I have run into an issue: resetting the drake project (drake::clean()) results in an "outdated" data_source_plan that needs to run again. The external changes made to the BLS API prevent my original code from working, so the project now fails at the prepare_cpi(path= file_out("extdata/source/cpi-2000-2018.csv")) command.
My solution is to remove the targets associated with this input data from both prep_plan and upload_plan and store them in a new plan called target_archive_plan. This new plan is not executed when get_data_source_plan() is run, but it allows me to keep the original source code for this target. If the dependency issue is fixed then targets stored in target_archive_plan may be restored to the other plans; if not then they will remain there as a record of what used to work.
Here is what the data_source_plan now looks like:
get_data_source_plan <- function(){
prep_plan <- drake::drake_plan(
...
)
upload_plan <- drake::drake_plan(
...
)
target_archive_plan <- drake::drake_plan(
# stored targets go here
)
# note that `target_archive_plan` is *not* included below
data_source_plan <- drake::bind_plans(prep_plan, upload_plan)
return(data_source_plan)
}
Sometimes an external change will occur and a target will no longer be able to be created.
An example of this is
cpi
which relies on the BLS API. If a change is made to the API -- and it hasn't been addressed by theblsAPI
package -- this may result a command that no longer works.This type of dependency is one of the primary motivators for the project's architecture that separates the original code used to create input data (
data_source_plan
) from the code used to import a stored version of the input data (data_cache_plan
).While this system works well, I have run into an issue: resetting the drake project (
drake::clean()
) results in an "outdated"data_source_plan
that needs to run again. The external changes made to the BLS API prevent my original code from working, so the project now fails at theprepare_cpi(path= file_out("extdata/source/cpi-2000-2018.csv"))
command.My solution is to remove the targets associated with this input data from both
prep_plan
andupload_plan
and store them in a new plan calledtarget_archive_plan
. This new plan is not executed whenget_data_source_plan()
is run, but it allows me to keep the original source code for this target. If the dependency issue is fixed then targets stored intarget_archive_plan
may be restored to the other plans; if not then they will remain there as a record of what used to work.Here is what the
data_source_plan
now looks like: