Skip to content

Commit

Permalink
Don’t ship binaries anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Nov 1, 2017
1 parent 57ccef7 commit 99224e9
Show file tree
Hide file tree
Showing 23 changed files with 117 additions and 325 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ __tmp__
.mypy_cache
*.egg-info
.eggs
.coverage
11 changes: 11 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,11 @@
exclude .gitignore
exclude .coverage
exclude .travis.yml
include README.md
include setup.cfg
prune .cache
prune .git
prune build
prune dist
recursive-exclude *.egg-info *
recursive-include tests *
14 changes: 11 additions & 3 deletions README.md
Expand Up @@ -4,14 +4,22 @@ Related repos:
* https://github.com/domoritz/vis-csp
* https://github.com/domoritz/vis-constraints

## Dev setup
## Developer setup

## First, install clingo.

On Linux, run `apt get install gringo`. On MacOS, you can run `brew install gringo`.

## Python setup

`pip install -r requirements.txt`

Install draco in editable mode

`pip install -e .`

Now you should be able to run the tests
Now you can call the command line tool `draco`. For example `draco --version` or `draco --help`.

You should also be able to run the tests (and coverage report)

`python setup.py test` or `pytest`
`python setup.py test`
Binary file removed bin/clingcon-linux
Binary file not shown.
Binary file removed bin/clingcon-mac
Binary file not shown.
Binary file removed bin/clingcon.exe
Binary file not shown.
Binary file removed bin/clingo-linux
Binary file not shown.
Binary file removed bin/clingo-mac
Binary file not shown.
Binary file removed bin/clingo-python-mac
Binary file not shown.
Binary file removed bin/clingo.exe
Binary file not shown.
1 change: 1 addition & 0 deletions draco/__init__.py
@@ -0,0 +1 @@
__version__ = '0.1.0'
41 changes: 41 additions & 0 deletions draco/cli.py
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

import sys
import argparse
import logging

from draco.run import run
from draco import __version__

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def main():
parser = argparse.ArgumentParser(description="Draco Visualization recommendation system.",
epilog="There is a moment in every dawn when light floats, there is the possibility of magic. Creation holds its breath.")

parser.add_argument("query", nargs="?", type=argparse.FileType("r"), default=sys.stdin,
help="The CompassQL query (partial Vega-Lite spec).")
parser.add_argument("--out", nargs="?", type=argparse.FileType("w"), default=sys.stdout,
help="specify the Vega-Lite output file")
parser.add_argument('--version', action='version',
version=__version__)
args = parser.parse_args()

logger.info(f"Processing query: {args.query.name} ...")

run(args.query, args.out)

# close open files
if args.query is not sys.stdin:
args.query.close()

if args.out is not sys.stdout:
args.out.close()

logger.info(f"Complete task.")


if __name__ == '__main__':
main()
34 changes: 2 additions & 32 deletions main.py → draco/run.py 100755 → 100644
@@ -1,9 +1,5 @@
#!/usr/bin/env python3

import os
import sys
import json
import argparse
import subprocess
import logging
from pprint import pprint
Expand All @@ -14,9 +10,6 @@
logger = logging.getLogger(__name__)

CONFIG = {
# the clingcon bin file
"clingo": os.path.join("bin", "clingo-python-mac"),
# vegalite file
"vega_lite_lp": os.path.join("asp", "vega-lite.lp"),
# the directory storing temporary files
# (e.g., lp files compiled from partial spec)
Expand All @@ -28,7 +21,7 @@
os.makedirs(CONFIG["tmp_dir"])


def main(partial_vl_spec, out):
def run(partial_vl_spec, out):
""" Given a partial vegalite spec, recommand a completion of the spec
"""
tmp_asp_file = os.path.join(CONFIG["tmp_dir"], os.path.basename(partial_vl_spec.name).split(".")[0] + ".lp")
Expand All @@ -40,7 +33,7 @@ def main(partial_vl_spec, out):
logger.info(f"Temp asp specification written into: {tmp_asp_file}.")
f.write(task.to_asp())

r = subprocess.run([CONFIG["clingo"], CONFIG["vega_lite_lp"], tmp_asp_file, "--outf=2"],
r = subprocess.run([clingo, CONFIG["vega_lite_lp"], tmp_asp_file, "--outf=2"],
stdout=subprocess.PIPE, stderr=None)

json_result = json.loads(r.stdout.decode("utf-8"))
Expand All @@ -59,26 +52,3 @@ def main(partial_vl_spec, out):

print(new_task.to_vl_json(), file=out)
logger.info(f"Wrote Vega-Lite spec to {out.name}.")

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Visualization recommendation system.",
epilog="There is a moment in every dawn when light floats, there is the possibility of magic. Creation holds its breath.")

parser.add_argument("query", nargs="?", type=argparse.FileType("r"), default=sys.stdin,
help="The CompassQL query (partial Vega-Lite spec).")
parser.add_argument("--out", nargs="?", type=argparse.FileType("w"), default=sys.stdout,
help="Where to output the Vega-Lite spec.")
args = parser.parse_args()

logger.info(f"Processing partial vis spec: {args.query.name} ...")

main(args.query, args.out)

# close open files
if args.query is not sys.stdin:
args.query.close()

if args.out is not sys.stdout:
args.out.close()

logger.info(f"Complete task.")
2 changes: 0 additions & 2 deletions draco/spec.py
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

import csv
import agate
import json
Expand Down
33 changes: 0 additions & 33 deletions legacy/asp-py.lp

This file was deleted.

10 changes: 0 additions & 10 deletions legacy/range-py.lp

This file was deleted.

6 changes: 0 additions & 6 deletions legacy/sets.lp

This file was deleted.

5 changes: 0 additions & 5 deletions legacy/sets2.lp

This file was deleted.

10 changes: 0 additions & 10 deletions legacy/unique.lp

This file was deleted.

0 comments on commit 99224e9

Please sign in to comment.