-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
759 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
## ---- eval=FALSE--------------------------------------------------------- | ||
# library(checkpoint) | ||
# checkpoint("2015-04-26", checkpointLocation = tempdir()) | ||
|
||
## ---- eval=FALSE, warning=FALSE------------------------------------------ | ||
# library(checkpoint) | ||
# checkpoint("2015-04-26", checkpointLocation = tempdir()) | ||
# | ||
# library(MASS) | ||
# hist(islands) | ||
# truehist(islands) | ||
|
||
## ----setup, include=FALSE------------------------------------------------ | ||
|
||
## Create temporary project and set working directory | ||
|
||
example_project <- tempdir() | ||
|
||
dir.create(example_project, recursive = TRUE, showWarnings = FALSE) | ||
oldRepos <- getOption("repos") | ||
oldLibPaths <- .libPaths() | ||
|
||
|
||
## Write dummy code file to project | ||
|
||
example_code <- ' | ||
library(checkpoint) | ||
checkpoint("2015-04-26", checkpointLocation = tempdir()) | ||
library(MASS) | ||
hist(islands) | ||
truehist(islands) | ||
' | ||
|
||
cat(example_code, file = file.path(example_project, "checkpoint_example_code.R")) | ||
|
||
|
||
## ----checkpoint, warning=FALSE------------------------------------------- | ||
## Create a checkpoint by specifying a snapshot date | ||
|
||
library(checkpoint) | ||
dir.create(file.path(tempdir(), ".checkpoint"), recursive = TRUE) | ||
checkpoint("2015-04-26", project = example_project, checkpointLocation = tempdir()) | ||
|
||
## ----inspect-1----------------------------------------------------------- | ||
getOption("repos") | ||
|
||
## ----inspect-2----------------------------------------------------------- | ||
normalizePath(.libPaths(), winslash = "/") | ||
|
||
## ----inspect-3----------------------------------------------------------- | ||
installed.packages()[, "Package"] | ||
|
||
## ----cleanup, include=FALSE---------------------------------------------- | ||
## cleanup | ||
|
||
unlink(example_project, recursive = TRUE) | ||
unlink(file.path(tempdir(), "checkpoint_example_code.R")) | ||
unlink(file.path(tempdir(), ".checkpoint"), recursive = TRUE) | ||
options(repos = oldRepos) | ||
unCheckpoint(oldLibPaths) | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
## ---- eval=FALSE--------------------------------------------------------- | ||
# library(MASS) | ||
# hist(islands) | ||
# truehist(islands) | ||
|
||
## ----setup-1, include=FALSE---------------------------------------------- | ||
## Write dummy code file to project | ||
example_code <- ' | ||
library(MASS) | ||
library(chron) | ||
' | ||
dir.create(tempdir(), recursive = TRUE) | ||
cat(example_code, file = file.path(tempdir(), "managing_checkpoint_example_code.R")) | ||
|
||
## ----checkpoint, results="hide", message=FALSE, warning=FALSE------------ | ||
## Create a checkpoint by specifying a snapshot date | ||
library(checkpoint) | ||
dir.create(file.path(tempdir(), ".checkpoint"), recursive = TRUE, showWarnings = FALSE) | ||
checkpoint("2015-04-26", project = tempdir(), checkpointLocation = tempdir()) | ||
|
||
|
||
## ----archives-1---------------------------------------------------------- | ||
# List checkpoint archives on disk. | ||
checkpointArchives(tempdir()) | ||
|
||
## ----archives-2---------------------------------------------------------- | ||
checkpointArchives(tempdir(), full.names = TRUE) | ||
|
||
## ----access-------------------------------------------------------------- | ||
# Returns the date the snapshot was last accessed. | ||
getAccessDate(tempdir()) | ||
|
||
|
||
## ----remove-1, eval=FALSE------------------------------------------------ | ||
# # Remove singe checkpoint archive from disk. | ||
# checkpointRemove("2015-04-26") | ||
|
||
## ----remove-2, eval=FALSE------------------------------------------------ | ||
# # Remove range of checkpoint archives from disk. | ||
# checkpointRemove("2015-04-26", allSinceSnapshot = TRUE) | ||
# checkpointRemove("2015-04-26", allUntilSnapshot = = TRUE) | ||
# | ||
|
||
## ----remove-3, eval=FALSE------------------------------------------------ | ||
# # Remove snapshot archives that have not been used recently | ||
# checkpointRemove("2015-04-26", notUsedSince = TRUE) | ||
# | ||
|
||
## ----logfile-1----------------------------------------------------------- | ||
dir(file.path(tempdir(), ".checkpoint")) | ||
|
||
## ----logfile-2----------------------------------------------------------- | ||
|
||
log_file <- file.path(tempdir(), ".checkpoint", "checkpoint_log.csv") | ||
log <- read.csv(log_file) | ||
head(log) | ||
|
||
## ----uncheckpoint-1------------------------------------------------------ | ||
.libPaths() | ||
|
||
## ----uncheckpoint-2------------------------------------------------------ | ||
# Note this is still experimental | ||
unCheckpoint() | ||
.libPaths() | ||
|
||
## ----cleanup, include=FALSE---------------------------------------------- | ||
## cleanup | ||
unlink("manifest.R") | ||
unlink(file.path(tempdir(), "managing_checkpoint_example_code.R")) | ||
unlink(file.path(tempdir(), ".checkpoint"), recursive = TRUE) | ||
|
Oops, something went wrong.