diff --git a/ActionTree/__init__.py b/ActionTree/__init__.py index 630d726..291e881 100644 --- a/ActionTree/__init__.py +++ b/ActionTree/__init__.py @@ -29,9 +29,6 @@ stderr = ctypes.c_void_p.in_dll(libc, "__stderrp") -# @todo Evaluate https://pypi.python.org/pypi/PyContracts - - def execute(action, cpu_cores=None, keep_going=False, do_raise=True, hooks=None): """ Recursively execute an :class:`.Action`'s dependencies then the action. @@ -82,21 +79,17 @@ class Action(object): def __init__(self, label, dependencies=[], resources_required={}, accept_failed_dependencies=False): """ - :param label: - @todo Insist on label being a str or None. - Add a note saying how it's used in GanttChart and DependencyGraph. - whatever you want to attach to the action. - ``str(label)`` must succeed and return a string. - Can be retrieved by :attr:`label`. + :param label: A string used to represent the action in :class:`GanttChart` and + :class:`DependencyGraph`. Can be retrieved by :attr:`label`. + :type label: string or None :param list(Action) dependencies: see :meth:`~.Action.add_dependency` :param resources_required: see :meth:`~.Action.require_resource` :type resources_required: dict(Resource, int) :param bool accept_failed_dependencies: - it ``True``, then the action will execute even if some of its dependencies failed. + if ``True``, then the action will execute even after some of its dependencies failed. """ - str(label) self.__label = label self.__dependencies = list(dependencies) self.__resources_required = {CPU_CORE: 1} @@ -293,7 +286,7 @@ def __init__(self): super(DependencyCycleException, self).__init__("Dependency cycle") -class CompoundException(Exception): # Not doctested: @todo +class CompoundException(Exception): # Not doctested: @todoc """ Exception thrown by :func:`.execute` when dependencies raise exceptions. """ @@ -388,7 +381,7 @@ def pending_time(self): :rtype: datetime.datetime """ - return self.__pending_time # Not doctested: @todo + return self.__pending_time # Not doctested: @todoc @property def ready_time(self): @@ -436,7 +429,7 @@ def return_value(self): The value returned by this action (``None`` if it failed or was never started). """ - return self.__return_value # Not doctested: @todo + return self.__return_value # Not doctested: @todoc @property def failure_time(self): @@ -454,7 +447,7 @@ def exception(self): The exception raised by this action (``None`` if it succeeded or was never started). """ - return self.__exception # Not doctested: @todo + return self.__exception # Not doctested: @todoc @property def output(self): @@ -464,7 +457,7 @@ def output(self): :rtype: str or None """ - return self.__output # Not doctested: @todo + return self.__output # Not doctested: @todoc def __init__(self, root_action, actions, now): self._root_action = root_action @@ -529,7 +522,7 @@ def __init__(self, action): if action.label is None: # Not doctested: implementation detail self.__graphviz_graph.node(node, shape="point") else: - self.__graphviz_graph.node(node, str(action.label)) + self.__graphviz_graph.node(node, action.label) for dependency in action.dependencies: assert dependency in nodes # Because we are iterating a possible execution order self.__graphviz_graph.edge(node, nodes[dependency]) @@ -623,7 +616,7 @@ def draw(self, ax, ordinates, actions): # @todo Make sure the text is not outside the plot on the right if self.__label is not None: ax.annotate( - str(self.__label), + self.__label, xy=(self.__start_time, ordinate), xytext=(0, 3), textcoords="offset points", ) for d in self.__dependencies: @@ -655,7 +648,7 @@ def draw(self, ax, ordinates, actions): ) if self.__label is not None: ax.annotate( - str(self.__label), + self.__label, xy=(self.__start_time, ordinate), xytext=(0, 3), textcoords="offset points", ) for d in self.__dependencies: @@ -683,7 +676,7 @@ def draw(self, ax, ordinates, actions): ax.plot([self.__ready_time, self.__cancel_time], [ordinate, ordinate], color="grey", lw=1) if self.__label is not None: ax.annotate( - str(self.__label), + self.__label, xy=(self.__cancel_time, ordinate), xytext=(0, 3), textcoords="offset points", color="grey", ) @@ -826,7 +819,7 @@ def run(self, root_action): for w in multiprocessing.active_children(): w.join() - if self.do_raise and self.exceptions: # Not doctested: @todo + if self.do_raise and self.exceptions: # Not doctested: @todoc raise CompoundException(self.exceptions, self.report) else: return self.report diff --git a/ActionTree/tests/dependency_graph.py b/ActionTree/tests/dependency_graph.py index 1747ed3..f3a6090 100644 --- a/ActionTree/tests/dependency_graph.py +++ b/ActionTree/tests/dependency_graph.py @@ -111,20 +111,6 @@ def test_diamond(self): ] ) - def test_typed_label(self): - a = Action(("a", "curious", "label", 42)) - - self.assertEqual( - DependencyGraph(a).get_graphviz_graph().source, - textwrap.dedent( - """\ - digraph action { - \tnode [shape=box] - \t0 [label="('a', 'curious', 'label', 42)"] - }""" - ) - ) - def test_weird_string_label(self): a = Action("spaces and; semi=columns") diff --git a/ActionTree/tests/picklability.py b/ActionTree/tests/picklability.py index 24e4c7f..5f2a7b3 100644 --- a/ActionTree/tests/picklability.py +++ b/ActionTree/tests/picklability.py @@ -6,11 +6,8 @@ import pickle import unittest -import sys -import tempfile from ActionTree import * -from . import * class Unpicklable(object): @@ -21,6 +18,12 @@ def __reduce__(self): unpicklable = Unpicklable() +class UnpicklableAction(Action): + def __init__(self, *args, **kwds): + super(UnpicklableAction, self).__init__(*args, **kwds) + self.attribute = unpicklable + + class UnpicklableReturnValue(Action): def do_execute(self, dependency_statuses): return unpicklable @@ -31,10 +34,10 @@ def do_execute(self, dependency_statuses): raise Exception(unpicklable) -class PicklabilityTestCase(ActionTreeTestCase): +class PicklabilityTestCase(unittest.TestCase): def test_action(self): with self.assertRaises(pickle.PicklingError): - execute(self._action(unpicklable)) + execute(UnpicklableAction("x")) def test_return_value(self): with self.assertRaises(pickle.PicklingError): diff --git a/ActionTree/tests/possible_execution_order.py b/ActionTree/tests/possible_execution_order.py index 66aa35f..1bf40d8 100644 --- a/ActionTree/tests/possible_execution_order.py +++ b/ActionTree/tests/possible_execution_order.py @@ -10,16 +10,6 @@ class PreviewTestCase(unittest.TestCase): - def test_dependencies_and_labels_are_not_only_equal_but_same(self): - bLabel = ("b",) - a = Action("a") - b = Action(bLabel) - a.add_dependency(b) - - (otherB,) = a.dependencies - self.assertIs(otherB, b) - self.assertIs(otherB.label, bLabel) - def test_simple_preview(self): a = Action("a") self.assertEqual(a.get_possible_execution_order(), [a]) diff --git a/ActionTree/tests/timing.py b/ActionTree/tests/timing.py index 88c5906..c911f58 100644 --- a/ActionTree/tests/timing.py +++ b/ActionTree/tests/timing.py @@ -85,7 +85,7 @@ def test_leaves_have_same_ready_time(self): def test_many_dependencies_with_unlimited_cpu_cores(self): MANY = 20 a = self._action("a") - deps = [self._action(i) for i in range(MANY)] + deps = [self._action(str(i)) for i in range(MANY)] for dep in deps: a.add_dependency(dep) @@ -96,7 +96,7 @@ def test_many_dependencies_with_unlimited_cpu_cores(self): def test_many_dependencies_with_one_cpu_cores(self): MANY = 20 a = self._action("a") - deps = [self._action(i) for i in range(MANY)] + deps = [self._action(str(i)) for i in range(MANY)] for dep in deps: a.add_dependency(dep) @@ -109,7 +109,7 @@ def test_many_dependencies_with_one_cpu_cores(self): def test_many_dependencies_with_limited_cpu_cores(self): MANY = 20 a = self._action("a") - deps = [self._action(i) for i in range(MANY)] + deps = [self._action(str(i)) for i in range(MANY)] for dep in deps: a.add_dependency(dep) diff --git a/doc/user_guide/drawings.rst b/doc/user_guide/drawings.rst index b577336..01ae453 100644 --- a/doc/user_guide/drawings.rst +++ b/doc/user_guide/drawings.rst @@ -35,11 +35,11 @@ Actions are linked to their dependencies using thin doted lines. Actions that failed are in red, and actions that were canceled due to a failure in their dependencies are in grey: ->>> compile_unexisting = CallSubprocess(["g++", "-c", "unexisting.cpp", "-o", "_build/unexisting.o"]) +>>> compile_unexisting = CallSubprocess(["g++", "-c", "unexisting.cpp", "-o", "_build/unexisting.o"], label="g++ -c unexisting.cpp") >>> compile_unexisting.add_dependency(make_build_dir) >>> link.add_dependency(compile_unexisting) ->>> failed_link_report = execute(link, keep_going=True, do_raise=False) +>>> failed_link_report = execute(link, cpu_cores=1, keep_going=True, do_raise=False) >>> failed_link_report.is_success False >>> chart = GanttChart(failed_link_report) diff --git a/doc/user_guide/introduction.rst b/doc/user_guide/introduction.rst index 17932cd..421c8a1 100644 --- a/doc/user_guide/introduction.rst +++ b/doc/user_guide/introduction.rst @@ -112,13 +112,13 @@ Say you want to compile :ref:`two C++ files ` and link them: >>> make_build_dir = CreateDirectory("_build") ->>> compile_a = CallSubprocess(["g++", "-c", "a.cpp", "-o", "_build/a.o"]) +>>> compile_a = CallSubprocess(["g++", "-c", "a.cpp", "-o", "_build/a.o"], label="g++ -c a.cpp") >>> compile_a.add_dependency(make_build_dir) ->>> compile_b = CallSubprocess(["g++", "-c", "b.cpp", "-o", "_build/b.o"]) +>>> compile_b = CallSubprocess(["g++", "-c", "b.cpp", "-o", "_build/b.o"], label="g++ -c b.cpp") >>> compile_b.add_dependency(make_build_dir) ->>> link = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o"]) +>>> link = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o"], label="g++ -o test") >>> link.add_dependency(compile_a) >>> link.add_dependency(compile_b) diff --git a/doc/user_guide/resources.rst b/doc/user_guide/resources.rst index c7f4b72..6f02320 100644 --- a/doc/user_guide/resources.rst +++ b/doc/user_guide/resources.rst @@ -3,8 +3,6 @@ Resources ========= -.. @todo Add labels to stock Actions (in ActionTree.stock, AND in the doc) - .. testsetup:: import shutil @@ -29,11 +27,11 @@ You can tell *ActionTree* that your :class:`.Action` uses more cores with :meth: >>> from ActionTree import CPU_CORE ->>> compile_others = CallSubprocess(["make", "-j", "4", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"]) +>>> compile_others = CallSubprocess(["make", "-j", "4", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"], label="make -j 4") >>> compile_others.add_dependency(make_build_dir) >>> compile_others.require_resource(CPU_CORE, 4) ->>> link_with_others = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"]) +>>> link_with_others = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"], label="g++ -o test") >>> link_with_others.add_dependency(compile_a) >>> link_with_others.add_dependency(compile_b) >>> link_with_others.add_dependency(compile_others) @@ -60,22 +58,20 @@ while allowing other actions to run, just create a resource: >>> semaphore = Resource(2) >>> dependencies = [] >>> for i in range(6): -... d = Sleep(0.3) +... d = Sleep(0.3, label="limited") ... d.require_resource(semaphore) ... dependencies.append(d) >>> for i in range(5): -... d = Sleep(0.4) +... d = Sleep(0.4, label="free") ... dependencies.append(d) ->>> arbitrary_resource = NullAction() ->>> for d in dependencies: -... arbitrary_resource.add_dependency(d) +>>> with_resource = NullAction(dependencies=dependencies) ->>> GanttChart(execute(arbitrary_resource, cpu_cores=5)).write_to_png("arbitrary_resource_gantt_chart.png") +>>> GanttChart(execute(with_resource, cpu_cores=5)).write_to_png("with_resource_gantt_chart.png") -.. figure:: artifacts/arbitrary_resource_gantt_chart.png +.. figure:: artifacts/with_resource_gantt_chart.png :align: center - ``arbitrary_resource_gantt_chart.png`` + ``with_resource_gantt_chart.png`` As expected again, there was never more than two ``sleep 0.3`` actions running at the same time, but ``sleep 0.4`` actions were free to execute. diff --git a/docs/_images/arbitrary_resource_gantt_chart.png b/docs/_images/arbitrary_resource_gantt_chart.png deleted file mode 100644 index bbc95c2..0000000 Binary files a/docs/_images/arbitrary_resource_gantt_chart.png and /dev/null differ diff --git a/docs/_images/failed_link_gantt_chart.png b/docs/_images/failed_link_gantt_chart.png index 88dd391..e030927 100644 Binary files a/docs/_images/failed_link_gantt_chart.png and b/docs/_images/failed_link_gantt_chart.png differ diff --git a/docs/_images/link_dependency_graph.png b/docs/_images/link_dependency_graph.png index 8f5a58d..f4bbc66 100644 Binary files a/docs/_images/link_dependency_graph.png and b/docs/_images/link_dependency_graph.png differ diff --git a/docs/_images/link_gantt_chart.png b/docs/_images/link_gantt_chart.png index 47c46c4..fe8ff42 100644 Binary files a/docs/_images/link_gantt_chart.png and b/docs/_images/link_gantt_chart.png differ diff --git a/docs/_images/link_with_others_gantt_chart.png b/docs/_images/link_with_others_gantt_chart.png index ad5bfed..e041f96 100644 Binary files a/docs/_images/link_with_others_gantt_chart.png and b/docs/_images/link_with_others_gantt_chart.png differ diff --git a/docs/_images/with_resource_gantt_chart.png b/docs/_images/with_resource_gantt_chart.png new file mode 100644 index 0000000..73a74f1 Binary files /dev/null and b/docs/_images/with_resource_gantt_chart.png differ diff --git a/docs/_sources/user_guide/drawings.rst.txt b/docs/_sources/user_guide/drawings.rst.txt index b577336..01ae453 100644 --- a/docs/_sources/user_guide/drawings.rst.txt +++ b/docs/_sources/user_guide/drawings.rst.txt @@ -35,11 +35,11 @@ Actions are linked to their dependencies using thin doted lines. Actions that failed are in red, and actions that were canceled due to a failure in their dependencies are in grey: ->>> compile_unexisting = CallSubprocess(["g++", "-c", "unexisting.cpp", "-o", "_build/unexisting.o"]) +>>> compile_unexisting = CallSubprocess(["g++", "-c", "unexisting.cpp", "-o", "_build/unexisting.o"], label="g++ -c unexisting.cpp") >>> compile_unexisting.add_dependency(make_build_dir) >>> link.add_dependency(compile_unexisting) ->>> failed_link_report = execute(link, keep_going=True, do_raise=False) +>>> failed_link_report = execute(link, cpu_cores=1, keep_going=True, do_raise=False) >>> failed_link_report.is_success False >>> chart = GanttChart(failed_link_report) diff --git a/docs/_sources/user_guide/introduction.rst.txt b/docs/_sources/user_guide/introduction.rst.txt index 17932cd..421c8a1 100644 --- a/docs/_sources/user_guide/introduction.rst.txt +++ b/docs/_sources/user_guide/introduction.rst.txt @@ -112,13 +112,13 @@ Say you want to compile :ref:`two C++ files ` and link them: >>> make_build_dir = CreateDirectory("_build") ->>> compile_a = CallSubprocess(["g++", "-c", "a.cpp", "-o", "_build/a.o"]) +>>> compile_a = CallSubprocess(["g++", "-c", "a.cpp", "-o", "_build/a.o"], label="g++ -c a.cpp") >>> compile_a.add_dependency(make_build_dir) ->>> compile_b = CallSubprocess(["g++", "-c", "b.cpp", "-o", "_build/b.o"]) +>>> compile_b = CallSubprocess(["g++", "-c", "b.cpp", "-o", "_build/b.o"], label="g++ -c b.cpp") >>> compile_b.add_dependency(make_build_dir) ->>> link = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o"]) +>>> link = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o"], label="g++ -o test") >>> link.add_dependency(compile_a) >>> link.add_dependency(compile_b) diff --git a/docs/_sources/user_guide/resources.rst.txt b/docs/_sources/user_guide/resources.rst.txt index c7f4b72..6f02320 100644 --- a/docs/_sources/user_guide/resources.rst.txt +++ b/docs/_sources/user_guide/resources.rst.txt @@ -3,8 +3,6 @@ Resources ========= -.. @todo Add labels to stock Actions (in ActionTree.stock, AND in the doc) - .. testsetup:: import shutil @@ -29,11 +27,11 @@ You can tell *ActionTree* that your :class:`.Action` uses more cores with :meth: >>> from ActionTree import CPU_CORE ->>> compile_others = CallSubprocess(["make", "-j", "4", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"]) +>>> compile_others = CallSubprocess(["make", "-j", "4", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"], label="make -j 4") >>> compile_others.add_dependency(make_build_dir) >>> compile_others.require_resource(CPU_CORE, 4) ->>> link_with_others = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"]) +>>> link_with_others = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"], label="g++ -o test") >>> link_with_others.add_dependency(compile_a) >>> link_with_others.add_dependency(compile_b) >>> link_with_others.add_dependency(compile_others) @@ -60,22 +58,20 @@ while allowing other actions to run, just create a resource: >>> semaphore = Resource(2) >>> dependencies = [] >>> for i in range(6): -... d = Sleep(0.3) +... d = Sleep(0.3, label="limited") ... d.require_resource(semaphore) ... dependencies.append(d) >>> for i in range(5): -... d = Sleep(0.4) +... d = Sleep(0.4, label="free") ... dependencies.append(d) ->>> arbitrary_resource = NullAction() ->>> for d in dependencies: -... arbitrary_resource.add_dependency(d) +>>> with_resource = NullAction(dependencies=dependencies) ->>> GanttChart(execute(arbitrary_resource, cpu_cores=5)).write_to_png("arbitrary_resource_gantt_chart.png") +>>> GanttChart(execute(with_resource, cpu_cores=5)).write_to_png("with_resource_gantt_chart.png") -.. figure:: artifacts/arbitrary_resource_gantt_chart.png +.. figure:: artifacts/with_resource_gantt_chart.png :align: center - ``arbitrary_resource_gantt_chart.png`` + ``with_resource_gantt_chart.png`` As expected again, there was never more than two ``sleep 0.3`` actions running at the same time, but ``sleep 0.4`` actions were free to execute. diff --git a/docs/reference.html b/docs/reference.html index d708c60..4538b57 100644 --- a/docs/reference.html +++ b/docs/reference.html @@ -103,14 +103,11 @@

Reference Parameters: diff --git a/docs/searchindex.js b/docs/searchindex.js index 29030c1..2431d59 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["index","reference","user_guide","user_guide/drawings","user_guide/hooks","user_guide/introduction","user_guide/outputs","user_guide/resources","user_guide/source_files","user_guide/timing"],envversion:52,filenames:["index.rst","reference.rst","user_guide.rst","user_guide/drawings.rst","user_guide/hooks.rst","user_guide/introduction.rst","user_guide/outputs.rst","user_guide/resources.rst","user_guide/source_files.rst","user_guide/timing.rst"],objects:{"":{ActionTree:[1,0,0,"-"]},"ActionTree.Action":{accept_failed_dependencies:[1,2,1,""],add_dependency:[1,3,1,""],dependencies:[1,2,1,""],get_possible_execution_order:[1,3,1,""],label:[1,2,1,""],require_resource:[1,3,1,""],resources_required:[1,2,1,""]},"ActionTree.CompoundException":{exceptions:[1,2,1,""],execution_report:[1,2,1,""]},"ActionTree.DependencyGraph":{get_graphviz_graph:[1,3,1,""],write_to_png:[1,3,1,""]},"ActionTree.ExecutionReport":{ActionStatus:[1,1,1,""],get_action_status:[1,3,1,""],get_actions_and_statuses:[1,3,1,""],is_success:[1,2,1,""]},"ActionTree.ExecutionReport.ActionStatus":{cancel_time:[1,2,1,""],exception:[1,2,1,""],failure_time:[1,2,1,""],output:[1,2,1,""],pending_time:[1,2,1,""],ready_time:[1,2,1,""],return_value:[1,2,1,""],start_time:[1,2,1,""],status:[1,2,1,""],success_time:[1,2,1,""]},"ActionTree.GanttChart":{get_mpl_figure:[1,3,1,""],plot_on_mpl_axes:[1,3,1,""],write_to_png:[1,3,1,""]},"ActionTree.Hooks":{action_canceled:[1,3,1,""],action_failed:[1,3,1,""],action_pending:[1,3,1,""],action_printed:[1,3,1,""],action_ready:[1,3,1,""],action_started:[1,3,1,""],action_successful:[1,3,1,""]},"ActionTree.stock":{CallSubprocess:[1,1,1,""],CalledProcessError:[1,5,1,""],CopyFile:[1,1,1,""],CreateDirectory:[1,1,1,""],DeleteDirectory:[1,1,1,""],DeleteFile:[1,1,1,""],NullAction:[1,1,1,""],Sleep:[1,1,1,""],TouchFile:[1,1,1,""]},ActionTree:{Action:[1,1,1,""],CANCELED:[1,4,1,""],CPU_CORE:[1,4,1,""],CompoundException:[1,5,1,""],DependencyCycleException:[1,5,1,""],DependencyGraph:[1,1,1,""],ExecutionReport:[1,1,1,""],FAILED:[1,4,1,""],GanttChart:[1,1,1,""],Hooks:[1,1,1,""],Resource:[1,1,1,""],SUCCESSFUL:[1,4,1,""],UNLIMITED:[1,4,1,""],execute:[1,6,1,""],stock:[1,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","attribute","Python attribute"],"3":["py","method","Python method"],"4":["py","data","Python data"],"5":["py","exception","Python exception"],"6":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:attribute","3":"py:method","4":"py:data","5":"py:exception","6":"py:function"},terms:{"case":1,"catch":1,"class":[1,5,7],"default":[1,7],"float":1,"function":[0,5],"import":[0,1,3,5,7],"int":[1,8],"long":0,"new":1,"return":[0,1,2,5],"super":5,"true":[0,1,3,5],"void":8,"while":7,And:[0,5],Axes:1,For:5,The:[1,3,5,7],Then:5,Useful:1,__file:5,__init__:5,__name:5,_build:[3,5,7,8],about:5,accept_failed_depend:1,action:[0,2,3,6,7],action_cancel:1,action_fail:1,action_pend:1,action_print:1,action_readi:1,action_start:1,action_success:1,actionstatu:1,actiontre:[1,3,5,6,7],actual:3,add:1,add_depend:[0,1,3,5,7],adding:1,after:1,again:7,all:[1,3,5,7],allow:7,alreadi:1,also:1,ani:[1,6,7],anyth:1,anywai:1,append:7,arbitrari:[0,2],arbitrary_resourc:7,arbitrary_resource_gantt_chart:7,arg:1,argument:1,attach:1,attempt:6,avail:[0,1,7],axes:1,base:1,basic:5,becaus:1,becom:1,been:5,befor:[1,5],begin:1,being:1,below:7,between:0,blanklin:5,bool:1,bug:0,call:[0,1,5,7],calledprocesserror:1,callsubprocess:[0,1,3,5,7],can:[1,3,5,7],cancel:[1,3],cancel_tim:1,cannot:1,captur:6,cat:5,certain:1,chart:[0,1,2],check_cal:1,choos:1,chosen:1,code:0,command:1,common:[1,5],compil:5,compile_a:[5,7],compile_b:[5,7],compile_oth:7,compile_unexist:3,complet:1,compoundexcept:1,concat:5,concaten:5,concatfil:5,concurr:5,consid:[1,7],constructor:1,contain:1,contribut:0,control:7,copi:1,coping_depend:[],copyfil:1,core:[0,2,3],cpp:[0,3,5,8],cpu:[0,1,2,3,5],cpu_cor:[1,7],cpucoreresourc:1,creat:[0,1,5,7],createdirectori:[1,5],createfil:5,current:6,custom:1,cycl:1,data:6,datetim:1,def:5,defin:1,delet:1,deletedirectori:1,deletefil:1,depend:[0,1,2,7],dependency_status:[1,5],dependencycycleexcept:1,dependencygraph:[1,3],deriv:1,describ:1,destin:1,detail:3,devlpr:5,dict:1,dictionari:1,didn:1,digraph:1,direct:1,directori:[1,5,6],do_execut:[1,5],do_rais:[1,3],document:0,doe:1,doesn:1,done:[3,5],dote:3,draw:[0,1,2],dst:1,due:3,durat:1,each:[3,6],earlier:5,effect:[0,1,2],els:1,empti:1,end:1,ensur:1,environ:6,error:1,etc:1,even:1,everyth:[0,1],exampl:5,except:[0,1,2],execut:[0,1,3,5,6,7],execution_report:1,executionreport:[1,6],exist:1,expect:7,explain:3,extern:1,fail:[1,3],failed_link_gantt_chart:3,failed_link_report:3,failur:[1,3],failure_tim:1,fals:[1,3],figur:1,file:[1,5,7],filenam:1,filesystem:1,finish:[1,5],first:[1,5],flexibl:7,flush:1,format:5,fourth:5,free:7,from:[0,1,3,5,7],gantt:[0,1,2],ganttchart:[1,3,7],gener:5,get:1,get_action_statu:1,get_actions_and_status:1,get_graphviz_graph:1,get_mpl_figur:1,get_possible_execution_ord:[1,5],github:0,graph:[0,1,2,5],graphviz:1,grei:3,guaranti:5,guid:[0,3],handl:[1,6],has:[1,5],have:[1,5],here:7,hook:[0,1,2],horizont:3,how:[1,7],imag:1,includ:[1,5],index:0,individu:7,infinit:1,inform:[0,2],input:5,insert:1,insist:1,instal:0,instanc:[1,7],intermedi:1,introduct:[0,2],is_success:[0,1,3,5],isfil:0,issu:0,its:[0,1,5,6],just:[1,5,7],keep_go:[1,3],kei:1,kind:7,know:5,kwarg:1,kwd:1,label:[1,5],later:3,left:3,let:[1,5],librari:0,licens:0,like:[1,6],line:3,linear:1,link:[0,3,5],link_dependency_graph:3,link_gantt_chart:3,link_report:[3,5],link_with_oth:7,link_with_others_gantt_chart:7,list:1,look:5,mai:[1,5],main:[1,8],make:[1,6,7],make_build_dir:[3,5,7],makedir:1,makefil:8,manag:1,mani:[1,7],manipul:1,matplotlib:1,mechan:7,method:1,might:1,mit:0,modif:1,modifi:[1,6],modul:0,more:[0,1,2],must:1,mutex:1,name:[1,5],necessari:1,nest:1,never:[1,7],none:1,note:1,noth:1,nullact:[1,7],number:1,object:1,observ:7,one:[1,5],onli:1,open:[0,1,5],oper:5,option:3,order:[1,5],origin:1,other:[0,1,2,7],output:[0,1,2,5],own:[1,6],packag:0,page:0,parallel:[0,1,7],paramet:[1,7],part:3,pass:1,path:0,pending_tim:1,perform:1,pickl:1,picklabl:1,pip:0,place:5,placehold:1,plot:1,plot_on_mpl_ax:1,png:[1,3,7],possibl:[1,5],predefin:1,preview:[0,2],print:[0,1,2,5],process:[1,6],program:1,progress:1,protect:1,provid:1,pypi:0,python:[0,1],quantiti:[1,7],question:0,rais:1,rang:7,read:5,readi:[1,3],ready_tim:1,realli:5,reason:5,recurs:1,red:3,refer:0,remark:0,report:[0,1],repres:[1,3],represent:1,requir:1,require_resourc:[1,7],resourc:[0,1,2,3],resources_requir:1,respect:0,retriev:1,return_valu:1,right:3,rmtree:1,root:[0,5],run:[1,5,7],safe:6,sai:[1,5],said:5,same:[1,7],search:0,sec:1,second:[1,5],see:1,seen_act:1,self:[1,5],semaphor:[1,7],semaphore:1,set:1,sever:[1,5],ship:5,should:[6,7],shutil:1,side:[0,1,2],simpler:1,simplest:1,singl:[1,7],sleep:[1,7],some:[0,1,5,7],someth:1,somewher:1,sourc:[0,7],special:[1,5],specif:7,specifi:1,src:1,start:[1,5],start_tim:1,statu:1,status:1,stock:[0,2,7],stop:1,str:1,string:1,stuff:[1,5],subprocess:[1,5],succe:1,succeed:1,success:1,success_tim:1,successfulli:5,suitabl:1,sure:[1,5],system:[1,5],task:[1,5],tell:7,test:[0,5,7],text:1,than:[1,7],thei:[1,5],them:5,thi:[1,3,5],thicker:3,thin:3,third:5,those:0,three:5,thrown:1,thu:7,time:[0,1,2,3,7],todo:1,todoc:1,touch:1,touchfil:1,tupl:1,two:[5,7],type:1,typic:3,under:0,unexist:3,uniqu:1,unit:1,unlimit:1,unlink:1,use:[1,5],used:[1,7],user:[0,3],uses:7,using:[1,3,5],utim:1,valu:[0,1,2],variabl:6,verifi:0,visual:1,wait:3,want:[0,1,5,7],well:[0,1],went:0,were:[3,7],what:[1,5],whatev:1,when:1,where:1,which:[1,7],whose:1,why:5,wide:6,without:1,work:6,would:[1,5],write:[1,5],write_to_png:[1,3,7],wrote:5,you:[0,1,3,5,7],your:[1,5,7]},titles:["ActionTree","Reference","User guide","Drawings","Hooks","Introduction","Outputs and side-effects","Resources","Source files of examples","Timing information"],titleterms:{"return":6,action:[1,5],actiontre:0,arbitrari:7,chart:3,content:0,core:[1,7],cpu:7,depend:[3,5],draw:3,effect:6,exampl:8,except:6,file:8,gantt:3,graph:3,guid:2,hook:4,indic:0,inform:9,introduct:5,more:7,other:6,output:6,preview:5,print:6,quick:0,refer:1,resourc:7,side:6,sourc:8,start:0,stock:[1,5],tabl:0,time:9,user:2,valu:6}}) \ No newline at end of file +Search.setIndex({docnames:["index","reference","user_guide","user_guide/drawings","user_guide/hooks","user_guide/introduction","user_guide/outputs","user_guide/resources","user_guide/source_files","user_guide/timing"],envversion:52,filenames:["index.rst","reference.rst","user_guide.rst","user_guide/drawings.rst","user_guide/hooks.rst","user_guide/introduction.rst","user_guide/outputs.rst","user_guide/resources.rst","user_guide/source_files.rst","user_guide/timing.rst"],objects:{"":{ActionTree:[1,0,0,"-"]},"ActionTree.Action":{accept_failed_dependencies:[1,2,1,""],add_dependency:[1,3,1,""],dependencies:[1,2,1,""],get_possible_execution_order:[1,3,1,""],label:[1,2,1,""],require_resource:[1,3,1,""],resources_required:[1,2,1,""]},"ActionTree.CompoundException":{exceptions:[1,2,1,""],execution_report:[1,2,1,""]},"ActionTree.DependencyGraph":{get_graphviz_graph:[1,3,1,""],write_to_png:[1,3,1,""]},"ActionTree.ExecutionReport":{ActionStatus:[1,1,1,""],get_action_status:[1,3,1,""],get_actions_and_statuses:[1,3,1,""],is_success:[1,2,1,""]},"ActionTree.ExecutionReport.ActionStatus":{cancel_time:[1,2,1,""],exception:[1,2,1,""],failure_time:[1,2,1,""],output:[1,2,1,""],pending_time:[1,2,1,""],ready_time:[1,2,1,""],return_value:[1,2,1,""],start_time:[1,2,1,""],status:[1,2,1,""],success_time:[1,2,1,""]},"ActionTree.GanttChart":{get_mpl_figure:[1,3,1,""],plot_on_mpl_axes:[1,3,1,""],write_to_png:[1,3,1,""]},"ActionTree.Hooks":{action_canceled:[1,3,1,""],action_failed:[1,3,1,""],action_pending:[1,3,1,""],action_printed:[1,3,1,""],action_ready:[1,3,1,""],action_started:[1,3,1,""],action_successful:[1,3,1,""]},"ActionTree.stock":{CallSubprocess:[1,1,1,""],CalledProcessError:[1,5,1,""],CopyFile:[1,1,1,""],CreateDirectory:[1,1,1,""],DeleteDirectory:[1,1,1,""],DeleteFile:[1,1,1,""],NullAction:[1,1,1,""],Sleep:[1,1,1,""],TouchFile:[1,1,1,""]},ActionTree:{Action:[1,1,1,""],CANCELED:[1,4,1,""],CPU_CORE:[1,4,1,""],CompoundException:[1,5,1,""],DependencyCycleException:[1,5,1,""],DependencyGraph:[1,1,1,""],ExecutionReport:[1,1,1,""],FAILED:[1,4,1,""],GanttChart:[1,1,1,""],Hooks:[1,1,1,""],Resource:[1,1,1,""],SUCCESSFUL:[1,4,1,""],UNLIMITED:[1,4,1,""],execute:[1,6,1,""],stock:[1,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","attribute","Python attribute"],"3":["py","method","Python method"],"4":["py","data","Python data"],"5":["py","exception","Python exception"],"6":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:attribute","3":"py:method","4":"py:data","5":"py:exception","6":"py:function"},terms:{"case":1,"catch":1,"class":[1,5,7],"default":[1,7],"float":1,"function":[0,5],"import":[0,1,3,5,7],"int":[1,8],"long":0,"new":1,"return":[0,1,2,5],"super":5,"true":[0,1,3,5],"void":8,"while":7,And:[0,5],Axes:1,For:5,The:[1,3,5,7],Then:5,Useful:1,__file:5,__init__:5,__name:5,_build:[3,5,7,8],about:5,accept_failed_depend:1,action:[0,2,3,6,7],action_cancel:1,action_fail:1,action_pend:1,action_print:1,action_readi:1,action_start:1,action_success:1,actionstatu:1,actiontre:[1,3,5,6,7],actual:3,add:1,add_depend:[0,1,3,5,7],adding:1,after:1,again:7,all:[1,3,5,7],allow:7,alreadi:1,also:1,ani:[1,6,7],anyth:1,anywai:1,append:7,arbitrari:[0,2],arg:1,argument:1,attempt:6,avail:[0,1,7],axes:1,base:1,basic:5,becaus:1,becom:1,been:5,befor:[1,5],begin:1,being:1,below:7,between:0,blanklin:5,bool:1,bug:0,call:[0,1,5,7],calledprocesserror:1,callsubprocess:[0,1,3,5,7],can:[1,3,5,7],cancel:[1,3],cancel_tim:1,cannot:1,captur:6,cat:5,certain:1,chart:[0,1,2],check_cal:1,choos:1,chosen:1,code:0,command:1,common:[1,5],compil:5,compile_a:[5,7],compile_b:[5,7],compile_oth:7,compile_unexist:3,complet:1,compoundexcept:1,concat:5,concaten:5,concatfil:5,concurr:5,consid:[1,7],constructor:1,contain:1,contribut:0,control:7,copi:1,copyfil:1,core:[0,2,3],cpp:[0,3,5,8],cpu:[0,1,2,3,5],cpu_cor:[1,3,7],cpucoreresourc:1,creat:[0,1,5,7],createdirectori:[1,5],createfil:5,current:6,custom:1,cycl:1,data:6,datetim:1,def:5,defin:1,delet:1,deletedirectori:1,deletefil:1,depend:[0,1,2,7],dependency_status:[1,5],dependencycycleexcept:1,dependencygraph:[1,3],deriv:1,describ:1,destin:1,detail:3,devlpr:5,dict:1,dictionari:1,didn:1,digraph:1,direct:1,directori:[1,5,6],do_execut:[1,5],do_rais:[1,3],document:0,doe:1,doesn:1,done:[3,5],dote:3,draw:[0,1,2],dst:1,due:3,durat:1,each:[3,6],earlier:5,effect:[0,1,2],els:1,empti:1,end:1,ensur:1,environ:6,error:1,etc:1,even:1,everyth:[0,1],exampl:5,except:[0,1,2],execut:[0,1,3,5,6,7],execution_report:1,executionreport:[1,6],exist:1,expect:7,explain:3,extern:1,fail:[1,3],failed_link_gantt_chart:3,failed_link_report:3,failur:[1,3],failure_tim:1,fals:[1,3],figur:1,file:[1,5,7],filenam:1,filesystem:1,finish:[1,5],first:[1,5],flexibl:7,flush:1,format:5,fourth:5,free:7,from:[0,1,3,5,7],gantt:[0,1,2],ganttchart:[1,3,7],gener:5,get:1,get_action_statu:1,get_actions_and_status:1,get_graphviz_graph:1,get_mpl_figur:1,get_possible_execution_ord:[1,5],github:0,graph:[0,1,2,5],graphviz:1,grei:3,guaranti:5,guid:[0,3],handl:[1,6],has:[1,5],have:[1,5],here:7,hook:[0,1,2],horizont:3,how:[1,7],imag:1,includ:[1,5],index:0,individu:7,infinit:1,inform:[0,2],input:5,insert:1,instal:0,instanc:[1,7],intermedi:1,introduct:[0,2],is_success:[0,1,3,5],isfil:0,issu:0,its:[0,1,5,6],just:[1,5,7],keep_go:[1,3],kei:1,kind:7,know:5,kwarg:1,kwd:1,label:[1,3,5,7],later:3,left:3,let:[1,5],librari:0,licens:0,like:[1,6],limit:7,line:3,linear:1,link:[0,3,5],link_dependency_graph:3,link_gantt_chart:3,link_report:[3,5],link_with_oth:7,link_with_others_gantt_chart:7,list:1,look:5,mai:[1,5],main:[1,8],make:[1,6,7],make_build_dir:[3,5,7],makedir:1,makefil:8,manag:1,mani:[1,7],manipul:1,matplotlib:1,mechan:7,method:1,might:1,mit:0,modif:1,modifi:[1,6],modul:0,more:[0,1,2],must:1,mutex:1,name:[1,5],necessari:1,nest:1,never:[1,7],none:1,note:1,noth:1,nullact:[1,7],number:1,object:1,observ:7,one:[1,5],onli:1,open:[0,1,5],oper:5,option:3,order:[1,5],origin:1,other:[0,1,2,7],output:[0,1,2,5],own:[1,6],packag:0,page:0,parallel:[0,1,7],paramet:[1,7],part:3,pass:1,path:0,pending_tim:1,perform:1,pickl:1,picklabl:1,pip:0,place:5,placehold:1,plot:1,plot_on_mpl_ax:1,png:[1,3,7],possibl:[1,5],predefin:1,preview:[0,2],print:[0,1,2,5],process:[1,6],program:1,progress:1,protect:1,provid:1,pypi:0,python:[0,1],quantiti:[1,7],question:0,rais:1,rang:7,read:5,readi:[1,3],ready_tim:1,realli:5,reason:5,recurs:1,red:3,refer:0,remark:0,report:[0,1],repres:[1,3],represent:1,requir:1,require_resourc:[1,7],resourc:[0,1,2,3],resources_requir:1,respect:0,retriev:1,return_valu:1,right:3,rmtree:1,root:[0,5],run:[1,5,7],safe:6,sai:5,said:5,same:[1,7],search:0,sec:1,second:[1,5],see:1,seen_act:1,self:[1,5],semaphor:[1,7],semaphore:1,set:1,sever:[1,5],ship:5,should:[6,7],shutil:1,side:[0,1,2],simpler:1,simplest:1,singl:[1,7],sleep:[1,7],some:[0,1,5,7],someth:1,somewher:1,sourc:[0,7],special:[1,5],specif:7,specifi:1,src:1,start:[1,5],start_tim:1,statu:1,status:1,stock:[0,2,7],stop:1,str:1,string:1,stuff:[1,5],subprocess:[1,5],succeed:1,success:1,success_tim:1,successfulli:5,suitabl:1,sure:[1,5],system:[1,5],task:[1,5],tell:7,test:[0,5,7],text:1,than:[1,7],thei:[1,5],them:5,thi:[1,3,5],thicker:3,thin:3,third:5,those:0,three:5,thrown:1,thu:7,time:[0,1,2,3,7],todoc:1,touch:1,touchfil:1,tupl:1,two:[5,7],type:1,typic:3,under:0,unexist:3,uniqu:1,unit:1,unlimit:1,unlink:1,use:[1,5],used:[1,7],user:[0,3],uses:7,using:[1,3,5],utim:1,valu:[0,1,2],variabl:6,verifi:0,visual:1,wait:3,want:[0,1,5,7],well:[0,1],went:0,were:[3,7],what:[1,5],when:1,where:1,which:[1,7],whose:1,why:5,wide:6,with_resourc:7,with_resource_gantt_chart:7,without:1,work:6,would:[1,5],write:[1,5],write_to_png:[1,3,7],wrote:5,you:[0,1,3,5,7],your:[1,5,7]},titles:["ActionTree","Reference","User guide","Drawings","Hooks","Introduction","Outputs and side-effects","Resources","Source files of examples","Timing information"],titleterms:{"return":6,action:[1,5],actiontre:0,arbitrari:7,chart:3,content:0,core:[1,7],cpu:7,depend:[3,5],draw:3,effect:6,exampl:8,except:6,file:8,gantt:3,graph:3,guid:2,hook:4,indic:0,inform:9,introduct:5,more:7,other:6,output:6,preview:5,print:6,quick:0,refer:1,resourc:7,side:6,sourc:8,start:0,stock:[1,5],tabl:0,time:9,user:2,valu:6}}) \ No newline at end of file diff --git a/docs/user_guide/drawings.html b/docs/user_guide/drawings.html index acab23c..37a303e 100644 --- a/docs/user_guide/drawings.html +++ b/docs/user_guide/drawings.html @@ -66,12 +66,12 @@

Gantt chartResources and timing are explained in detail later in this user guide.

Actions are linked to their dependencies using thin doted lines.

Actions that failed are in red, and actions that were canceled due to a failure in their dependencies are in grey:

-
>>> compile_unexisting = CallSubprocess(["g++", "-c", "unexisting.cpp", "-o", "_build/unexisting.o"])
+
>>> compile_unexisting = CallSubprocess(["g++", "-c", "unexisting.cpp", "-o", "_build/unexisting.o"], label="g++ -c unexisting.cpp")
 >>> compile_unexisting.add_dependency(make_build_dir)
 >>> link.add_dependency(compile_unexisting)
 
-
>>> failed_link_report = execute(link, keep_going=True, do_raise=False)
+
>>> failed_link_report = execute(link, cpu_cores=1, keep_going=True, do_raise=False)
 >>> failed_link_report.is_success
 False
 >>> chart = GanttChart(failed_link_report)
diff --git a/docs/user_guide/introduction.html b/docs/user_guide/introduction.html
index f7f6c3e..3498a99 100644
--- a/docs/user_guide/introduction.html
+++ b/docs/user_guide/introduction.html
@@ -139,15 +139,15 @@ 

Stock actions
>>> make_build_dir = CreateDirectory("_build")
 

-
>>> compile_a = CallSubprocess(["g++", "-c", "a.cpp", "-o", "_build/a.o"])
+
>>> compile_a = CallSubprocess(["g++", "-c", "a.cpp", "-o", "_build/a.o"], label="g++ -c a.cpp")
 >>> compile_a.add_dependency(make_build_dir)
 
-
>>> compile_b = CallSubprocess(["g++", "-c", "b.cpp", "-o", "_build/b.o"])
+
>>> compile_b = CallSubprocess(["g++", "-c", "b.cpp", "-o", "_build/b.o"], label="g++ -c b.cpp")
 >>> compile_b.add_dependency(make_build_dir)
 
-
>>> link = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o"])
+
>>> link = CallSubprocess(["g++", "-o", "_build/test", "_build/a.o", "_build/b.o"], label="g++ -o test")
 >>> link.add_dependency(compile_a)
 >>> link.add_dependency(compile_b)
 
diff --git a/docs/user_guide/resources.html b/docs/user_guide/resources.html index 1a97469..b83318e 100644 --- a/docs/user_guide/resources.html +++ b/docs/user_guide/resources.html @@ -54,12 +54,12 @@

More CPU cores
>>> from ActionTree import CPU_CORE
 

-
>>> compile_others = CallSubprocess(["make", "-j", "4", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"])
+
>>> compile_others = CallSubprocess(["make", "-j", "4", "_build/c.o", "_build/d.o", "_build/e.o", "_build/f.o", "_build/g.o", "_build/h.o"], label="make -j 4")
 >>> compile_others.add_dependency(make_build_dir)
 >>> compile_others.require_resource(CPU_CORE, 4)
 
-