How to run target-runner.py?

535 views
Skip to first unread message

Levi Ribeiro

unread,
Apr 4, 2021, 6:12:35 PM4/4/21
to The irace package: Iterated Racing for Automatic Configuration
Hello,

I am trying to test a trivial case of run IRACE with target-runner as a python program in Windows 10.

I use the folowing irace example: ~R\win-library\3.6\race\examples\target-runner-python\trivial

I put in the command line: irace --target-runner target-runner.py, and I get the following error: 

Erro: == irace == target runner 'targetRunner' (--target-runner) '~R/win-library/3.6/irace/examples/target-runner-python/trivial/target-runner.py' is not executable

Many thanks,

Levi Abreu

Vicente I. Plaza

unread,
Apr 16, 2021, 4:02:44 PM4/16/21
to The irace package: Iterated Racing for Automatic Configuration
i had the same issue, what im doing (i dont know if its the best solution) is converting the "main.py"  to .exe with "auto-py-to-exe" and executing the runner with the .bat file, that worked for me

Manuel López-Ibáñez

unread,
Apr 17, 2021, 4:43:36 AM4/17/21
to The irace package: Iterated Racing for Automatic Configuration
Yes, the issue is that .py files are not executable on their own and you need python.exe to read the .py file and execute it. Linux knowns how to do this if  the first line of the file is "#!/usr/bin/python", however, Windows doesn't know how to do it. In Windows you have 2 options:
  • Create a target-runner.bat file that contains a line similar to "C:\\path\to\python\python.exe C:\\path\to\your-target-runner-py\target-runner.py %instance% %seed% %candidate_parameters% 1>%stdout% 2>%stderr% (see templates/windows/target-runner.bat)
  • Or convert target-runner.py into an .exe file (for example using auto-py-to-exe) so that you do not need a .bat file.
If there is a third option, I would be happy to know about it.

I will include this info in the FAQ that comes with the user-guide.

Cheers,

Manuel.

Levi Ribeiro

unread,
Apr 24, 2021, 9:39:45 AM4/24/21
to The irace package: Iterated Racing for Automatic Configuration
Thanks, Vicent and Manuel.

I try to do the first option (create a target-runner.bat with python execution code ) and work very well!

The second option is not suitable for me because my python code has many libraries, and the conversion to .exe takes a lot of time!

Many thanks,

Levi Abreu.

Manuel López-Ibáñez

unread,
Jun 11, 2021, 3:44:48 AM6/11/21
to The irace package: Iterated Racing for Automatic Configuration
Dear Levi,

Would you mind sharing your target-runner.bat that calls python? This will be useful to other users. Feel free to replace the name of your algorithm and the parameters with dummy ones like in the templates we provide.

Cheers,

Manuel.

Levi Ribeiro

unread,
Jun 13, 2021, 3:17:40 PM6/13/21
to The irace package: Iterated Racing for Automatic Configuration

Hello,

I attached the target-runner.bat that calls python in Windows (.bat file) and Linux version. We attached the python code (target-runner.py), instances.txt, scenario.txt, and parameters.txt files that run a trivial example, similar to the IRACE templates.

Follow the link to files: https://www.dropbox.com/sh/41dqvt63wjrr2db/AAD_gzMyYD3zFM2MIMxQdYKUa?dl=0.

Many thanks,

Levi Abreu.

Reply all
Reply to author
Forward
0 new messages