Issue1080

Title Call program on plan found
Priority wish Status resolved
Superseder Nosy List gabi, jendrik, malte, remo, silvan
Assigned To Keywords
Optional summary

Created on 2023-02-09.11:55:26 by remo, last changed by remo.

Messages
msg11275 (view) Author: remo Date: 2023-08-08.12:35:33
No worries at all, it was good fun to learn about processes. :)
Sorry for never following up on it!
msg11268 (view) Author: malte Date: 2023-08-07.18:33:27
No, in this case I suggest to close as this was only meant as a kind of hack. I think a better way to support this will be the library interface we're working on. Remo, apologies for the wasted time!
msg11267 (view) Author: gabi Date: 2023-08-07.14:50:45
Actually, I don't need this anymore for AIPlan4EU (we are now just parsing the 
stdout). Should we still pursue this further?
msg11212 (view) Author: remo Date: 2023-07-27.13:38:38
I haven't done anything for this issue since my last message (msg11014), so the 
conclusions there are still up to date.
msg11211 (view) Author: malte Date: 2023-07-27.12:13:53
I meant "waiting for a review", sorry.
msg11210 (view) Author: malte Date: 2023-07-27.12:13:37
Is this stuck? It seems this is waiting for a pull request?
Gabi, I think you needed this feature -- can you have a look if it does what you need it to do?
msg11014 (view) Author: remo Date: 2023-02-14.11:01:03
During the sprint last week, some discussions on how to implement this feature 
were held. The main complication of this issue lies in how to execute the 
system call so that it works on all supported platforms. One way to achieve 
this would be to forward this responsibility to an external library, for 
example Boost. The discussion on Discord ended with the conclusion that a less 
robust but more lightweight solution is sufficient, especially because this fix 
should only exist until the Python library is functional and should then be 
removed.

Malte and I discussed what the implementation could look like in more detail. 
The idea is to first check the value of the environment variable 
DOWNWARD_PLAN_CALLBACK. If the variable is *not* set, we do nothing. Otherwise, 
we call the executable the variable points to and provide the name of the newly 
generated plan as an argument. For Windows, we use the system() to execute the 
callback, and for Linux/MacOS we use the appropriate versions of the 
fork/exec/wait functions. In particular we want to use execvp(), which takes 
the arguments as an array instead of as a variadic argument. Additionally we 
want that both platforms behave the same way with regards to whether they scan 
the PATH to look for the executable, execvp() and system() both do so.

I tried to put this plan into practice in the following pull request:
https://github.com/aibasel/downward/pull/153

In the current implementation, DOWNWARD_PLAN_CALLBACK has to contain a relative 
or absolute path to an executable. This means that setting the variable to 
something like "python my_script.py" does not work. To achieve this, we can 
instead just set it to "./my_script.py" on Unix (because the shebang is 
interpreted), or write a batch script that calls the python program on Windows.

Regarding PATH, while it is searched on both platforms, on Windows the content 
of DOWNWARD_PLAN_CALLBACK is double-quoted to allow whitespace in the path. 
This prevents PATH commands from being recognized (the unquoted command type is 
recognized by the command interpreter, but "type" is not).

I tested the functionality manually for Linux and Windows, but I did not verify 
that things work the same way for Mac. I am not sure how thorough we want/need 
to be given that this is only a temporary solution. Automated tests through 
GitHub actions were also on the table, but I have not done anything in this 
direction.

As a next step I would suggest that somebody takes a look at the pull request, 
and to decide whether more thorough testing is needed. Another question would 
be if we need to verify that the no-hook operation of the planner is not 
affected by this change. The last task would be to write the merge commit 
message, I will write a suggestion when the code is reviewed and ready to be 
merged.
msg10989 (view) Author: remo Date: 2023-02-09.11:57:11
This feature is needed for the AIPlan4EU project and should in particular enable 
sending a notification whenever a plan is found in anytime configurations.

The solution developed in this issue is intended to be temporary and should be 
removed once the same functionality is provided by the Python interface to Fast 
Downward that is currently under development.
History
Date User Action Args
2023-08-08 12:35:33remosetmessages: + msg11275
2023-08-07 18:33:27maltesetstatus: in-progress -> resolved
messages: + msg11268
2023-08-07 14:50:45gabisetmessages: + msg11267
2023-07-27 13:38:38remosetmessages: + msg11212
2023-07-27 12:13:53maltesetmessages: + msg11211
2023-07-27 12:13:37maltesetmessages: + msg11210
2023-02-14 11:01:03remosetmessages: + msg11014
2023-02-09 16:28:00silvansetnosy: + silvan
2023-02-09 11:57:11remosetmessages: + msg10989
summary: This feature is needed for the AIPlan4EU project and should in particular enable sending a notification whenever a plan is found in anytime configurations. The solution developed in this issue is intended to be temporary and should be removed once the same functionality is provided by the Python interface to Fast Downward that is currently under development. ->
2023-02-09 11:55:26remocreate