changeset 8:74a8deeedd19 draft

Uploaded
author patrick_chabrier
date Thu, 04 Jul 2024 14:15:56 +0000
parents fe6b69ede424
children 8b69e0234c5c
files carboseqSimulator.xml run.r semantifier.jar
diffstat 3 files changed, 133 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/carboseqSimulator.xml	Mon Jul 01 11:06:13 2024 +0000
+++ b/carboseqSimulator.xml	Thu Jul 04 14:15:56 2024 +0000
@@ -1,16 +1,18 @@
-<tool id="CarboSeqSimulator" name="CarboSeqSimulator" version="1.0.6">
+<tool id="CarboSeqSimulator" name="CarboSeqSimulator" version="1.0.7">
   <description>To run the CarboSeq simulator</description>
   <requirements>
     <container type="singularity">docker://registry.forgemia.inra.fr/csopra/csopralibs:develop</container>
   </requirements>
   <command detect_errors="exit_code"><![CDATA[
+  (java -Dquarkus.http.port=8282 -jar  $__tool_directory__/semantifier.jar &) &&
+  env &&
   (env | grep DOCKER_IMAGE) &&
   printf " Image  Reg   : \$s\n" \$(env | grep DOCKER_IMAGE) &&
   bash -e -c "mkdir output &&
   unzip -d input ${input} &&
   mkdir tmp &&
   export TMPDIR="\${PWD}/tmp" &&
-  Rscript /usr/local/src/myscripts/scenarios/run-sim-perf/run.r --url=https://coby.infosol.inrae.fr:7777/semantify --srcDir=\$(realpath -s input) --srcOut=\$(realpath -s output) --NBCores=\${GALAXY_SLOTS:-4}&&
+  Rscript $__tool_directory__/run.r --url=https://coby.infosol.inrae.fr:7777/semantify --srcDir=\$(realpath -s input) --srcOut=\$(realpath -s output) --NBCores=\${GALAXY_SLOTS:-4}&&
   mv output/* ${output}"
     ]]>
   </command>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run.r	Thu Jul 04 14:15:56 2024 +0000
@@ -0,0 +1,129 @@
+# help : Rscript % --url=https://coby.infosol.inrae.fr:7777/semantify --srcDir=~/CSCL/src/csoprapreprocessor/inst/extdata/carboseq/set001/
+
+# Function to parse command-line arguments
+parse_args <- function() {
+    args <- commandArgs(trailingOnly = TRUE)
+    
+    # Default values for optional parameters
+#	url <- "https://coby.infosol.inrae.fr:8080/semantify/"
+	url <- "http://localhost:8282/semantify"
+	srcDir <- NULL
+	part <- "modeltoolbox_sem_sep"
+	DS <- T
+	NBCores <- 1
+    # Parse arguments
+    for (arg in args) {
+        if (grepl("^--url=", arg)) {
+            url <- sub("^--url=", "", arg)
+        }
+
+	if (grepl("^--srcDir=", arg)) {
+            srcDir <- sub("^--srcDir=", "", arg)
+        }
+
+	if (grepl("^--part=", arg)) {
+            part <- sub("^--part=", "", arg)
+        }
+
+	if (grepl("^--DS=", arg)) {
+            DS <- ifelse(sub("^--DS=", "", arg) == "TRUE", TRUE, FALSE)
+        }
+
+	if (grepl("^--NBCores=", arg)) {
+            NBCores <- as.numeric(sub("^--NBCores=", "", arg))
+        }
+        
+	if (grepl("^--srcOut=", arg)) {
+            srcOut <- sub("^--srcOut=", "", arg)
+        }
+
+    }
+    
+    list(url = url, srcDir = srcDir, part = part, DS = DS, NBCores = NBCores, srcOut = srcOut)
+}
+
+argus <- parse_args()
+url <- argus[["url"]]
+srcDir <- argus[["srcDir"]]
+part <- argus[["part"]]
+DS <- argus[["DS"]]
+NBCores <- argus[["NBCores"]]
+
+srcOut <- argus[["srcOut"]]
+
+if (!endsWith(srcOut, "/")) {
+  srcOut <- paste0(srcOut, "/")
+}
+
+# url="https://147.100.203.110/semantify "
+# srcDir="~/tmp/testFiles/400Sites/"
+# part="modeltoolbox"
+# part="csoprapreprocessor"
+# DS=TRUE
+# NBCores=10
+
+
+# MTB{{{
+if (part == "modeltoolbox") {
+f0 <- function(){
+	modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", 
+	       preprocessorInputs = ppi)
+	modeltoolbox::runSims(maxCores = NBCores)
+	res <- modeltoolbox::readSocForcingsResults()
+	fileName <- "resRun.RData"
+	filePath <- file.path(srcOut, fileName)
+	save(res, file = filePath)
+}
+}
+#}}}
+
+if (part == "modeltoolbox_sem_sep") {
+	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("../..")
+                print("before semantify")
+#		Sys.sleep(runif(n=1, min=30, max=60))
+		csopratools::semantify(
+			  inputDir = srcDir,
+			  outputDir = srcDir,
+			  name = "carboseq",
+			  use = "service", 
+			  URL = url,
+#			  extFileNames = paste0(c("crop", "soil", "units"), ".csv")
+			  extFileNames = list.files(srcDir)
+		)
+		print("between semantify and load")
+		modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", 
+		       preprocessorInputs = ppi)
+		print("between load an sim")       
+		modeltoolbox::runSims(maxCores = NBCores)
+		res <- modeltoolbox::getYearlySOCResults()
+		fileName <- "resRun.RData"
+		filePath <- file.path(srcOut, fileName)
+		save(res, file = filePath)
+	}
+}
+
+ppi <- list(
+					weatherRetrievalMethod = "service",
+		    			srcDir = srcDir,
+					doSemantify = DS,
+			 	        weatherRetrievalURL = "https://147.100.203.110/climate",
+					semantifierServiceURL = url
+	    )
+
+
+print(url)
+print(srcDir)
+print(srcOut)
+print(DS)
+print(NBCores)
+print(f0)
+
+f0()
+
+
Binary file semantifier.jar has changed