IBM / nl2flow

NL2Flow: A PDDL Interface to Flow Construction
Apache License 2.0
8 stars 2 forks source link

Kstar unable to parse plans with \"s #119

Closed TathagataChakraborti closed 5 days ago

TathagataChakraborti commented 1 week ago

When object names have "s in them, the planner works fine but Kstar errors out.

Screenshot 2024-09-09 at 4 21 03 PM



download pddl

Of course, one can say such strings are not allowed, but I feel that if the planner handles it then the package should be able to forward that information correctly.

ctpelok77 commented 1 week ago

Not sure I understand, do you want me to write to json "map \"new_york\" query" instead?

ctpelok77 commented 1 week ago

I am guessing I would need something like

#include <regex>
...
std::string name = operators[plan[0]].get_name()
name = std::regex_replace(name, std::regex("\\""), "\\\\"");
...

added here: https://github.com/IBM/kstar/blob/main/src/search/plan_manager.cc#L113C24-L113C53

TathagataChakraborti commented 1 week ago

do you want me to write to json "map \"new_york\" query" instead

No I think the problem is inside the package reading from the output of fast downward. Coz I am getting back an empty list of plans with the decoding error for the step map "new york" query

Try with the attached PDDL.

ctpelok77 commented 1 week ago

Okay, let me rephrase. A valid json would have an escape character before ". So, the json generated by K* is not a valid json. That's why it fails on reading.

TathagataChakraborti commented 1 week ago

I don't think thats the problem. "It" here is K itself! The packages asks for the files directly as input so by then the escaping into text has already happened. The strings with "s then get passed all the way through to the planner as is. So the problem is at reading the sas plan output files when it is trying to generate the output JSON to return back (its not a case of an invalid JSON generated by K coz it does not return the doc string it returns the JSON object).

ctpelok77 commented 1 week ago

There is no actual reading of sas plan files, the code I referred to above is dumping the plans into JSON. The action names are strings, they have the " inside, but without escape characters, and when written the way they are, the JSON does not have the escape characters as well, which makes the JSON invalid. I did the dump to JSON myself instead of using a JSON library, maybe such libraries do know how to handle the string with " correctly. Or I can just do the ad-hoc fix.

TathagataChakraborti commented 1 week ago

I see, up to you how / if you want to handle it. I am transforming the names before sending anyway but in general you might want to cover it for other users.

ctpelok77 commented 1 week ago

If this is not an issue for nl2flow, then maybe the issue should be opened on the K* git? I have never experienced or asked about it until now, so I assume this is not urgent.

TathagataChakraborti commented 5 days ago

Ok closing this and logging it in kstar for posterity.