vle-forge / rvle

R wrapper
GNU General Public License v3.0
1 stars 3 forks source link

It is not possible to disable some outputs from rvle functions in R #27

Closed picasa closed 6 years ago

picasa commented 6 years ago

since -beta1, rvle::new or rvle::run print informations on R console

 > sunflo <- new("Rvle", file="sunflo_web.vpz", pkg="sunflo")
Context: Context initialized [prefix=/usr] [home=/home/casadebaig/.vle]
rvle_experiment_get_seed is unavailable.
> run(sunflo)
rvle_experiment_set_seed is unavailable.Context: Context initialized [prefix=/usr] [home=/home/casadebaig/.vle]
runSubProcess: Context: Context initialized [prefix=/usr] [home=/home/casadebaig/.vle]
runSubProcess: Context: Context initialized [prefix=/usr] [home=/home/casadebaig/.vle]

However, some output are catchable (the string rvle_experiment_get_seed is unavailable.)

> suppressMessages(sunflo <- new("Rvle", file="sunflo_web.vpz", pkg="sunflo"))
Context: Context initialized [prefix=/usr] [home=/home/casadebaig/.vle]
rvle_experiment_get_seed is unavailable.
> a <- capture.output(sunflo <- new("Rvle", file="sunflo_web.vpz", pkg="sunflo"))
Context: Context initialized [prefix=/usr] [home=/home/casadebaig/.vle]
quesnel commented 6 years ago

Ok. I confirm.

I will replace the printf() family function with the Rprintf() family.

Badly, with the current rvle state, we cannot provide a function to change the verbosity level.

picasa commented 6 years ago

just to provide a small test for silencing functions :

silence <- function(expr) {
  capture.output(x <- suppressMessages(suppressWarnings(expr)))
  invisible(x)
}

noise <- function(n) {
  cat("CAT"); message("MESSAGE"); print("PRINT"); warning("WARNING")
  rnorm(n)
}

> noise(1)
CATMESSAGE
[1] "PRINT"
[1] 0.5368348
Warning message:
In noise(1) : WARNING

> silence(noise(1))

> x <- silence(noise(1))

> x
[1] 0.5615403

> silence(run(sunflo))
rvle_experiment_set_seed is unavailable.Context initialized [prefix=/usr/local] [home=/home/casadebaig/.vle]

very noisy run :)

quesnel commented 6 years ago

very noisy run :)

:)

Do you use latest version for both vle and rvle ?

picasa commented 6 years ago

vle version is beta2, rvle version is 24ed3d3. This is not a blocking problem, but as I tested this function on another context, I gave it a try for rvle::run and could not explain the behavior.

quesnel commented 6 years ago

The following patchs must fix this issues (in stable vle and rvle): https://github.com/vle-forge/vle/commit/a96fa1d263f2c18bb90222287d219ef6812f9374 https://github.com/vle-forge/rvle/commit/24ed3d30e80925ef12cf9b8ac7c998f6a3b10dca