MLopez-Ibanez / irace

Iterated Racing for Automatic Algorithm Configuration
https://mlopez-ibanez.github.io/irace/
GNU General Public License v2.0
58 stars 14 forks source link

add ability to use stdout #53

Closed DE0CH closed 10 months ago

DE0CH commented 1 year ago

I decided to just modify runcommand to print to stdout and read from stdin instead of doing anything more complicated. It will just print what it would normally run in the shell to stdout with stdout://targetRunner and stdout://targetEvaluator as the first argument to differentiate the two. This has the advantage of benefiting from all the documentation and error checking of the codebase. I don't really have a good way to implement parallelism so I just ask the user to use targetEvaluator if they want to know all the runs of a batch and run them in parallel.

part of #34

MLopez-Ibanez commented 1 year ago
DE0CH commented 1 year ago

Could you add a test showing how this will work in practice? Will there be some kind of server reading the output of irace and launching commands?

I don't really know how the testing framework works. Could you please tell me where to put the test and what command I need to use to run the test?

Parallel evaluation seems impossible with this approach: There is nothing that ensures the order of the stuff read from stdin, no?

Yeah. There's no easy way to do this. stdin is sequential and the only way to do this is to have the line to contain an ID which irace and then match it with the corresponding run. But I don't really know how to do that in r.

I'm not sure how targetEvaluator can ever work under this approach, because output <- readLines(file("stdin"), n=1) implies that runcommand must receive something from targetRunner.

The idea is you have some dispatcher reading stdout and if the line starts with stdout://targetRunner or stdout://targetEvaluator, you send it to targetRunner or targetEvaluator, otherwise you treat it as a log and print it somewhere else.

MLopez-Ibanez commented 1 year ago

Could you add a test showing how this will work in practice? Will there be some kind of server reading the output of irace and launching commands?

I don't really know how the testing framework works. Could you please tell me where to put the test and what command I need to use to run the test?

https://testthat.r-lib.org/

You can also see in Makefile how I run the tests and in https://github.com/MLopez-Ibanez/irace/blob/master/.github/workflows/R-CMD-check.yaml for another way to run them.