Skip to content

Commit

Permalink
GH-#1: Add some examples on README.
Browse files Browse the repository at this point in the history
  • Loading branch information
ankostis committed Mar 29, 2015
1 parent eb3b28f commit 7d6b87f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
6 changes: 3 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Changes

Known deficiencies
==================
- cannot filter-include target-deps.

TODOs
=====
- move matpotlib draw-data in external files.
- Pass kw-options from cmd-line to `store_XXX()` methods.
- Pass kw-options from cmd-line to `nx.store_XXX()` methods.
- Add graphviz graphs.
- Add more tests, setup Travis, add Docs contents.

Changelog
=========
Expand Down
30 changes: 25 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
doit-graphx
===========

Command plugin to generate graphical or textual graphs of [doit](http://pydoit.org)
task-dependencies using [NetworkX](http://networkx.github.io).
Command plugin to generate graphical or textual graphs of `doit <http://pydoit.org>`_
task-dependencies using `NetworkX <http://networkx.github.io>`_.

.. figure:: docs/doit_graph.png
:align: center
Expand All @@ -12,15 +12,26 @@ task-dependencies using [NetworkX](http://networkx.github.io).

Install
-------
Requires *doit* version >= 0.28, `networkx` and `matplotlib`::
Requires *doit* version >= 0.28, `networkx` and `matplotlib`.
You can install it from directly from github::

pip install git+https://github.com/pydoit/doit-graphx.git


Since currently (March-2015) *doit-0.28* is not yet released,
you have to install the latest version also from github::

pip install git+https://github.com/pydoit/doit.git

Use the `-I` option if you have already *doit* installed.
pip install git+https://github.com/pydoit/doit-graphx.git



Usage
-----
To activate this plugin add a file named :file:`doit.cfg` into root of
your project with the following content::
To activate this *doit* plugin add a file named :file:`doit.cfg` into
the root of your project with the following content::

[command]
cmd_graphx:Graphx
Expand All @@ -29,3 +40,12 @@ your project with the following content::
Now you can just use the `graphx` command::

doit graphx
doit graph ## By default, plots a matplotlib frame
doit graph --deps file,calc,target --private
doit graph --out-file some.png
doit graph --graph-type json --out-file some.png

Multiple output-formats are supported by the `--graph-type <format>` option.
Type ``doit help graphx`` to see them.
By default, results are written to standard output.

10 changes: 6 additions & 4 deletions cmd_graphx.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def find_edge_attr(g, attr, value):

def _store_json(graph, fname, disp_params, **kws):
import json
# TODO: obey disp_params
# TODO: Obey disp_params on json
m = nx.to_dict_of_dicts(graph)
json.dump(m, fname, **kws)

Expand Down Expand Up @@ -220,13 +220,15 @@ class Graphx(DoitCmdBase):
doc_usage = "[TASK ...]"
doc_description = dedent("""\
Without any options, includes all known taks.
TODO: Task-selection works also with wildcards.
TODO: Task-selection works with wildcards.
Examples:
doit graph
doit graph ## By default, plots a matplotlib frame
doit graph --deps file,calc,target --private
doit graph --out-file some.png
doit graph --graph-type json --out-file some.png
See https://github.com/pydoit/doit-graphx
""")

cmd_options = (opt_subtasks, opt_private, opt_no_children, opt_deps,
Expand Down Expand Up @@ -396,5 +398,5 @@ def _execute(self,
out_file = self._prepare_out_file(out_file, graph_type)
disp_params = dict(zip(['graph_type', 'show_status', 'deps', 'template'],
[graph_type, show_status, deps, template]))
kws = {} # TODO: kws not used yet.
kws = {} # TODO: kws not used on write_XXX() methods.
func(graph, out_file, disp_params, **kws)
5 changes: 3 additions & 2 deletions test_cmd_graphx.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ def test_store_json_stdout(self):
self.assertIn("t3", got)
self.assertIn("join_files", got)

def test_target(self):
def test_target_in(self):
output = StringIO()
cmd = CmdFactory(Graphx, outstream=output, task_list=self._tasks())
cmd._execute(graph_type='json')
got = output.getvalue()
self.assertIn("fout.hdf5", got)

def test_target_out(self):
output = StringIO()
cmd = CmdFactory(Graphx, outstream=output, task_list=self._tasks())
cmd._execute(graph_type='json', deps='file')
cmd._execute(graph_type='json', deps='task')
got = output.getvalue()
self.assertNotIn("fout.hdf5", got)

Expand Down

0 comments on commit 7d6b87f

Please sign in to comment.