Fix warn instead of stop when there are not device ids

pull/130/head
JulioV 2021-03-16 20:02:16 -04:00
parent 4c2f60fffd
commit 6e234f7951
2 changed files with 13 additions and 5 deletions

View File

@ -119,9 +119,6 @@ pull_phone_data <- function(){
device_oss <- replace(device_oss, device_oss == "multiple", "infer") # support multiple for retro compatibility
validate_deviceid_platforms(devices, device_oss, participant_file)
if(length(devices) == 0)
stop("There were no PHONE device ids in this participant file:", participant_file)
if(length(device_oss) == 1)
device_oss <- rep(device_oss, length(devices))
@ -130,6 +127,12 @@ pull_phone_data <- function(){
expected_columns <- tolower(rapids_schema[[sensor]])
participant_data <- setNames(data.frame(matrix(ncol = length(expected_columns), nrow = 0)), expected_columns)
if(length(devices) == 0){
warning("There were no PHONE device ids in this participant file:", participant_file)
write_csv(participant_data, output_data_file)
return()
}
container_functions <- load_container_script(stream_container)
infer_device_os_container <- container_functions$infer_device_os
pull_data_container <- container_functions$pull_data

View File

@ -85,12 +85,17 @@ pull_wearable_data_main <- function(){
stream_schema <- read_yaml(stream_format)
rapids_schema <- read_yaml(rapids_schema_file)
devices <- participant_data[[toupper(device_type)]]$DEVICE_IDS
if(length(devices) == 0)
stop("There were no ", device_type ," device ids in this participant file: ", participant_file)
validate_expected_columns_mapping(stream_schema, rapids_schema, sensor, rapids_schema_file, stream_format)
expected_columns <- tolower(names(stream_schema[[sensor]][["RAPIDS_COLUMN_MAPPINGS"]]))
participant_data <- setNames(data.frame(matrix(ncol = length(expected_columns), nrow = 0)), expected_columns)
if(length(devices) == 0){
warning("There were no ", device_type ," device ids in this participant file: ", participant_file)
write_csv(participant_data, output_data_file)
return()
}
pull_data_container <- load_container_script(stream_container)
for(idx in seq_along(devices)){ #TODO remove length