Skip to content

Commit

Permalink
add raw config key setting and a convinience wrapper for the requeste…
Browse files Browse the repository at this point in the history
…d keys in issue #1
  • Loading branch information
mboecker committed Sep 7, 2018
1 parent 7d2073b commit df936f7
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/R/mboServiceConnect.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library("httr")
mboServiceConnect = function(hostname) {
url = sprintf("%s/session/open", hostname)
result = httr::GET(url)
session_id = trimws(httr::content(result, as = "text"))
session_id = trimws(httr::content(result, as = "text", encoding="utf8"))
obj = list(
hostname = hostname,
session_id = session_id
Expand Down
57 changes: 54 additions & 3 deletions client/R/mboServiceSetConfigKey.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
library("httr")

mboServiceSetConfigKey = function(obj, key, value) {
url = sprintf("%s/set/%s/%s/%s", obj$hostname, obj$session_id, key, value)
result = httr::GET(url)
mboServiceSetConfigKey = function(obj, minimize = NULL, noisy = NULL, propose.points = NULL, opt.restarts = NULL, opt.focussearch.maxit = NULL, opt.focussearch.points = NULL) {
if(!is.null(minimize)) {
if(is.logical(minimize)) {
mboServiceSetConfigKeyRaw(obj, "minimize", minimize)
} else {
# FIXME
stop("wrong type")
}
}

if(!is.null(noisy)) {
if(is.logical(noisy)) {
mboServiceSetConfigKeyRaw(obj, "noisy", noisy)
} else {
# FIXME
stop("wrong type")
}
}

if(!is.null(propose.points)) {
if(is.numeric(propose.points)) {
mboServiceSetConfigKeyRaw(obj, "propose.points", propose.points)
} else {
# FIXME
stop("wrong type")
}
}

if(!is.null(opt.restarts)) {
if(is.numeric(opt.restarts)) {
mboServiceSetConfigKeyRaw(obj, "opt.restarts", opt.restarts)
} else {
# FIXME
stop("wrong type")
}
}

if(!is.null(opt.focussearch.maxit)) {
if(is.numeric(opt.focussearch.maxit)) {
mboServiceSetConfigKeyRaw(obj, "opt.focussearch.maxit", opt.focussearch.maxit)
} else {
# FIXME
stop("wrong type")
}
}

if(!is.null(opt.focussearch.points)) {
if(is.numeric(opt.focussearch.points)) {
mboServiceSetConfigKeyRaw(obj, "opt.focussearch.points", opt.focussearch.points)
} else {
# FIXME
stop("wrong type")
}
}
}
6 changes: 6 additions & 0 deletions client/R/mboServiceSetConfigKeyRaw.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library("httr")

mboServiceSetConfigKeyRaw = function(obj, key, value) {
url = sprintf("%s/set/%s/%s/%s", obj$hostname, obj$session_id, key, value)
result = httr::GET(url)
}
8 changes: 4 additions & 4 deletions client/tests/simple.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
devtools::load_all()
obj = mboServiceConnect("http://localhost:5000")
data = data.frame(x = c(5,10), y = c(20,30))
mboServiceSetConfigKey(obj, "par.set", "{}")
mboServiceSetConfigKeyRaw(obj, "par.set", "{}")
mboServiceUpload(obj, data)
#point = mboServicePropose(obj)
#print(point)
#mboServiceDisconnect(obj)
point = mboServicePropose(obj)
print(point)
mboServiceDisconnect(obj)

0 comments on commit df936f7

Please sign in to comment.