petteriTeikari / R-PLR

Once separate repos combined to one making it easier in the end
1 stars 0 forks source link

Multicore not supported on windows #10

Closed ray-najjar closed 5 years ago

ray-najjar commented 5 years ago
Error in mclapply(files_to_process, function(files_to_process) { : 
  'mc.cores' > 1 is not supported on Windows 

when calling

 # Do some semi-intelligent decompositions for machine learning data augmentation purposes
  # Computes as well 1st and 2nd derivatives (i.e. velocity and acceleration) from the smoothed PLRs
  batch.data.decompose.for.augmentation(data_path = paths[['data_out']][['reconstructed']], 
                                        data_path_out = paths[['data_out']][['FinalOUT']],
                                        RPLR_recon_path = paths[['recon']],
                                        parameters = param[['decomp_augm']],
                                        RPLR_paths = paths[['RPLR']],
                                        masterExcel = paths[['data_in']][['excelMasterPath']],
                                        process_only_unprocessed = TRUE,
                                        path_check_for_done = paths[['data_out']][['FinalOUT']],
                                        pupil_col = 'denoised')
petteriTeikari commented 5 years ago

Fixed this by adding a switch to this so that on Windows, only one thread/core is used

if (identical(.Platform$OS.type, 'windows')) {
      list_of_DFs = lapply(files_to_process, function(files_to_process){
        file.decomp_augmentation.wrapper(files_to_process, data_path_out, param, pupil_col, debug = FALSE)
      }) 

    } else {
      list_of_DFs = mclapply(files_to_process, function(files_to_process){
        file.decomp_augmentation.wrapper(files_to_process, data_path_out, param, pupil_col, debug = FALSE)
      } , mc.cores = param[['no_of_cores_to_use']])
    }