-
Notifications
You must be signed in to change notification settings - Fork 1
/
UploadResultsFromZipFiles.R
48 lines (41 loc) · 1.91 KB
/
UploadResultsFromZipFiles.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
################################################################################
# INSTRUCTIONS: The code below assumes you have used CreateResultsDataModel.R to
# create the results data model in a Postgres or SQLite database. This script
# will loop over all the zip files created by the ShareResults.R script.
#
# Make sure you have set the connection details to your results database in
# scriptsForStudyCoordinator/SetConnectionDetails.R.
# ##############################################################################
source("scriptsForStudyCoordinator/SetConnectionDetails.R")
resultsFiles <- list.files(path = "/Users/schuemie/Data/ExampleStrategusStudy", pattern = ".zip", full.names = T, recursive = F)
analysisSpecifications <- ParallelLogger::loadSettingsFromJson(
fileName = "inst/studyAnalysisSpecification.json"
)
# Setup logging ----------------------------------------------------------------
ParallelLogger::clearLoggers()
ParallelLogger::addDefaultFileLogger(
fileName = "upload-log.txt",
name = "RESULTS_FILE_LOGGER"
)
ParallelLogger::addDefaultErrorReportLogger(
fileName = "upload-errorReport.txt",
name = "RESULTS_ERROR_LOGGER"
)
# Upload Results ---------------------------------------------------------------
for (resultsFile in resultsFiles) {
tempFolder <- tempfile("StrategusResults")
dir.create(tempFolder)
unzip(resultsFile, exdir = tempFolder)
resultsDataModelSettings <- Strategus::createResultsDataModelSettings(
resultsDatabaseSchema = resultsDatabaseSchema,
resultsFolder = tempFolder,
)
Strategus::uploadResults(
analysisSpecifications = analysisSpecifications,
resultsDataModelSettings = resultsDataModelSettings,
resultsConnectionDetails = resultsConnectionDetails
)
}
# Unregister loggers -----------------------------------------------------------
ParallelLogger::unregisterLogger("RESULTS_FILE_LOGGER")
ParallelLogger::unregisterLogger("RESULTS_ERROR_LOGGER")