Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ jobs:
uses: arduino/setup-protoc@v1
- name: Generate program_graph_pb2.py
run: "protoc program_graph.proto --python_out=."
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=80 --statistics
- name: Test with pytest
run: |
pytest
5 changes: 5 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from algorithm import NullAlgorithm
from algorithm import AlgorithmV1
from algorithm import AlgorithmV2
from statistics import evaluate
import program_graph_pb2
File renamed without changes.
4 changes: 2 additions & 2 deletions splitbrain_benchmark.py → algorithm_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import networkx as nx
import google_benchmark as benchmark
import splitbrain
from splitbrain import SplitbrainV2


@benchmark.register
Expand All @@ -13,7 +13,7 @@ def benchmark_fib(state):
G.add_edge("do_fib", "fib")
G.remove_edges_from(nx.selfloop_edges(G))

algorithm = splitbrain.SplitbrainV2()
algorithm = SplitbrainV2()

while state:
algorithm.run(G)
Expand Down
9 changes: 5 additions & 4 deletions splitbrain_test.py → algorithm_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from re import X
from absl.testing import absltest
import splitbrain
import statistics
from splitbrain import SplitbrainV2
from splitbrain import SplitbrainV1
from splitbrain import statistics
import graphdef_utils
import program_graph_pb2

Expand All @@ -18,7 +19,7 @@ def test_fib(self):
graphdef = graphdef_utils.load_graphdef_from_file(
"testdata/example_graph.textproto")
G = graphdef_utils.make_graph_from_proto(graphdef)
algorithm = splitbrain.SplitbrainV2()
algorithm = SplitbrainV2()
CLs = algorithm.run(G)
self.assertEqual(CLs, [['fib', 'my_error'], ['do_fib']])

Expand Down Expand Up @@ -52,7 +53,7 @@ def test_SplitbrainV1_only_uses_bazel(self):
nodedef.kind = program_graph_pb2.NodeDef.Kind.SYMBOL
graphdef = program_graph_pb2.GraphDef()
graphdef.symbol.append(nodedef)
self.assertFalse(splitbrain.SplitbrainV1().is_valid(graphdef))
self.assertFalse(SplitbrainV1().is_valid(graphdef))


if __name__ == '__main__':
Expand Down
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import networkx as nx
import program_graph_pb2
import splitbrain
import statistics
import graphdef_utils

from absl import app
Expand Down Expand Up @@ -93,8 +92,8 @@ def main(argv):
if FLAGS.output_dir is None:
raise Exception("output_dir cannot be empty if --enable_statistics.")
print('Writing statistics to disk.')
stats_pb = statistics.evaluate(G, CLs, graphdef, algorithm=algorithm_name,
cl_identifier=FLAGS.cl_identifier)
stats_pb = splitbrain.evaluate(G, CLs, graphdef, algorithm=algorithm_name,
cl_identifier=FLAGS.cl_identifier)
_write_statistics_to_disk(FLAGS.output_dir,
stats_pb,
algorithm=algorithm_name,
Expand Down