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

Include checks for data version, branch, sha and data hash in template script #129

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions inst/rmarkdown/templates/visc_report/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,20 @@ remotes::install_git(file.path('cavd', 'Studies', 'cvdNNN', 'pdata', 'VDCNNN.git
lib = my_data_package_lib)
```

```{r check_data_version}
DataPackageR::assert_data_version("VDCNNNAnalysis",version_string = "data_version")
testthat::expect_equal(packageDescription("VDCNNNAnalysis")$RemoteSha,"commit_sha")
testthat::expect_equal(packageDescription("VDCNNNAnalysis")$RemoteRef,"branch_name")

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if: instead of having a spot where the SRA manually includes the commit_sha and branch_name (which would still not be visible from the knitted PDF) it would make more sense to assign these values and add them in the reproducibility table at the end (next to the data_hash). i.e. lines 106-107 would be replaced with:

commit_sha <- packageDescription("VDCNNNAnalysis")$RemoteSha
branch_name <- packageDescription("VDCNNNAnalysis")$RemoteRef

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editing this further... shouldn't this be for the datapackage not for the analysis folder (since the analysis folder is not a package):

commit_sha <- packageDescription("VDCNNN")$RemoteSha
branch_name <- packageDescription("VDCNNN")$RemoteRef

```


```{r data-processing}
# For this template use VISCfunction example data
data('exampleData_ICS', package = 'VISCfunctions', envir = environment())

testthat::expect_equal(digest::digest(exampleData_ICS),"data_hash")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. We can replace lines 114-116 with:

exampleData_ICS <- visc_load_pdata(exampleData_ICS, proj_or_datapackage = "datapackage", criteria = "SRA_enter_data_hash")
data_hash <- digest::digest(exampleData_ICS)

In case the data object (exampleData_ICS) is modified without being assigned a new name before the reproducibility table at the end, I would create the data_hash object immediately after loading in the data and call that in the reproducibility table.


ICS_adata <- exampleData_ICS %>%
filter(Population == "IFNg" & Group != 3)
```
Expand Down Expand Up @@ -369,8 +379,9 @@ if (any(installed.packages()[,1] == 'rmarkdown')) suppressWarnings(library(rmark

my_session_info <- VISCfunctions::get_session_info()

kable(
my_session_info$platform_table,
my_session_info$platform_table %>%
add_row(name = "data hash", value = digest::digest(exampleData_ICS), .before = nrow(.)) %>%
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace 366 with lines:

add_row(name = "data hash", value = data_hash, .before = nrow(.)) %>%
add_row(name = "branch", value = branch_name, .before = nrow(.)) %>%
add_row(name = "commit", value = commit_sha, .before = nrow(.)) %>%

kable(
format = output_type,
booktabs = TRUE,
linesep = "",
Expand All @@ -380,8 +391,17 @@ kable(
```

```{r Software-Package-Version-Information, results="asis", warning=kable_warnings}
my_session_info$packages_table %>%
left_join(
sessioninfo::package_info() %>% filter(str_detect(source, pattern = "git2r")) %>%
pull(package) %>%
packageDescription() %>%
.[c("Package","RemoteRef")] %>%
as_tibble() %>%
rename("package" = "Package",
"branch" = "RemoteRef"),
by = "package") %>%
kable(
my_session_info$packages_table,
format = output_type,
booktabs = TRUE,
linesep = "",
Expand Down
Loading