Skip to content

Commit de2b9ac

Browse files
committed
chore: clean up dag_to_code doctests
1 parent fae5f58 commit de2b9ac

3 files changed

Lines changed: 36 additions & 20 deletions

File tree

meshed/dag.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,44 +1576,47 @@ def dag_to_code(dag):
15761576
... b = func2(a, z)
15771577
... c = func3(a, w=b)
15781578
>>>
1579-
>>> print("Original DAG:")
1579+
15801580
Original DAG:
1581-
>>> print(test_pipeline.synopsis_string())
1581+
1582+
>>> print(test_pipeline.synopsis_string()) # doctest: +NORMALIZE_WHITESPACE
15821583
x,y -> func1 -> a
15831584
a,z -> func2 -> b
15841585
a,b -> func3 -> c
15851586
<BLANKLINE>
1586-
>>> print("Generated code using dag_to_code function:")
1587+
15871588
Generated code using dag_to_code function:
1589+
15881590
>>> code1 = dag_to_code(test_pipeline)
1589-
>>> print(code1)
1591+
>>> print(code1) # doctest: +NORMALIZE_WHITESPACE
15901592
def test_pipeline():
15911593
a = func1(x, y)
15921594
b = func2(a, z)
15931595
c = func3(a, w=b)
15941596
<BLANKLINE>
1595-
>>> print("Generated code using DAG.to_code method:")
1596-
Generated code using DAG.to_code method:
1597-
>>> code2 = test_pipeline.to_code()
1598-
>>> print(code2)
1597+
1598+
Generated code using `DAG.to_code` method:
1599+
1600+
>>> code2 = dag_to_code(test_pipeline)
1601+
>>> print(code2) # doctest: +NORMALIZE_WHITESPACE
15991602
def test_pipeline():
16001603
a = func1(x, y)
16011604
b = func2(a, z)
16021605
c = func3(a, w=b)
16031606
<BLANKLINE>
1604-
>>> # Test round-trip conversion
1605-
>>> print("Round-trip test:")
1606-
Round-trip test:
1607+
1608+
Test round-trip conversion:
1609+
16071610
>>> dag2 = code_to_dag(code1)
1608-
>>> print(dag2.synopsis_string())
1611+
>>> print(dag2.synopsis_string()) # doctest: +NORMALIZE_WHITESPACE
16091612
x,y -> func1 -> a
16101613
a,z -> func2 -> b
16111614
a,b -> func3 -> c
16121615
<BLANKLINE>
1613-
>>> # Verify they're equivalent
1614-
>>> assert test_pipeline.synopsis_string() == dag2.synopsis_string()
1615-
>>> print("✓ Round-trip conversion successful!")
1616-
✓ Round-trip conversion successful!
1616+
>>> # Verify they're equivalent:
1617+
>>> test_pipeline.synopsis_string() == dag2.synopsis_string()
1618+
True
1619+
16171620
16181621
"""
16191622
return func_nodes_to_code(dag.func_nodes, dag.name)

meshed/ext/gk.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
"""
2-
This module was based on yahoo/graphkit
3-
Made to without networkx, amongst other things
2+
This module is meant to explore a different representation of a computation graph
3+
and a different way of executing it.
4+
It is based on Yahoo's graphkit library. The library hasn't been maintained since 2018,
5+
so vendored and modified here).
6+
One of the main differences is that we got rid of the networkx dependency,
7+
which was used to represent the computation graph.
8+
Instead, this module uses meshed's itools library to represent the computation graph.
9+
10+
# Yahoo's graphkit library is under Apache License 2.0:
11+
# Copyright 2016, Yahoo Inc.
12+
# Licensed under the terms of the Apache License, Version 2.0. See the LICENSE file associated with the project for terms.
13+
14+
NOTE: This module is only meant to an exploratory "extension". It is not planned to be maintained.
415
"""
516

617
# ---------- base --------------------------------------------------------------

meshed/ext/gk_tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Tests for gk.py
33
"""
44

5-
# Copyright 2016, Yahoo Inc.
6-
# Licensed under the terms of the Apache License, Version 2.0. See the LICENSE file associated with the project for terms.
5+
import pytest
6+
77
from contextlib import suppress
88

99
import math
@@ -251,6 +251,8 @@ def addplusplus(a, b, c=0):
251251
results = net({"a": 4, "b": 3}, outputs=["sum2"])
252252
assert "sum2" in results
253253

254+
# Skip this test since it requires a long time to run
255+
@pytest.mark.skip(reason="This test takes a long time to run")
254256
def test_parallel_execution():
255257
import time
256258

0 commit comments

Comments
 (0)