From 083e4e85cb369ee073d94aa1c214775c0227d84c Mon Sep 17 00:00:00 2001 From: Tim Vieira Date: Sat, 29 Jun 2013 00:21:50 -0400 Subject: [PATCH] tweaks to the README, todo list, and repl formatting. --- README.md | 76 +++++++++----------- src/Dyna/Backend/Python/interpreter.py | 97 +++++--------------------- src/Dyna/Backend/Python/repl.py | 11 +-- src/Dyna/Backend/Python/utils.py | 4 +- 4 files changed, 54 insertions(+), 134 deletions(-) diff --git a/README.md b/README.md index 2bddcce..b5014ee 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,44 @@ -An overview of the source tree ------------------------------- - -* docs/sphinx/ -- Documentation in reST format for sphinx -* examples/ -- Dyna source programs - * expected/ -- Expected output for self-tests. -* misc/ -- Pretty much what it says on the tin -* src/Dyna/ - * Analysis -- The heart of the compiler - * Mode -- A re-implementation of the Mercury mode system - * Backend -- Compilation to target languages - * Python -- A Python code generator - * Main -- Dyna compiler drivers (main and test) and definitions used throughout the pipeline - * ParserHS -- the Haskell front-end parser and selftests - * Term -- Different representations of terms and utilities - * XXX -- code that should probably go upstream or be made freestanding. - -Building --------- - -First, ensure that you have the Haskell platform 2012.2 or later installed, -either through your favorite package manager or by installing it stand-alone. -You'll want to have the following programs installed: - - * Python 2.7 or compatible - * graphviz +Dyna +---- + +Dyna is a small, high-level declarative programming language. Dyna programs +specify a collection of named data items. These item's can be queried, much like +a database. Dyna's power comes from the ability to define an item's value by +relating other items with an equation. These possibly recursive equations +specify the logical structure of a computation. Thus, Dyna provides a unified +way of specifying both data and algorithms. Dyna's algorithms are reactive---a +change to an item's value efficiently propagates throughout the dynabase so that +all equations are satisfied. + + +Quick Start +----------- + +First, ensure that you have the Haskell platform 2012.2 or later installed +either through your favorite package manager (e,g, `apt-get install +haskell-platform`) or by installing it stand-alone from the haskell homepage. + +This is enough to get you the compiler up and running. In order execute +programs, you'll need to set up the Python backend up. For that you'll need to +have the following: + + * Python 2.7+ The python modules required - $ easy_install numpy ipython pygments path.py matplotlib + $ easy_install ipython -You should probably run +Optionally, installing the following will enable certain extension - cabal update + $ easy_install pygments matplotlib numpy ipython + $ apt-get install graphviz -before proceeding, just to make sure that your package database is -up-to-date. Running +Now you're ready to build. make -will then build dependencies and the Dyna executable. Run the test harness, -just to make sure things built and are working OK: +this will build dependencies and the Dyna compiler executable. Run the test +harness, just to make sure things built and are working: make tests @@ -47,20 +46,13 @@ And read up on the documentation: make sphinxdoc -At this point, the code is still rather "in the works" so you probably want -to... +Now you're ready to run a Dyna program. We've included a few for you to play +with in the `examples/` directory. * Run the python backend interactively (leave off the "-i" for bulk operation): ./dyna -i examples/papa2.dyna -* Produce visualizations of some of the internal stages of our compiler - - ./debug examples/papa2.dyna - -* load some module in GHCi; for example: - - ghci -isrc Dyna.ParserHS.Parser Disclaimer ---------- diff --git a/src/Dyna/Backend/Python/interpreter.py b/src/Dyna/Backend/Python/interpreter.py index 7fbd358..b268de3 100644 --- a/src/Dyna/Backend/Python/interpreter.py +++ b/src/Dyna/Backend/Python/interpreter.py @@ -4,11 +4,25 @@ TODO ==== - - TODO: @nwf remove comments from rule source - - More info in crash handler. (stack trace, repl transcript, cmd-line args, version control info, and dyna source is enough) + - hooks to call a crash script + + - dyna syntax which just gets passed to the backend: + + - running repl commands, loaders, post-procesors + + - hook for python imports? or maybe an arbirary preamble/epilogue. + + :- python "from bar import foo, baz" + + - sheebang? + + + - TODO: @nwf remove comments from rule source + + - vbench: a script which tracks performace over time (= git commits). - profiler workflow @@ -27,63 +41,20 @@ TODO handlers, and indices (as Jason points out indices are just memoized queries). - - hook for python imports? or maybe an arbirary preamble/epilogue. - - :- python: from numpy import exp, sqrt, log - - Subscriptions: - - TODO: users are automatically be subscribed to errors. - - everything - functor - ignore variable - - show diffs - Maybe subscription to diff is a different beast, only available as a - procedural world. - - TODO: True and 1 are equivalent. This sometimes leads to strange behavior. - - New syntax for doing repl stuff (@nwf): load, subscribe, post-process - - - sheebang - - - loader for importing rules - - - Errors: - - - Should errors be maintained by dyna? I guess that's an (implicit?) program - transform where all items in a rule have a side conditions that they are - not in an error state. - - - crash handler - - - where do errors go? - - - @nwf suggests temporary measure for LSA students: time-stamped file - sitting in the users home directory, - e.g. ~/.dyna/crash/2013-06-19.crash.tar.gz - - Hide all *.plan.py files - multi-line input in REPL. Consider using a fancier library such as cmd2 or ipython's. -BUGS -==== - - - TODO: write all files to ~/.dyna - - - TODO: (@nwf) String quoting (see example/stringquote.py) - - - TODO: (@nwf) mode planning failures are slient - - - TODO: make sure interpreter uses the right exceptions. The codegen catches a - few things -- I think assertionerror is one them... we should probably do - whatever this is doing with a custom exception. - FASTER ====== @@ -123,10 +94,6 @@ USERS - user-defined priorities (blocked: back-chaining) - - filter / bulk loader; post-processing (e.g. serialization and plotting) - - - How should we pass arguments to pre/post-processors? - - Catch typos! Warn the user if they write a predicate that is not defined on the LHS of a rule and it's not quoted (i.e. not some new piece of structure). [mode analysis will help with this]. @@ -143,38 +110,6 @@ NOTES - `None` does not propagate, eventually it will because of the `?` prefix operator. - - Term values should only be aggregated with ``=`` or ``:=`` maybe even - ``set=``. We should disallow ``a += &b.`` - - Equals aggregation only one value allowed, mult. >0 on single value. The - following program has one FP of `c` end `e` are mutually exclusive. - - a = b for c - a = d for e - - This might not be the case during computation -- this is the same as the - error problem. - - - Numeric precision is an issue with BAggregators. - - timv: Are we sure we have this bug? - - a[0.1] += 1 - a[0.1 + eps] -= 1 - - Approaches: - - - arbitrary precision arithmetic - - - approximate deletion ("buckets"), find the nearest neighbor and delete it. - - - hybrid: maintain streaming sum parallel to the BAggregator and check - periodically for quality and null. - - - numeric approximations, stream folding (fails to get null) - - - delete/add the hyperedge explicitly - JUST FOR FUN ============ diff --git a/src/Dyna/Backend/Python/repl.py b/src/Dyna/Backend/Python/repl.py index f5dfb2e..b7ba7d5 100644 --- a/src/Dyna/Backend/Python/repl.py +++ b/src/Dyna/Backend/Python/repl.py @@ -3,17 +3,10 @@ """ TODO: unsubscribe -TODO: query should probably remove the new rule after we get the results. - TODO: subscriptions probably should only show "changes" -TODO: queries are all maintained... should probably toss out the query rule. If -users want queries to be kept up-to-date user should subscribe instead. - TODO: help should print call signature of loads and post-processors in addition to help. - -TODO: $include load rules from a file. """ import os, cmd, readline @@ -181,7 +174,7 @@ class REPL(cmd.Cmd, object): for val, bindings in results: #if not bindings: # print ' ', _repr(val) - print ' ', _repr(val), 'where', drepr(dict(bindings)) + print ' ', _repr(val), 'where', drepr(dict(bindings)) print def do_query(self, q): @@ -215,7 +208,7 @@ class REPL(cmd.Cmd, object): print 'No results.' return for term, result in sorted((subst(q, dict(result.variables)), result) for result in results): - print ' ', _repr(result.value), '←', term + print ' ', _repr(result.value), '=*', term print def default(self, line, show_changed=True): diff --git a/src/Dyna/Backend/Python/utils.py b/src/Dyna/Backend/Python/utils.py index c5b482b..4f65862 100644 --- a/src/Dyna/Backend/Python/utils.py +++ b/src/Dyna/Backend/Python/utils.py @@ -1,7 +1,7 @@ -import re, sys +import re +from IPython.frontend.terminal.embed import InteractiveShellEmbed from path import path from subprocess import Popen, PIPE -from IPython.frontend.terminal.embed import InteractiveShellEmbed from config import dynahome, dotdynadir from collections import namedtuple -- 2.50.1