Mercurial > repos > siwaa > carboseq_s
comparison run.r @ 4:a069fc43b0b1 draft
"planemo upload for repository https://forgemia.inra.fr/carboseq/record-projet-carboseq/-/tree/ed5816b24b0c91099c78cbb5bbbe835ae5c74cd7/toos/CarboSeqSimulator commit ed5816b24b0c91099c78cbb5bbbe835ae5c74cd7-dirty"
author | siwaa |
---|---|
date | Fri, 23 Aug 2024 13:19:04 +0000 |
parents | 89c69fcbf561 |
children | 366449cab681 |
comparison
equal
deleted
inserted
replaced
3:d753f3430970 | 4:a069fc43b0b1 |
---|---|
5 args <- commandArgs(trailingOnly = TRUE) | 5 args <- commandArgs(trailingOnly = TRUE) |
6 | 6 |
7 # Default values for optional parameters | 7 # Default values for optional parameters |
8 url <- "https://coby.infosol.inrae.fr:8080/semantify/" | 8 url <- "https://coby.infosol.inrae.fr:8080/semantify/" |
9 srcDir <- NULL | 9 srcDir <- NULL |
10 part <- "modeltoolbox_sem_sep" | 10 part <- "modeltoolbox" |
11 DS <- T | 11 DS <- T |
12 NBCores <- 1 | 12 NBCores <- 1 |
13 # Parse arguments | 13 # Parse arguments |
14 for (arg in args) { | 14 for (arg in args) { |
15 if (grepl("^--url=", arg)) { | 15 if (grepl("^--url=", arg)) { |
33 } | 33 } |
34 | 34 |
35 if (grepl("^--srcOut=", arg)) { | 35 if (grepl("^--srcOut=", arg)) { |
36 srcOut <- sub("^--srcOut=", "", arg) | 36 srcOut <- sub("^--srcOut=", "", arg) |
37 } | 37 } |
38 | |
39 if (grepl("^--semPath=", arg)) { | |
40 semPath <- sub("^--semPath=", "", arg) | |
41 } | |
42 | 38 |
43 } | 39 } |
44 | 40 |
45 list(url = url, srcDir = srcDir, part = part, DS = DS, NBCores = NBCores, srcOut = srcOut, semPath = semPath) | 41 list(url = url, srcDir = srcDir, part = part, DS = DS, NBCores = NBCores, srcOut = srcOut) |
46 } | 42 } |
47 | 43 |
48 argus <- parse_args() | 44 argus <- parse_args() |
49 url <- argus[["url"]] | 45 url <- argus[["url"]] |
50 srcDir <- argus[["srcDir"]] | 46 srcDir <- argus[["srcDir"]] |
51 part <- argus[["part"]] | 47 part <- argus[["part"]] |
52 DS <- argus[["DS"]] | 48 DS <- argus[["DS"]] |
53 NBCores <- argus[["NBCores"]] | 49 NBCores <- argus[["NBCores"]] |
54 | 50 |
55 srcOut <- argus[["srcOut"]] | 51 srcOut <- argus[["srcOut"]] |
56 semPath <- argus[["semPath"]] | |
57 | 52 |
58 if (!endsWith(srcOut, "/")) { | 53 if (!endsWith(srcOut, "/")) { |
59 srcOut <- paste0(srcOut, "/") | 54 srcOut <- paste0(srcOut, "/") |
60 } | 55 } |
61 | 56 |
63 # srcDir="~/tmp/testFiles/400Sites/" | 58 # srcDir="~/tmp/testFiles/400Sites/" |
64 # part="modeltoolbox" | 59 # part="modeltoolbox" |
65 # part="csoprapreprocessor" | 60 # part="csoprapreprocessor" |
66 # DS=TRUE | 61 # DS=TRUE |
67 # NBCores=10 | 62 # 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 ) | |
68 | 71 |
69 | 72 |
70 # MTB{{{ | 73 # MTB{{{ |
71 if (part == "modeltoolbox") { | 74 if (part == "modeltoolbox") { |
72 f0 <- function(){ | 75 f0 <- function(){ |
79 save(res, file = filePath) | 82 save(res, file = filePath) |
80 } | 83 } |
81 } | 84 } |
82 #}}} | 85 #}}} |
83 | 86 |
84 if (part == "modeltoolbox_sem_sep") { | 87 # prepro{{ |
85 DS <- F | 88 if (part == "csoprapreprocessor") { |
86 print("Setting DS to F. Will semantify outside of the csoprapreprocessor functions") | 89 f0 <- function(){ |
87 f0 <- function(){ | 90 path <- this.path::this.dir() |
88 csopratools::semantify( | 91 print(path) |
89 inputDir = srcDir, | 92 setwd(path) |
90 outputDir = srcDir, | 93 setwd("../..") |
91 name = "carboseq", | 94 source("src/csoprapreprocessor/src-utils.r") |
92 # use = "service", | 95 CsopPre$Tool$sourceCodeFiles() |
93 URL = url, | 96 CsopPre$runPreprocessor(name = "carboseq", maxCores = NBCores, preprocessorInputs = ppi) |
94 use = "java", | |
95 semantifierRootPath = semPath, | |
96 extFileNames = paste0(c("crop", "soil", "units"), ".csv") | |
97 ) | |
98 print("between semantify and load") | |
99 modeltoolbox::loadCSVs(maxCores = NBCores, cinputCalculator = "cinest", | |
100 preprocessorInputs = ppi) | |
101 print("between load an sim") | |
102 modeltoolbox::runSims(maxCores = NBCores) | |
103 res <- modeltoolbox::getYearlySOCResults() | |
104 fileName <- "resRun.RData" | |
105 filePath <- file.path(srcOut, fileName) | |
106 save(res, file = filePath) | |
107 } | |
108 } | 97 } |
109 | 98 } |
110 ppi <- list( | 99 #}}} |
111 weatherRetrievalMethod = "service", | |
112 srcDir = srcDir, | |
113 doSemantify = DS, | |
114 weatherRetrievalURL = "https://147.100.203.110/climate", | |
115 semantifierServiceURL = url | |
116 ) | |
117 | |
118 | 100 |
119 print(url) | 101 print(url) |
120 print(srcDir) | 102 print(srcDir) |
121 print(srcOut) | 103 print(srcOut) |
122 print(DS) | 104 print(DS) |
123 print(NBCores) | 105 print(NBCores) |
124 print(f0) | 106 print(f0) |
125 | |
126 f0() | 107 f0() |
127 | 108 |
128 | 109 |