Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make evaluator script executable with command line arguments PDDL/SAS files for testing #82

Closed
ClemensBuechner opened this issue Jun 29, 2022 · 3 comments · Fixed by #94
Labels
enhancement New feature or request

Comments

@ClemensBuechner
Copy link
Contributor

No description provided.

@FlorianPommerening
Copy link
Member

We discussed this and would like evaluators to take the path to pickled state as input for the normal operation of the search rather than importing a function from the evaluator script and calling it. This will make it possible for the search to detect cases where the evaluator runs out of resources and will unify the grid and local environments more. The original goal of the issue was to also allow PDDL/SAS files as input for testing. We will handle this as optional inputs in convenience functions provided by the modules.

We discussed a few options on Discord and ended up with the following design. An evaluator without convenience functions, could look like this:

#!/usr/bin/env python3

from machetli import pddl, tools, EXIT_CODE_IMPROVING, EXIT_CODE_NONIMPROVING
import sys

def load_state(argv):
    try:
        return machetli.unpickle(argv[1])
    except:
        return pddl.create_state(argv[1], argv[2])

def evaluate(state):
    with pddl.temporary_files(state) as (domain_filename, problem_filename):
        return evaluate(domain_filename, problem_filename)

def evaluate(domain_filename, problem_filename):
    command = ["./bugged-planner/plan", f"{domain_filename}", f"{problem_filename}"]
    run = tools.Run(command, time_limit=20, memory_limit=3000)
    stdout, stderr, returncode = run.start()
    return "Wrong task encoding" in stdout

if __name__ == "__main__":
    state = load_state(sys.argv)
    if evaluate(state):
        return EXIT_CODE_IMPROVING
    else:
        return EXIT_CODE_NONIMPROVING

With convenience functions, we could boil it down to this:

from machetli import pddl, tools

def evaluate(domain_filename, problem_filename):
    command = ["./bugged-planner/plan", f"{domain_filename}", f"{problem_filename}"]
    run = tools.Run(command, time_limit=20, memory_limit=3000)
    stdout, stderr, returncode = run.start()
    return "Wrong task encoding" in stdout

if __name__ == "__main__":
    pddl.run_evaluator(evaluate)

@FlorianPommerening
Copy link
Member

As discussed in #90, we want to work on #53 first. We might do this issue together with #53 if that makes things easier.

@FlorianPommerening
Copy link
Member

Pull request #94 deals with this. There are still a couple of TODOs and we have to update the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants