Commit 5bb170dc authored by aho's avatar aho
Browse files

Clean comments; remove .withWarnings() for num_procs > 1 case

parent dc68670a
Pipeline #8518 passed with stage
in 44 minutes and 12 seconds
......@@ -1222,12 +1222,6 @@ Start <- function(..., # dim = indices/selectors,
debug <- TRUE
}
#-------NEW---------
# warnings1 <- NULL
# warnings2 <- NULL
# warnings3 <- NULL
#------NEW_END--------
############################## READING FILE DIMS ############################
# Check that no unrecognized variables are present in the path patterns
# and also that no file dimensions are requested to THREDDs catalogs.
......@@ -1953,11 +1947,9 @@ Start <- function(..., # dim = indices/selectors,
transformed_common_vars_unorder_indices <- NULL
transform_crop_domain <- NULL
#--------NEW---------
# store warning messages from transform
warnings1 <- NULL
warnings2 <- NULL
#-------NEW_END--------
for (i in 1:length(dat)) {
if (dataset_has_files[i]) {
......@@ -2121,17 +2113,7 @@ Start <- function(..., # dim = indices/selectors,
transform_params))
)
transformed_data <- tmp$value
#print("warnings1")
#browser()
#--------NEW-------------
# if (!is.null(res1$warnings)) {
# if (is.null(warnings1)) {
# warnings1 <- res1$warnings
# } else {
warnings1 <- c(warnings1, tmp$warnings)
# }
# }
#-------NEW_END----------
# Discard the common transformed variables if already transformed before
if (!is.null(transformed_common_vars)) {
......@@ -3009,17 +2991,7 @@ Start <- function(..., # dim = indices/selectors,
transform_params))$variables[[var_with_selectors_name]]
)
transformed_subset_var <- tmp$value
#print("warnings2")
#browser()
#--------NEW-----------
# if (!is.null(res2$warnings)) {
# if (is.null(warnings2)) {
# warnings2 <- res2$warnings
# } else {
warnings2 <- c(warnings2, tmp$warnings)
# }
# }
#-----NEW_END------------
# Sorting the transformed variable and working out the indices again after transform.
if (!is.null(dim_reorder_params[[inner_dim]])) {
......@@ -3779,10 +3751,9 @@ Start <- function(..., # dim = indices/selectors,
}
}
#------NEW---------
# store warning messages from transform
warnings3 <- NULL
#----NEW_END-------
# The following several lines will only run if retrieve = TRUE
if (retrieve) {
......@@ -3876,23 +3847,14 @@ Start <- function(..., # dim = indices/selectors,
silent = silent, debug = debug)
)
found_files <- tmp$value
#print('warnings3-1')
#browser()
#-----------NEW-------------
# if (!is.null(tmp$warnings)) {
# if (is.null(warnings3)) {
# warnings3 <- tmp$warnings
# } else {
warnings3 <- c(warnings3, tmp$warnings)
# }
# }
#----------NEW_END------------
} else {
cluster <- parallel::makeCluster(num_procs, outfile = "")
# Send the heavy work to the workers
##NOTE: .withWarnings() can't catch warnings like it does above (num_procs == 1). The warnings
## show below when "bigmemory::as.matrix(data_array)" is called. Don't know how to fix it for now.
work_errors <- try({
tmp <- .withWarnings(
found_files <- parallel::clusterApplyLB(cluster, work_pieces, .LoadDataFile,
shared_matrix_pointer = shared_matrix_pointer,
file_data_reader = file_data_reader,
......@@ -3901,20 +3863,6 @@ Start <- function(..., # dim = indices/selectors,
transform_params = transform_params,
transform_crop_domain = transform_crop_domain,
silent = silent, debug = debug)
)
found_files <- tmp$value
#print('warnings3-2')
#browser()
#-----------NEW-------------
# if (!is.null(res3$warnings)) {
# if (is.null(warnings3)) {
# warnings3 <- res3$warnings
# } else {
warnings3 <- c(warnings3, tmp$warnings)
# }
# }
#----------NEW_END------------
})
parallel::stopCluster(cluster)
}
......@@ -4153,10 +4101,8 @@ Start <- function(..., # dim = indices/selectors,
}
}
#browser()
# Print the warnings from transform
if (!is.null(c(warnings1, warnings2, warnings3))) {
#----------NEW-----------
transform_warnings_list <- lapply(c(warnings1, warnings2, warnings3), function(x) {
return(x$message)
})
......@@ -4165,7 +4111,6 @@ Start <- function(..., # dim = indices/selectors,
.warning(transform_warnings_list[[i]])
}
}
#-------NEW_END----------
# Change final_dims_fake back because retrieve = FALSE will use it for attributes later
if (exists("final_dims_fake_output")) {
......
......@@ -863,9 +863,9 @@
.withWarnings <- function(expr) {
myWarnings <- NULL
wHandler <- function(w) {
myWarnings <<- c(myWarnings, list(w))
invokeRestart("muffleWarning")
myWarnings <<- c(myWarnings, list(w))
invokeRestart("muffleWarning")
}
val <- withCallingHandlers(expr, warning = wHandler)
list(value = val, warnings = myWarnings)
}
\ No newline at end of file
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment