changeset 7:366449cab681 draft

"planemo upload for repository https://forgemia.inra.fr/carboseq/record-projet-carboseq/-/tree/b4b11a86a9c43b3dd4a3d27af9f2d99463cdbffa/toos/CarboSeqSimulator commit b4b11a86a9c43b3dd4a3d27af9f2d99463cdbffa-dirty"
author siwaa
date Thu, 29 Aug 2024 14:58:19 +0000
parents f9183e245cdb
children 5fdc9d0c223b
files carboseqSimulator.xml run.r
diffstat 2 files changed, 99 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/carboseqSimulator.xml	Thu Aug 29 10:11:24 2024 +0000
+++ b/carboseqSimulator.xml	Thu Aug 29 14:58:19 2024 +0000
@@ -1,4 +1,4 @@
-<tool id="CarboSeqSimulator" name="CarboSeqSimulator" version="1.0.12">
+<tool id="CarboSeqSimulator" name="CarboSeqSimulator" version="1.0.13">
   <description>To run the CarboSeq simulator</description>
   <requirements>
     <container type="singularity">docker://registry.forgemia.inra.fr/csopra/csopralibs:siwaa</container>
@@ -12,7 +12,7 @@
   cp /usr/local/src/myscripts/start_server.sh . &&
   cp -r /usr/local/src/myscripts/config_mappers . &&
   cp -r /usr/local/src/myscripts/data . &&
-  Rscript /usr/local/src/myscripts/scenarios/run-sim-perf/run.r --srcDir=\$(realpath -s input) --srcOut=\$(realpath -s output) --semPath=\$(realpath -s .) --part=${semantifier} --NBCores=\${GALAXY_SLOTS:-4}&&
+  Rscript $__tool_directory__/run.r --srcDir=\$(realpath -s input) --srcOut=\$(realpath -s output) --semPath=\$(realpath -s .) --part=${semantifier} --NBCores=\${GALAXY_SLOTS:-4}&&
   cp output/* ${output}"
     ]]>
   </command>
--- a/run.r	Thu Aug 29 10:11:24 2024 +0000
+++ b/run.r	Thu Aug 29 14:58:19 2024 +0000
@@ -1,3 +1,4 @@
+
 # help : Rscript % --url=https://coby.infosol.inrae.fr:7777/semantify --srcDir=~/CSCL/src/csoprapreprocessor/inst/extdata/carboseq/set001/
 
 # Function to parse command-line arguments
@@ -7,53 +8,71 @@
     # Default values for optional parameters
 	url <- "https://coby.infosol.inrae.fr:8080/semantify/"
 	srcDir <- NULL
-	part <- "modeltoolbox"
+	# srcDirOutput <- NULL
+	part <- "modeltoolbox_sem_remote"
 	DS <- T
 	NBCores <- 1
+	semPath <- "."
     # Parse arguments
     for (arg in args) {
+
         if (grepl("^--url=", arg)) {
             url <- sub("^--url=", "", arg)
         }
 
-	if (grepl("^--srcDir=", arg)) {
+ 	    if (grepl("^--srcDir=", arg)) {
             srcDir <- sub("^--srcDir=", "", arg)
         }
 
-	if (grepl("^--part=", arg)) {
+        # if (grepl("^--srcDirOutput=", arg)) {
+        #    srcDirOutput <- sub("^--srcDirOutput=", "", arg)
+        # }
+	    if (grepl("^--part=", arg)) {
             part <- sub("^--part=", "", arg)
         }
 
-	if (grepl("^--DS=", arg)) {
+	    if (grepl("^--DS=", arg)) {
             DS <- ifelse(sub("^--DS=", "", arg) == "TRUE", TRUE, FALSE)
         }
 
-	if (grepl("^--NBCores=", arg)) {
+	    if (grepl("^--NBCores=", arg)) {
             NBCores <- as.numeric(sub("^--NBCores=", "", arg))
         }
         
-	if (grepl("^--srcOut=", arg)) {
+	    if (grepl("^--srcOut=", arg)) {
             srcOut <- sub("^--srcOut=", "", arg)
         }
 
+		if (grepl("^--semPath=", arg)) {
+            semPath <- sub("^--semPath=", "", arg)
+        }
     }
     
-    list(url = url, srcDir = srcDir, part = part, DS = DS, NBCores = NBCores, srcOut = srcOut)
+    list( url = url, srcDir = srcDir, part = part, DS = DS, 
+	      NBCores = NBCores, srcOut = srcOut, semPath = semPath )
 }
 
 argus <- parse_args()
+
 url <- argus[["url"]]
 srcDir <- argus[["srcDir"]]
+# srcDirOutput <- argus[["srcDirOutput"]]
 part <- argus[["part"]]
 DS <- argus[["DS"]]
 NBCores <- argus[["NBCores"]]
 
 srcOut <- argus[["srcOut"]]
 
+semPath <- argus[["semPath"]]
+
 if (!endsWith(srcOut, "/")) {
   srcOut <- paste0(srcOut, "/")
 }
 
+#if (is.null(srcDirOutput)) {
+#  srcDirOutput <- srcDir
+# }
+
 # url="https://147.100.203.110/semantify "
 # srcDir="~/tmp/testFiles/400Sites/"
 # part="modeltoolbox"
@@ -61,15 +80,6 @@
 # DS=TRUE
 # NBCores=10
 
-ppi <- list(
-					weatherRetrievalMethod = "service",
-		    			srcDir = srcDir,
-					doSemantify = DS,
-			 	        weatherRetrievalURL = "https://147.100.203.110/climate",
-					semantifierServiceURL = url
-	    )
-
-
 # MTB{{{
 if (part == "modeltoolbox") {
 f0 <- function(){
@@ -84,26 +94,84 @@
 }
 #}}}
 
-# prepro{{
-if (part == "csoprapreprocessor") {
-f0 <- function(){
-	path <- this.path::this.dir()
-	print(path)
-	setwd(path)
-	setwd("../..")
-	source("src/csoprapreprocessor/src-utils.r")
-	CsopPre$Tool$sourceCodeFiles()
-	CsopPre$runPreprocessor(name = "carboseq", maxCores = NBCores, preprocessorInputs = ppi)
+if (part == "modeltoolbox_sem_local") {
+	DS <- F
+	print("Setting DS to F. Will semantify outside of the csoprapreprocessor functions")
+	f0 <- function(){
+		path <- this.path::this.dir()
+		print(path)
+		csopratools::semantify(
+			  inputDir = srcDir,
+			  outputDir = srcDir,
+			  name = "carboseq",
+			  # use = "service",
+			  URL = url,
+			  use = "java",
+			  semantifierRootPath =  semPath,
+			  extFileNames = paste0(c("crop", "soil", "units"), ".csv")
+		)
+		print("between semantify and load")
+
+		ppi$srcDirOutput <- NULL # Hack
+
+		modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", 
+		       preprocessorInputs = ppi)
+		print("between load an sim")       
+		modeltoolbox::runSims(maxCores = NBCores)
+		# res <- modeltoolbox::getYearlySOCResults()
+		res <- modeltoolbox::readSocForcingsResults()
+		fileName <- "resRun.RData"
+		filePath <- file.path(srcOut, fileName)
+		save(res, file = filePath)
+	}
 }
+
+if (part == "modeltoolbox_sem_remote") {
+	DS <- F
+	print("Setting DS to F. Will semantify outside of the csoprapreprocessor functions")
+	f0 <- function(){
+		path <- this.path::this.dir()
+		print(path)
+		setwd(path)
+		setwd("../..")
+		csopratools::semantify(
+			  inputDir = srcDir,
+			  outputDir = srcDir,
+			  name = "carboseq",
+			  use = "service", 
+			  URL = url,
+			  extFileNames = paste0(c("crop", "soil", "units"), ".csv")
+		)
+
+		# ppi$srcDirOutput <- NULL # Hack
+
+		modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", 
+		       preprocessorInputs = ppi)
+		modeltoolbox::runSims(maxCores = NBCores)
+		# res <- modeltoolbox::getYearlySOCResults()
+		res <- modeltoolbox::readSocForcingsResults()
+		fileName <- "resRun.RData"
+		filePath <- file.path(srcOut, fileName)
+		save(res, file = filePath)
+	}
 }
-#}}}
+
+ppi <- list(
+			 weatherRetrievalMethod = "service",
+		     srcDir = srcDir,
+		 	 # srcDirOutput = srcDirOutput,
+			 doSemantify = DS,
+			 weatherRetrievalURL = "https://coby.infosol.inrae.fr:8080/climate",
+			 semantifierServiceURL = url
+	    )
+
 
 print(url)
 print(srcDir)
+# print(srcDirOutput)
 print(srcOut)
 print(DS)
 print(NBCores)
 print(f0)
+
 f0()
-
-