DAG_runner.py
is a script that can be run with a given directed acyclic graph (DAG) formatted as a .json file. It meets the following criteria:
- Runner accepts a DAG in .json format.
- Runner prints the node values of each node it visits, beginning with the designated starting node. It continues printing in order based on direction and wait time determined by the edges connecting nodes.
- Runner processes nodes in parallel using multithreading. If a node has already been printed, it does not print out the node again.
- Create and activate a virtualenv. Then install requirements.txt
DAG_runner
accepts a .json file as a command line argument. As an example, to run it onDAG_1.json
use:
python DAG_runner.py DAG_1.json
You can also replace DAG_1.json with any path to a DAG in json format.
- [optional] To see the time elapsed between node values as they print out, uncomment out lines 28 and 36 in
DAG_runner.py
and run step 2 again. Note that uncommenting these lines out will make one of the unit tests fail since the unit test checks the console output.
- Run
pytest
. There are currently 3 unit tests: 2 fromuntils_test.py
and 1 fromDAG_runner_test.py
. - Note:
DAG_runner_test.py
is dependant onDAG_1.json
for testing, so changes made to one may also need to be reflected in the other.