Mercurial > repos > siwaa > carboseq_s
comparison run.r @ 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 | a069fc43b0b1 |
children | 5fdc9d0c223b |
comparison
equal
deleted
inserted
replaced
6:f9183e245cdb | 7:366449cab681 |
---|---|
1 | |
1 # help : Rscript % --url=https://coby.infosol.inrae.fr:7777/semantify --srcDir=~/CSCL/src/csoprapreprocessor/inst/extdata/carboseq/set001/ | 2 # help : Rscript % --url=https://coby.infosol.inrae.fr:7777/semantify --srcDir=~/CSCL/src/csoprapreprocessor/inst/extdata/carboseq/set001/ |
2 | 3 |
3 # Function to parse command-line arguments | 4 # Function to parse command-line arguments |
4 parse_args <- function() { | 5 parse_args <- function() { |
5 args <- commandArgs(trailingOnly = TRUE) | 6 args <- commandArgs(trailingOnly = TRUE) |
6 | 7 |
7 # Default values for optional parameters | 8 # Default values for optional parameters |
8 url <- "https://coby.infosol.inrae.fr:8080/semantify/" | 9 url <- "https://coby.infosol.inrae.fr:8080/semantify/" |
9 srcDir <- NULL | 10 srcDir <- NULL |
10 part <- "modeltoolbox" | 11 # srcDirOutput <- NULL |
12 part <- "modeltoolbox_sem_remote" | |
11 DS <- T | 13 DS <- T |
12 NBCores <- 1 | 14 NBCores <- 1 |
15 semPath <- "." | |
13 # Parse arguments | 16 # Parse arguments |
14 for (arg in args) { | 17 for (arg in args) { |
18 | |
15 if (grepl("^--url=", arg)) { | 19 if (grepl("^--url=", arg)) { |
16 url <- sub("^--url=", "", arg) | 20 url <- sub("^--url=", "", arg) |
17 } | 21 } |
18 | 22 |
19 if (grepl("^--srcDir=", arg)) { | 23 if (grepl("^--srcDir=", arg)) { |
20 srcDir <- sub("^--srcDir=", "", arg) | 24 srcDir <- sub("^--srcDir=", "", arg) |
21 } | 25 } |
22 | 26 |
23 if (grepl("^--part=", arg)) { | 27 # if (grepl("^--srcDirOutput=", arg)) { |
28 # srcDirOutput <- sub("^--srcDirOutput=", "", arg) | |
29 # } | |
30 if (grepl("^--part=", arg)) { | |
24 part <- sub("^--part=", "", arg) | 31 part <- sub("^--part=", "", arg) |
25 } | 32 } |
26 | 33 |
27 if (grepl("^--DS=", arg)) { | 34 if (grepl("^--DS=", arg)) { |
28 DS <- ifelse(sub("^--DS=", "", arg) == "TRUE", TRUE, FALSE) | 35 DS <- ifelse(sub("^--DS=", "", arg) == "TRUE", TRUE, FALSE) |
29 } | 36 } |
30 | 37 |
31 if (grepl("^--NBCores=", arg)) { | 38 if (grepl("^--NBCores=", arg)) { |
32 NBCores <- as.numeric(sub("^--NBCores=", "", arg)) | 39 NBCores <- as.numeric(sub("^--NBCores=", "", arg)) |
33 } | 40 } |
34 | 41 |
35 if (grepl("^--srcOut=", arg)) { | 42 if (grepl("^--srcOut=", arg)) { |
36 srcOut <- sub("^--srcOut=", "", arg) | 43 srcOut <- sub("^--srcOut=", "", arg) |
37 } | 44 } |
38 | 45 |
46 if (grepl("^--semPath=", arg)) { | |
47 semPath <- sub("^--semPath=", "", arg) | |
48 } | |
39 } | 49 } |
40 | 50 |
41 list(url = url, srcDir = srcDir, part = part, DS = DS, NBCores = NBCores, srcOut = srcOut) | 51 list( url = url, srcDir = srcDir, part = part, DS = DS, |
52 NBCores = NBCores, srcOut = srcOut, semPath = semPath ) | |
42 } | 53 } |
43 | 54 |
44 argus <- parse_args() | 55 argus <- parse_args() |
56 | |
45 url <- argus[["url"]] | 57 url <- argus[["url"]] |
46 srcDir <- argus[["srcDir"]] | 58 srcDir <- argus[["srcDir"]] |
59 # srcDirOutput <- argus[["srcDirOutput"]] | |
47 part <- argus[["part"]] | 60 part <- argus[["part"]] |
48 DS <- argus[["DS"]] | 61 DS <- argus[["DS"]] |
49 NBCores <- argus[["NBCores"]] | 62 NBCores <- argus[["NBCores"]] |
50 | 63 |
51 srcOut <- argus[["srcOut"]] | 64 srcOut <- argus[["srcOut"]] |
52 | 65 |
66 semPath <- argus[["semPath"]] | |
67 | |
53 if (!endsWith(srcOut, "/")) { | 68 if (!endsWith(srcOut, "/")) { |
54 srcOut <- paste0(srcOut, "/") | 69 srcOut <- paste0(srcOut, "/") |
55 } | 70 } |
71 | |
72 #if (is.null(srcDirOutput)) { | |
73 # srcDirOutput <- srcDir | |
74 # } | |
56 | 75 |
57 # url="https://147.100.203.110/semantify " | 76 # url="https://147.100.203.110/semantify " |
58 # srcDir="~/tmp/testFiles/400Sites/" | 77 # srcDir="~/tmp/testFiles/400Sites/" |
59 # part="modeltoolbox" | 78 # part="modeltoolbox" |
60 # part="csoprapreprocessor" | 79 # part="csoprapreprocessor" |
61 # DS=TRUE | 80 # DS=TRUE |
62 # NBCores=10 | 81 # NBCores=10 |
63 | |
64 ppi <- list( | |
65 weatherRetrievalMethod = "service", | |
66 srcDir = srcDir, | |
67 doSemantify = DS, | |
68 weatherRetrievalURL = "https://147.100.203.110/climate", | |
69 semantifierServiceURL = url | |
70 ) | |
71 | |
72 | 82 |
73 # MTB{{{ | 83 # MTB{{{ |
74 if (part == "modeltoolbox") { | 84 if (part == "modeltoolbox") { |
75 f0 <- function(){ | 85 f0 <- function(){ |
76 modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", | 86 modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", |
82 save(res, file = filePath) | 92 save(res, file = filePath) |
83 } | 93 } |
84 } | 94 } |
85 #}}} | 95 #}}} |
86 | 96 |
87 # prepro{{ | 97 if (part == "modeltoolbox_sem_local") { |
88 if (part == "csoprapreprocessor") { | 98 DS <- F |
89 f0 <- function(){ | 99 print("Setting DS to F. Will semantify outside of the csoprapreprocessor functions") |
90 path <- this.path::this.dir() | 100 f0 <- function(){ |
91 print(path) | 101 path <- this.path::this.dir() |
92 setwd(path) | 102 print(path) |
93 setwd("../..") | 103 csopratools::semantify( |
94 source("src/csoprapreprocessor/src-utils.r") | 104 inputDir = srcDir, |
95 CsopPre$Tool$sourceCodeFiles() | 105 outputDir = srcDir, |
96 CsopPre$runPreprocessor(name = "carboseq", maxCores = NBCores, preprocessorInputs = ppi) | 106 name = "carboseq", |
107 # use = "service", | |
108 URL = url, | |
109 use = "java", | |
110 semantifierRootPath = semPath, | |
111 extFileNames = paste0(c("crop", "soil", "units"), ".csv") | |
112 ) | |
113 print("between semantify and load") | |
114 | |
115 ppi$srcDirOutput <- NULL # Hack | |
116 | |
117 modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", | |
118 preprocessorInputs = ppi) | |
119 print("between load an sim") | |
120 modeltoolbox::runSims(maxCores = NBCores) | |
121 # res <- modeltoolbox::getYearlySOCResults() | |
122 res <- modeltoolbox::readSocForcingsResults() | |
123 fileName <- "resRun.RData" | |
124 filePath <- file.path(srcOut, fileName) | |
125 save(res, file = filePath) | |
126 } | |
97 } | 127 } |
128 | |
129 if (part == "modeltoolbox_sem_remote") { | |
130 DS <- F | |
131 print("Setting DS to F. Will semantify outside of the csoprapreprocessor functions") | |
132 f0 <- function(){ | |
133 path <- this.path::this.dir() | |
134 print(path) | |
135 setwd(path) | |
136 setwd("../..") | |
137 csopratools::semantify( | |
138 inputDir = srcDir, | |
139 outputDir = srcDir, | |
140 name = "carboseq", | |
141 use = "service", | |
142 URL = url, | |
143 extFileNames = paste0(c("crop", "soil", "units"), ".csv") | |
144 ) | |
145 | |
146 # ppi$srcDirOutput <- NULL # Hack | |
147 | |
148 modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", | |
149 preprocessorInputs = ppi) | |
150 modeltoolbox::runSims(maxCores = NBCores) | |
151 # res <- modeltoolbox::getYearlySOCResults() | |
152 res <- modeltoolbox::readSocForcingsResults() | |
153 fileName <- "resRun.RData" | |
154 filePath <- file.path(srcOut, fileName) | |
155 save(res, file = filePath) | |
156 } | |
98 } | 157 } |
99 #}}} | 158 |
159 ppi <- list( | |
160 weatherRetrievalMethod = "service", | |
161 srcDir = srcDir, | |
162 # srcDirOutput = srcDirOutput, | |
163 doSemantify = DS, | |
164 weatherRetrievalURL = "https://coby.infosol.inrae.fr:8080/climate", | |
165 semantifierServiceURL = url | |
166 ) | |
167 | |
100 | 168 |
101 print(url) | 169 print(url) |
102 print(srcDir) | 170 print(srcDir) |
171 # print(srcDirOutput) | |
103 print(srcOut) | 172 print(srcOut) |
104 print(DS) | 173 print(DS) |
105 print(NBCores) | 174 print(NBCores) |
106 print(f0) | 175 print(f0) |
176 | |
107 f0() | 177 f0() |
108 | |
109 |