lab icon indicating copy to clipboard operation
lab copied to clipboard

Allow calling parser without reading/writing files

Open FlorianPommerening opened this issue 4 years ago • 3 comments

This is something that came up yesterday when working on the PDDL minimizer. We would like to import the parser class from lab and use it to parse the output of a run of Fast Downward but we would like to avoid writing files. Currently, we write the log to the disk, call the parser, read the properties from the disk and then delete log and properties. In this patch, loading the logs and writing the properties is decoupled from parsing. This is a bit tricky because of the _FileParser class but I think I found a way. If you are not too attached to the _FileParser class, there may be an easier way that modifies it a bit: instead of storing the content in it, we only store the filename and pass the file_contents dictionary to the function that actually does the parsing.

FlorianPommerening avatar Mar 04 '21 14:03 FlorianPommerening

I think that being able to parse in-memory text is a pretty specialized requirement and I'm hesitant to add this to the Lab API. Couldn't you simply copy the Parser class to your project and adapt it to your needs there?

jendrikseipp avatar Mar 08 '21 15:03 jendrikseipp

We could do that but using lab as a third-party library would be more useful because people could take the parsers they wrote for their experiment and use them in the minimizer without re-implementing them. in general, I think the view of lab "as a library" instead of "as a framework" fits better with functions that do things in memory rather than code that expects a specific file layout.

I also think the change in this patch is good in general because it takes a function that does many things and replaces it by several functions that each do a single thing.

FlorianPommerening avatar Mar 08 '21 17:03 FlorianPommerening

Sorry that this is lingering for so long already, but it will have to linger a while longer.

jendrikseipp avatar Mar 24 '21 12:03 jendrikseipp