Skip to content

Commit 06ba490

Browse files
committed
fix many R checks & sync with funz v1.14
1 parent 4c8a129 commit 06ba490

File tree

5 files changed

+34
-33
lines changed

5 files changed

+34
-33
lines changed

R/calculator.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ startCalculators <- function(n=1) {
3232
p=NULL
3333
if (Sys.info()[['sysname']]=="Windows")
3434
for (i in 1:n)
35-
p = c(p,process$new(file.path(FUNZ_HOME,"FunzDaemon.bat"),
35+
p = c(p,process$new("cmd.exe", c("/c", "call", file.path(FUNZ_HOME,"FunzDaemon.bat")),
3636
stdout = NULL, stderr = NULL))
3737
else
3838
for (i in 1:n)
39-
p = c(p,process$new(file.path(FUNZ_HOME,"FunzDaemon.sh"),
39+
p = c(p,process$new("/bin/bash", c("-c", file.path(FUNZ_HOME,"FunzDaemon.sh")),
4040
stdout = NULL, stderr = NULL))
4141
p
4242
}
4343

4444
#' Shutdown calculator instances (also named as "funz daemons")
4545
#'
46-
#' @param px array of processx objects to stop (returned values of startCalculators()^)
46+
#' @param px array of processx objects to stop (returned values of startCalculators())
4747
#' @export
4848
#' @examples
4949
#' \dontrun{

R/client.R

+11-7
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ Run <- function(model=NULL,input.files,
4949
}
5050

5151

52-
#' Get last Funz Run(...) call
52+
#' Get last Funz Run() call
5353
#'
54-
#' @return last Funz Run(...) call
54+
#' @return last Funz Run() call
5555
#' @export
5656
.Last.run <- function() {
57-
return(.Funz.Last.run)
57+
return(.env$.Funz.Last.run)
5858
}
5959

6060
#' Apply a design of experiments through Funz environment on a response surface.
@@ -94,12 +94,12 @@ Design <- function(fun, design, options=NULL,
9494
archive.dir=archive.dir,verbosity=verbosity,log.file=FALSE,...))
9595
}
9696

97-
#' Get last Funz Design(...) call
97+
#' Get last Funz Design() call
9898
#'
99-
#' @return last Funz Design(...) call
99+
#' @return last Funz Design() call
100100
#' @export
101101
.Last.design <- function() {
102-
return(.Funz.Last.design)
102+
return(.env$.Funz.Last.design)
103103
}
104104

105105
#' Call an external (to R) code wrapped through Funz environment.
@@ -160,7 +160,7 @@ RunDesign <- function(model=NULL,input.files,
160160
#' @return last Funz RunDesign(...) call
161161
#' @export
162162
.Last.rundesign <- function() {
163-
return(.Funz.Last.rundesign)
163+
return(.env$.Funz.Last.rundesign)
164164
}
165165

166166
#' Convenience method to find variables & related info. in parametrized file.
@@ -171,8 +171,10 @@ RunDesign <- function(model=NULL,input.files,
171171
#' @return list of variables & their possible default value
172172
#' @export
173173
#' @examples
174+
#' \dontrun{
174175
#' ParseInput(model = "R",
175176
#' input.files = file.path(Funz:::FUNZ_HOME,"samples","branin.R"))
177+
#' }
176178
ParseInput <- function(model,input.files) {
177179
return(Funz_ParseInput(model=model,input.files=input.files))
178180
}
@@ -186,12 +188,14 @@ ParseInput <- function(model,input.files) {
186188
#'
187189
#' @export
188190
#' @examples
191+
#' \dontrun{
189192
#' CompileInput(model = "R",
190193
#' input.files = file.path(Funz:::FUNZ_HOME,"samples","branin.R"),
191194
#' input.values = list(x1=0.5, x2=0.6))
192195
#' CompileInput(model = "R",
193196
#' input.files = file.path(Funz:::FUNZ_HOME,"samples","branin.R"),
194197
#' input.values = list(x1=c(0.5,.55), b=c(0.6,.7)))
198+
#' }
195199
CompileInput <- function(model,input.files,input.values,output.dir=".") {
196200
return(Funz_CompileInput(model=model,input.files=input.files,input.values=input.values,output.dir=output.dir))
197201
}

R/install.R

+15-23
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
.onLoad <- function(libname, pkgname) {
2-
gv = c(".jclassFunz", ".jclassFile", ".jclassData", ".jclassFormat", ".jclassPrint",
3-
".jclassDesignShell", ".jclassRunShell", ".jclassShell", ".jclassLinkedHashMap",
4-
".jclassHashMap", ".jclassConstants", ".jclassSystem", ".jclassUtils",".jclassSystem",
5-
".FUNZ_HOME")
6-
utils::globalVariables(gv,package = pkgname)
7-
for (v in gv)
8-
assign(v, NULL, envir = parent.env(environment()))
92
assign("FUNZ_HOME",system.file("Funz", package = "Funz"), envir = parent.env(environment()))
10-
113
source(file.path(FUNZ_HOME,"Funz.R"),local=parent.env(environment()))
124
Funz.init(FUNZ_HOME,
135
verbosity=0,
146
java.control=if (Sys.info()[['sysname']]=="Windows")
15-
list(Xmx="512m",Xss="256k", app.user=tempdir())
7+
list(Xmx="512m", Xss="256k", app.user=tempdir(), USE_RSERVE_FROM_CRAN="true")
168
else
17-
list(Xmx="512m", app.user=tempdir()))
9+
list(Xmx="512m", app.user=tempdir(), USE_RSERVE_FROM_CRAN="true"))
1810
}
1911

2012

@@ -39,7 +31,7 @@ if (length(.github_repos)==0) .github_repos <- NA
3931
#' @examples
4032
#' installed.Models()
4133
installed.Models <- function() {
42-
.jclassFunz$getModelList()
34+
.env$.jclassFunz$getModelList()
4335
}
4436

4537

@@ -53,8 +45,8 @@ installed.Models <- function() {
5345
#' @examples
5446
#' available.Models()
5547
available.Models <- function(refresh_repo = F) {
56-
if (refresh_repo | is.na(.github_repos))
57-
.github_repos <<- gh::gh("/orgs/Funz/repos",.token=NA)
48+
if (refresh_repo | any(is.na(.github_repos)))
49+
.env$.github_repos <- gh::gh("/orgs/Funz/repos",.token=NA)
5850

5951
gsub("plugin-","",
6052
unlist(lapply(.github_repos,
@@ -76,14 +68,14 @@ install_file.Model <- function(model.zip, model=gsub(".zip(.*)","",gsub("(.*)plu
7668
warning("Model ",model," was already installed. Skipping new installation.")
7769
return()
7870
} else
79-
message("Model ",model," was already installed. Forcing new installation...")
71+
message("Model ",model," was already installed. Forcing new installation..")
8072

8173
utils::unzip(zipfile=model.zip, exdir=FUNZ_HOME,...)
8274

8375
eval({
84-
.jclassFunz$init()
85-
.Funz.Models <<- installed.Models()
86-
.Funz.Designs <<- installed.Designs()
76+
.env$.jclassFunz$init()
77+
.env$.Funz.Models <- installed.Models()
78+
.env$.Funz.Designs <- installed.Designs()
8779
}) # reload plugins in Funz env
8880
if (!(model %in% installed.Models()))
8981
stop("Could not install model ",model , " from ",model.zip)
@@ -217,7 +209,7 @@ install.Model <- function(model,force=F) {
217209
#' @examples
218210
#' installed.Designs()
219211
installed.Designs <- function() {
220-
.jclassFunz$getDesignList()
212+
.env$.jclassFunz$getDesignList()
221213
}
222214

223215
#' List available designs from Funz GitHub repository
@@ -230,8 +222,8 @@ installed.Designs <- function() {
230222
#' @examples
231223
#' available.Designs()
232224
available.Designs <- function(refresh_repo = F) {
233-
if (refresh_repo | is.na(.github_repos))
234-
.github_repos <<- gh::gh("/orgs/Funz/repos",.token=NA)
225+
if (refresh_repo | any(is.na(.github_repos)))
226+
.env$.github_repos <- gh::gh("/orgs/Funz/repos",.token=NA)
235227

236228
gsub("algorithm-","",
237229
unlist(lapply(.github_repos,
@@ -262,9 +254,9 @@ install_file.Design <- function(design.zip, design=gsub(".zip(.*)","",gsub("(.*)
262254
utils::unzip(zipfile=design.zip, exdir=FUNZ_HOME,...)
263255

264256
eval({
265-
.jclassFunz$init()
266-
.Funz.Models <<- installed.Models()
267-
.Funz.Designs <<- installed.Designs()
257+
.env$.jclassFunz$init()
258+
.env$.Funz.Models <- installed.Models()
259+
.env$.Funz.Designs <- installed.Designs()
268260
}) # reload plugins in Funz env
269261
if (!(design %in% installed.Designs()))
270262
stop("Could not install design ",design , " from ",design.zip)

configure

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
: "${R_HOME=`R RHOME`}"
3+
echo "R.home=${R_HOME}" >> inst/Funz/Funz.conf

configure.win

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
echo "R.home=${R_HOME}" >> inst/Funz/Funz.conf

0 commit comments

Comments
 (0)