-
Notifications
You must be signed in to change notification settings - Fork 19
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
Switch to clingo pypi package #123
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
from clingo.application import Application, clingo_main | ||
|
||
""" | ||
A wrapper to emulate the default clingo app behavior | ||
""" | ||
class WrapperClingo(Application): | ||
def __init__(self, name): | ||
self.app_name = name | ||
|
||
def main(self, ctl, files): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Innocent question: do we need all this code if we're just simply using the default behavior of clingo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had the same question. Going by the documentation this seems to be the recommended way to get the default clingo app behavior https://potassco.org/clingo/python-api/current/clingo/application.html Also, I checked it. The pip package doesn't include the gringo binary, instead it has a platform specific library with a python wrapper. So, we cannot nab the path to the binary. |
||
""" | ||
The default implementation from clingo documentation | ||
Note- main(...) must be implemented | ||
""" | ||
for f in files: | ||
ctl.load(f) | ||
if not files: | ||
ctl.load("-") | ||
ctl.ground([("base", [])]) | ||
ctl.solve() | ||
|
||
""" | ||
run the clingo application in the default gringo mode | ||
""" | ||
clingo_main(WrapperClingo("gringo"), ["--mode", "gringo"]+sys.argv[1:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this attribute being used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That attribute should be
program_name
. That's a typo on my part. It is a member of theApplication
class.