-
Notifications
You must be signed in to change notification settings - Fork 1
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
9 changed files
with
355 additions
and
92 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 @@ | ||
* @Sage-Bionetworks/genie_admins |
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
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,30 @@ | ||
/* | ||
Updates the potential pHI fields table with any new variables to redact | ||
*/ | ||
process update_potential_phi_fields_table { | ||
|
||
container "$params.references_docker" | ||
secret 'SYNAPSE_AUTH_TOKEN' | ||
debug true | ||
|
||
input: | ||
val comment | ||
val production | ||
|
||
output: | ||
stdout | ||
|
||
script: | ||
if (production) { | ||
""" | ||
cd /usr/local/src/myscripts/ | ||
Rscript update_potential_phi_fields_table.R -c $comment --production | ||
""" | ||
} | ||
else { | ||
""" | ||
cd /usr/local/src/myscripts/ | ||
Rscript update_potential_phi_fields_table.R -c $comment | ||
""" | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,21 +1,34 @@ | ||
FROM r-base:4.0.0 | ||
FROM rstudio/r-base:4.0-bullseye | ||
|
||
# Set working directory | ||
WORKDIR /usr/local/src/myscripts | ||
|
||
# Set environment variable for renv version | ||
ENV RENV_VERSION 0.14.0 | ||
|
||
RUN rm /etc/apt/apt.conf.d/default | ||
RUN apt-get update -y | ||
RUN apt-get install -y dpkg-dev zlib1g-dev libssl-dev libffi-dev | ||
# procps is required for nextflow tower | ||
RUN apt-get install -y curl libcurl4-openssl-dev procps | ||
RUN R -e "install.packages('synapser', repos=c('http://ran.synapse.org', 'http://cran.fhcrc.org'))" | ||
# Update apt-get and install system dependencies (only install required) | ||
RUN apt-get update -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
dpkg-dev zlib1g-dev libssl-dev libffi-dev \ | ||
libcurl4-openssl-dev curl procps && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV PYTHON /usr/local/lib/R/site-library/PythonEmbedInR/bin/python3.6 | ||
# Install R packages including remotes and renv | ||
RUN R -e "install.packages('remotes', repos = 'https://cloud.r-project.org')" && \ | ||
R -e "remotes::install_github('rstudio/renv', ref = '${RENV_VERSION}')" || true | ||
|
||
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))" | ||
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')" | ||
# Install synapser with specific version | ||
RUN R -e "remotes::install_version('synapser', version = '0.11.7', repos = c('http://ran.synapse.org', 'http://cran.fhcrc.org'))" | ||
|
||
COPY . . | ||
# Set Python environment variable for R | ||
ENV PYTHON /usr/local/lib/R/site-library/PythonEmbedInR/bin/python3.6 | ||
|
||
# Copy only renv.lock first to leverage docker cache for dependencies | ||
COPY renv.lock renv.lock | ||
|
||
# Restore R environment with renv | ||
RUN R -e "renv::restore()" | ||
|
||
# Copy the local project files into the container | ||
COPY . . |
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
100 changes: 100 additions & 0 deletions
100
scripts/references/tests/test_update_potential_phi_fields_table.R
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,100 @@ | ||
library(mockery) | ||
library(testthat) | ||
|
||
source(testthat::test_path("..", "update_potential_phi_fields_table.R")) | ||
|
||
# Setup code: This will run before any tests | ||
setup({ | ||
# Mock synapse function | ||
mock_synStore <<- mock() | ||
mock_snapshot_version <<- mock(return_value=3) | ||
|
||
# Create dummy input data | ||
test_df_update_non_empty <<- data.frame(col1 = 1:3, col2 = letters[1:3]) | ||
test_df_update_empty <<- data.frame() | ||
synid_table <<- "syn123" | ||
synid_file_sor <<- "syn456" | ||
test_comment <<- "Test comment" | ||
}) | ||
|
||
|
||
test_that("update_red_table does not update table when dry_run is TRUE and df_update has non-empty rows", { | ||
dry_run <- TRUE | ||
|
||
# Use mockery to mock the synStore and snapshot_synapse_table functions | ||
stub(update_red_table, "synStore", mock_synStore) | ||
stub(update_red_table, "snapshot_synapse_table", mock_snapshot_version) | ||
|
||
# Call the function with dry_run = TRUE | ||
result <- update_red_table(synid_table, synid_file_sor, test_df_update_non_empty, test_comment, dry_run) | ||
|
||
# Assert that synStore was never called | ||
expect_called(mock_synStore, 0) | ||
|
||
# Assert that snapshot_synapse_table was never called | ||
expect_called(mock_snapshot_version, 0) | ||
|
||
# Assert that result is 3 (since update was made) | ||
expect_equal(result, NA) | ||
}) | ||
|
||
|
||
test_that("update_red_table does not update table when dry_run is TRUE and df_update has empty rows", { | ||
dry_run <- TRUE | ||
|
||
# Use mockery to mock the synStore and snapshot_synapse_table functions | ||
stub(update_red_table, "synStore", mock_synStore) | ||
stub(update_red_table, "snapshot_synapse_table", mock_snapshot_version) | ||
|
||
# Call the function with dry_run = TRUE | ||
result <- update_red_table(synid_table, synid_file_sor, test_df_update_empty, test_comment, dry_run) | ||
|
||
# Assert that synStore was never called | ||
expect_called(mock_synStore, 0) | ||
|
||
# Assert that snapshot_synapse_table was never called | ||
expect_called(mock_snapshot_version, 0) | ||
|
||
# Assert that result is NA (since no update was made) | ||
expect_equal(result, NA) | ||
}) | ||
|
||
test_that("update_red_table updates table when dry_run is FALSE and df_update has non-empty rows", { | ||
dry_run <- FALSE | ||
|
||
# Use mockery to mock the synStore and snapshot_synapse_table functions | ||
stub(update_red_table, "synStore", mock_synStore) | ||
stub(update_red_table, "snapshot_synapse_table", mock_snapshot_version) | ||
|
||
# Call the function with dry_run = FALSE | ||
result <- update_red_table(synid_table, synid_file_sor, test_df_update_non_empty, test_comment, dry_run) | ||
|
||
# Assert that synStore was called once | ||
expect_called(mock_synStore, 1) | ||
|
||
# Assert that snapshot_synapse_table was called once | ||
expect_called(mock_snapshot_version, 1) | ||
|
||
# Assert that result is 1 (simulated version returned by mock_snapshot_version) | ||
expect_equal(result, 3) | ||
}) | ||
|
||
|
||
test_that("update_red_table does not update table when dry_run is FALSE and df_update has empty rows", { | ||
dry_run <- FALSE | ||
|
||
# Use mockery to mock the synStore and snapshot_synapse_table functions | ||
stub(update_red_table, "synStore", mock_synStore) | ||
stub(update_red_table, "snapshot_synapse_table", mock_snapshot_version) | ||
|
||
# Call the function with dry_run = FALSE | ||
result <- update_red_table(synid_table, synid_file_sor, test_df_update_empty, test_comment, dry_run) | ||
|
||
# Assert that synStore was called once | ||
expect_called(mock_synStore, 1) | ||
|
||
# Assert that snapshot_synapse_table was called once | ||
expect_called(mock_snapshot_version, 1) | ||
|
||
expect_equal(result, NA) | ||
}) |
Oops, something went wrong.