# HG changeset patch # User siwaa # Date 1702377500 0 # Node ID 812bb8097dac0440e59752839d564d1027755a11 # Parent 3db1f57029a766a31892599d41e1dcde85ba5f77 "planemo upload for repository https://forgemia.inra.fr/redelac commit d16b9ecdb4dd51b69a6aaa4ab298b82455fe0267" diff -r 3db1f57029a7 -r 812bb8097dac redelacSticsInputGenerator.R --- a/redelacSticsInputGenerator.R Fri Oct 27 09:17:06 2023 +0000 +++ b/redelacSticsInputGenerator.R Tue Dec 12 10:38:20 2023 +0000 @@ -3,6 +3,7 @@ library(lubridate) library(parallel) library(doParallel) +library(doFuture) sessionInfo() @@ -21,9 +22,11 @@ args = commandArgs(trailingOnly = TRUE) -genUSMsXmlOneAfterOther <- (args[1] == "usmx_one_after_other") +redelac <- (args[1] == "optim") parallel <- (args[2] == "parallel") +print(paste("parallel:", parallel, args[2])) nbSlots <- as.integer(args[3]) +print(paste("nbslots:", nbSlots)) # USMs file loading @@ -72,92 +75,37 @@ gen_sta_xml(param_df = sta_param, out_dir = workspace) -if (genUSMsXmlOneAfterOther) { - - durGenX <- lubridate::as.duration(0) - durGenT <- lubridate::as.duration(0) - - if (parallel) { - cl <- makeCluster(nbSlots) - print(cl) - registerDoParallel(cl) - `%dordopar%` <- `%dopar%` - } else { - `%dordopar%` <- `%do%` - } - - # looping on USMs - loopRes <- foreach::foreach(i = 1:nrow(usms_param), - .packages = c("SticsRFiles", "lubridate")) %dordopar% { - - beforeGenXmlTimeI <- Sys.time() - - usmxFileName = paste0("usms", as.character(i) , ".xml") - - usmxFilePath = file.path(workspace, usmxFileName) - - gen_usms_xml(file = usmxFilePath, - param_df = usms_param[i, ]) - - afterGenXmlTimeI <- Sys.time() - durGenXI <- - lubridate::as.duration(lubridate::interval(beforeGenXmlTimeI, - afterGenXmlTimeI)) - - # one after the other generating txt folder - - beforeGenTxtTimeI <- Sys.time() - - gen_usms_xml2txt( - usms_file = usmxFileName, - javastics = javastics_path, - workspace = workspace, - out_dir = txt_path, - verbose = TRUE - ) - - afterGenTxtTimeI <- Sys.time() - durGenTI <- - lubridate::as.duration(lubridate::interval(beforeGenTxtTimeI, - afterGenTxtTimeI)) - - return(c(durGenXI, durGenTI)) - } - - if (parallel) stopCluster(cl) - - durDS <- as.data.frame(do.call(rbind, loopRes)) - durGenX <- sum(durDS[1]) - durGenT <- sum(durDS[2]) - -} else { - - beforeGenXmlTime <- Sys.time() - - gen_usms_xml(file = file.path(workspace, "usms.xml"), - param_df = usms_param) - - afterGenXmlTime <- Sys.time() - durGenX <- - lubridate::as.duration(lubridate::interval(beforeGenXmlTime, - afterGenXmlTime)) - - beforeGenTxtTime <- Sys.time() - - gen_usms_xml2txt( - javastics = javastics_path, - workspace = workspace, - out_dir = txt_path, - verbose = TRUE - ) - - afterGenTxtTime <- Sys.time() - durGenT <- - lubridate::as.duration(lubridate::interval(beforeGenTxtTime, - afterGenTxtTime)) - +if (parallel) { + doFuture::registerDoFuture() + future::plan(multisession, workers = nbSlots) } +beforeGenXmlTime <- Sys.time() + +gen_usms_xml(file = file.path(workspace, "usms.xml"), + param_df = usms_param) + +afterGenXmlTime <- Sys.time() +durGenX <- + lubridate::as.duration(lubridate::interval(beforeGenXmlTime, + afterGenXmlTime)) +beforeGenTxtTime <- Sys.time() + +gen_usms_xml2txt( + javastics = javastics_path, + workspace = workspace, + out_dir = txt_path, + usms_file = "usms.xml", + redelac = redelac, + parallel = parallel, + verbose = FALSE +) + +afterGenTxtTime <- Sys.time() +durGenT <- + lubridate::as.duration(lubridate::interval(beforeGenTxtTime, + afterGenTxtTime)) + endTime <- Sys.time() dur <- @@ -167,8 +115,10 @@ print("REDELACSticsInputGenerator Report") print("=================================") -print(paste0("number of usms: ", nrow(usms_param))) -print(paste("usms.xml one after the other:", genUSMsXmlOneAfterOther)) +print(paste("number of usms: ", nrow(usms_param))) +print(paste("redelac optimization:", redelac)) +print(paste("process in parallel:", parallel)) +print(paste("nbslots:", nbSlots)) sprintf( 'overall duration: %g jour(s) %g heure(s) %g minute(s) %g seconde(s)', diff -r 3db1f57029a7 -r 812bb8097dac redelacSticsInputGenerator.bash --- a/redelacSticsInputGenerator.bash Fri Oct 27 09:17:06 2023 +0000 +++ b/redelacSticsInputGenerator.bash Tue Dec 12 10:38:20 2023 +0000 @@ -17,10 +17,10 @@ cp $9 JavaSTICS-1.5.1-STICS-10.0.0/WS/Ini.csv && cp ${10} JavaSTICS-1.5.1-STICS-10.0.0/WS/Station.csv && cd JavaSTICS-1.5.1-STICS-10.0.0 && -if [[ "$11" != "noAdditionalPlantOrConfig" ]] +(if [[ "$11" != "noAdditionalPlantOrConfig" ]] then - unzip -o ${10} -fi + unzip -q -o ${11} +fi) && /usr/bin/time -p -o ./bashlog Rscript --verbose $4/redelacSticsInputGenerator.R $1 $2 $3 && echo "Step 1, time to run the R script:" && echo "=================================" && diff -r 3db1f57029a7 -r 812bb8097dac redelacSticsInputGenerator.xml --- a/redelacSticsInputGenerator.xml Fri Oct 27 09:17:06 2023 +0000 +++ b/redelacSticsInputGenerator.xml Tue Dec 12 10:38:20 2023 +0000 @@ -1,7 +1,7 @@ - + to run generate Stics Inputs for REDELAC - docker://registry.forgemia.inra.fr/redelac/redelac-toolbox/sticsrpacks:0faa63e7838a2b86369026bf2e628842d7af9863 + docker://registry.forgemia.inra.fr/redelac/redelac-toolbox/sticsrpacks:fc777963cf7921da512ee8b091f4cebcfd1fbe19 @@ -26,15 +26,15 @@ - - - - + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -174,9 +217,9 @@ -*The usage of this tool is restricted to the user of the stics_authorized group.* +*The usage of this tool is restricted to the user of the redelac_authorized group.* -*To be granted, apply to the Project Stics Team and then request to SIWAA* +*To be granted, apply to the REDELAC Project Team and then request to SIWAA* Documentation -------------