Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import and export targets to and from drake caches #1021

Merged
merged 3 commits into from
Sep 29, 2019
Merged

Import and export targets to and from drake caches #1021

merged 3 commits into from
Sep 29, 2019

Conversation

wlandau
Copy link
Member

@wlandau wlandau commented Sep 29, 2019

Summary

This PR implements serious methods in the decorated storr API to import and export targets to and from drake caches.

Note: importing targets does not import history. Importing history is an all-or-nothing action managed directly with txtq (requires txtq >= 0.1.9002).

library(drake)
# You can import and export targets to and from decorated storrs.
plan1 <- drake_plan(w = "w", x = "x")
plan2 <- drake_plan(a = "a", x = "x2")
cache1 <- new_cache("cache1")
cache2 <- new_cache("cache2")
make(plan1, cache = cache1)
#> target w
#> target x
make(plan2, cache = cache2)
#> target a
#> target x
cache1$import(cache2, a)
cache1$get("a")
#> [1] "a"
cache1$get("x")
#> [1] "x"
cache1$import(cache2)
cache1$get("x")
#> [1] "x2"
# With txtq >= 0.1.6.9002 (on GitHub)
# you can import history from one cache into another.
# Regular import() does not do this.
drake_history(cache = cache1)
#> # A tibble: 2 x 8
#>   target current built             exists hash      command    seed runtime
#>   <chr>  <lgl>   <chr>             <lgl>  <chr>     <chr>     <int>   <dbl>
#> 1 w      TRUE    2019-09-28 21:43… TRUE   5a88927b… "\"w\""  1.98e9   0.001
#> 2 x      FALSE   2019-09-28 21:43… TRUE   7a3f077a… "\"x\""  1.06e9   0.001
cache1$history$import(cache2$history)
drake_history(cache = cache1)
#> # A tibble: 4 x 8
#>   target current built             exists hash      command    seed runtime
#>   <chr>  <lgl>   <chr>             <lgl>  <chr>     <chr>     <int>   <dbl>
#> 1 a      TRUE    2019-09-28 21:43… TRUE   8568aa40… "\"a\""  1.67e9   0    
#> 2 w      TRUE    2019-09-28 21:43… TRUE   5a88927b… "\"w\""  1.98e9   0.001
#> 3 x      FALSE   2019-09-28 21:43… TRUE   7a3f077a… "\"x\""  1.06e9   0.001
#> 4 x      TRUE    2019-09-28 21:43… TRUE   531cde55… "\"x2\…  1.06e9   0

Created on 2019-09-28 by the reprex package (v0.3.0)

Related GitHub issues and pull requests

Checklist

@wlandau
Copy link
Member Author

wlandau commented Sep 29, 2019

cc @billdenney and @noamross

@codecov-io
Copy link

codecov-io commented Sep 29, 2019

Codecov Report

Merging #1021 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1021   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          46      46           
  Lines        6494    6536   +42     
======================================
+ Hits         6494    6536   +42
Impacted Files Coverage Δ
R/cache.R 100% <ø> (ø) ⬆️
R/utils.R 100% <100%> (ø) ⬆️
R/decorate_storr.R 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30e49a8...b856d60. Read the comment docs.

@wlandau wlandau merged commit 5b36f44 into master Sep 29, 2019
@wlandau wlandau deleted the 1015 branch September 29, 2019 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants