Issue1033

Title Update automatic domain finding rules
Priority feature Status resolved
Superseder Nosy List jendrik, malte, patfer, silvan
Assigned To silvan Keywords
Optional summary

Created on 2021-08-03.18:35:33 by silvan, last changed by silvan.

Messages
msg10415 (view) Author: silvan Date: 2021-08-18.18:41:40
Done.
msg10414 (view) Author: malte Date: 2021-08-18.16:47:55
Looks good to merge. As always, we also want a change log entry.
msg10413 (view) Author: silvan Date: 2021-08-18.16:47:06
I changed the pull request.
msg10412 (view) Author: malte Date: 2021-08-18.16:09:14
I'd prefer to have the different cases consistent, i.e., don't replace the extension with ".pddl" in one case but preserve it in others. I'll add a concrete suggestion to the pull request.
msg10411 (view) Author: silvan Date: 2021-08-18.15:32:22
I implemented the suggestion: https://github.com/aibasel/downward/pull/63

Note, however, that the code also assumes that if "domain" is not a prefix but a suffix, then it also ends on .pddl (to be more precise, the suffix has to be "-domain.pddl"). This is totally fine for me, I just wanted to bring this up because this was the argument for not hard-coding [:-5] for task files. So I'm happy to merge if there are no objections or comments.
msg10387 (view) Author: malte Date: 2021-08-04.14:09:51
Agreed to not use [:-5] to split off an extension that may or may not be there. Some IPC domains had filenames like "pfile20" for example, without extension. (At some point, we added ".pddl" unilaterally in our repository.)

I would use os.path.splitext if we currently use os.path and pathlib if we currently use pathlib, but not start mixing in related code. Conversion of more stuff to pathlib is of course also OK.
msg10385 (view) Author: silvan Date: 2021-08-04.08:38:21
I agree that this is even cleaner. But then I would suggest to switch the modern pathlib which comes with a method for obtaining a file name without its extension.
msg10384 (view) Author: patfer Date: 2021-08-04.08:34:28
I agree, this should be changed.

Why do you prefer basename[:-5] over os.path.splitext?
Yours is obviously shorter, but it implies the knowledge that all relevant files end with ".pddl". The common Python method makes it explicit that we want to split the file extension.

    dirname, basename = os.path.split(task_filename)
    # The Python documentation uses the variables root and ext for the return values
    basename_root, _ = os.path.splitext(basename)

    domain_basenames = [
        "domain.pddl",
        basename_root + "-domain.pddl",
        "domain_" + basename,
        "domain-" + basename,
    ]
msg10381 (view) Author: jendrik Date: 2021-08-03.22:15:09
I like the suggestion.
msg10380 (view) Author: silvan Date: 2021-08-03.18:35:32
These are the current rules for finding a domain file for a given task file in the driver: 

    dirname, basename = os.path.split(task_filename)

    domain_basenames = [
        "domain.pddl",
        basename[:3] + "-domain.pddl",
        "domain_" + basename,
        "domain-" + basename,
    ]

The second rule only works for tasks of the name "xxx.pddl" and the corresponding domain files "xxx-domain.pddl". This works for names like p01 but is, in my opinion, a very arbitrary rule. I would suggest to change this line to

basename[:-5] + "-domain.pddl"

which works for all task files called <anything>.pddl and corresponding domain files <anything>-domain.pddl, which is probably still not a perfect rule, but much better in my opinion. I also checked the downward benchmarks and all files there end on ".pddl". Any objections?
History
Date User Action Args
2021-08-18 18:41:40silvansetstatus: chatting -> resolved
messages: + msg10415
2021-08-18 16:47:55maltesetmessages: + msg10414
2021-08-18 16:47:06silvansetmessages: + msg10413
2021-08-18 16:09:14maltesetmessages: + msg10412
2021-08-18 15:32:23silvansetmessages: + msg10411
2021-08-04 14:09:51maltesetmessages: + msg10387
2021-08-04 08:38:21silvansetmessages: + msg10385
2021-08-04 08:34:28patfersetnosy: + patfer
messages: + msg10384
2021-08-03 22:15:09jendriksetmessages: + msg10381
2021-08-03 18:35:33silvancreate