Skip to content

Commit bf6d041

Browse files
committed
Formatting changes
1 parent fe4e750 commit bf6d041

15 files changed

Lines changed: 143 additions & 179 deletions

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: nidapFunctions
22
Type: Package
33
Title: Tools for NIDAP Code Workbook Templates
4-
Version: 0.7.4
4+
Version: 0.7.6
55
Date: 2023-05-23
66
Authors@R: person("Cam", "Maggie", email = "maggie.cam@nih.gov", role = c("cre","aut"))
77
Maintainer: Cam Maggie <maggie.cam@nih.gov>
@@ -14,6 +14,6 @@ Suggests:
1414
License: MIT
1515
Encoding: UTF-8
1616
LazyData: true
17-
RoxygenNote: 7.2.3
17+
RoxygenNote: 7.2.1
1818
VignetteBuilder: knitr
1919
Language: en-US

NAMESPACE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(loopUnzip)
4-
export(nidapFilePath)
4+
export(nidapGetFiles)
55
export(nidapGetPath)
66
export(nidapLoadPackages)
7-
export(writeRDS)
87
importFrom(utils,unzip)

R/Get_File_Paths.R

Lines changed: 0 additions & 32 deletions
This file was deleted.

R/Get_Path.R

Lines changed: 0 additions & 27 deletions
This file was deleted.

R/Loop_Unzip.R

Lines changed: 0 additions & 25 deletions
This file was deleted.

R/Write_RDS.R

Lines changed: 0 additions & 21 deletions
This file was deleted.

R/get-files.R

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This function provides a file path when a transform input file is brought into
2+
# Palantir Foundry's Code Workbook in NIDAP.
3+
4+
#' @title Get Path
5+
#' @description This function returns the file path from a transform input
6+
#' dataset in NIDAP Code Workbook
7+
#' @details This function will return a file path from a transform input dataset
8+
#' into a code template or code transform in the NIDAP instance of
9+
#' Foundry Code Workbook.
10+
#' @param input transform input dataset to import
11+
#' @param name name of input file, usually transform input format
12+
#' @param type data type, by default, 'r'.
13+
#'
14+
#' @export
15+
#'
16+
#' @return file path from which to read in data. Note that the original file
17+
#' name will not be retained
18+
19+
nidapGetPath <- function(input,
20+
name,
21+
type = 'r'){
22+
23+
fs <- input$fileSystem()
24+
path <- fs$get_path(name, type)
25+
return(path)
26+
}
27+
28+
# This function returns the file path or paths used for loading files brought
29+
# into NIDAP code workbook.
30+
31+
#' @title Get Files
32+
#' @description This function returns specific file paths for an input dataset
33+
#' in transform input format containing either a single or multiple files.
34+
#' @details This method will copy files to the compute node and returns
35+
#' the original file names for reading into code workbook.
36+
#'
37+
#' @param dataset Dataset to import, usually in transform input format
38+
#' @param ext File extension. For instance, "xlsx", "csv", "'txt, "rds"
39+
#' @param type Data type, by default, 'r'
40+
#'
41+
#' @export
42+
#'
43+
#' @return File name(s) to read into code template or code transform
44+
#'
45+
46+
nidapGetFiles <- function(data,
47+
ext,
48+
type = 'r'){
49+
fs <- data$fileSystem()
50+
file.path <- fs$ls(glob = paste0("*.",ext))
51+
files <- lapply(file.path, function(file) {
52+
return(c(file$path, fs$get_path(file$path, type))) })
53+
output.names<-list()
54+
for (item in files){
55+
file.copy(from=item[2], to=item[1],
56+
overwrite = TRUE, recursive = FALSE,
57+
copy.mode = TRUE)
58+
output.names <- append(output.names,item[1])
59+
}
60+
return(unlist(output.names))
61+
}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
#' @description This function will load packages and reorder package priorities
55
#' while suppressing startup messages by default.
66
#' @details This method provides a way to automatically (optionally) suppress
7-
#' package startup messages in NIDAP and removes all other unnecessary
7+
#' package start up messages in NIDAP and removes all other unnecessary
88
#' packages
99
#'
10-
#' @param current.package vector of packages that are being used in the template
11-
#' @param suppress boolean to suppress messages. By default set to TRUE
10+
#' @param current.package Vector of packages that are being used in the template
11+
#' @param suppress Boolean to suppress messages. By default set to TRUE
1212
#'
1313
#' @export
1414
#'
@@ -33,11 +33,13 @@ nidapLoadPackages <- function(current.packages,
3333
"package:futile.logger",
3434
"package:uuid")
3535

36-
package.list <- search()[ifelse(unlist(gregexpr("package:",search()))==1,TRUE,FALSE)]
36+
package.list <- search()[ifelse(unlist(gregexpr("package:",search()))==1,
37+
TRUE,FALSE)]
3738
package.list <- setdiff(package.list,basic.packages)
3839

3940
#If there are existing non-basic packages, detach them.
40-
if (length(package.list)>0) for (package in package.list) detach(package, character.only=TRUE)
41+
if (length(package.list)>0) for (package in package.list)
42+
detach(package, character.only=TRUE)
4143

4244
#load current packages with option to suppress startup messages
4345
for(package in current.packages){

R/loop-unzip.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This function unzips the files brought into NIDAP code workbook.
2+
3+
#' @title Unzip Files in a Loop
4+
#' @description This function unzips specific file(s) in a file path
5+
#' @details This method will return unzipped file(s) for reading into a code
6+
#' workbook template/transform.
7+
#'
8+
#' @param dir File path for zipped data file(s)
9+
#'
10+
#' @importFrom utils unzip
11+
#'
12+
#' @export
13+
#'
14+
#' @return Local file path for unzipped data file(s)
15+
#'
16+
17+
18+
loopUnzip <- function(dir){
19+
while(length(grep(".zip",dir))!=0){
20+
dir <- unzip(dir)
21+
}
22+
output <- basename(dir)
23+
return(output)
24+
}

man/loopUnzip.Rd

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)