Skip to content

Commit 7aa32fe

Browse files
committed
Improve documentation of usage patterns.
1 parent 78f4fd4 commit 7aa32fe

File tree

3 files changed

+331
-129
lines changed

3 files changed

+331
-129
lines changed

docs/source/getting_started.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ def net_income(income, tax):
3939
combined = dags.concatenate_functions(
4040
functions={"income": income, "tax_rate": tax_rate, "tax": tax, "net_income": net_income},
4141
targets=["net_income", "tax"],
42+
return_type="dict",
4243
)
4344

4445
result = combined()
45-
# result = {"net_income": 35000, "tax": 15000}
46+
# result = {"net_income": 35000.0, "tax": 15000.0}
4647
```
4748

4849
### Providing External Inputs
@@ -59,25 +60,33 @@ def net_income(income, tax):
5960
combined = dags.concatenate_functions(
6061
functions={"tax": tax, "net_income": net_income},
6162
targets=["net_income"],
63+
return_type="dict",
6264
)
6365

6466
# income and tax_rate are external inputs
6567
result = combined(income=50000, tax_rate=0.3)
66-
# result = {"net_income": 35000}
68+
# result = {"net_income": 35000.0}
6769
```
6870

6971
### Return Types
7072

71-
By default, `concatenate_functions` returns a dictionary. You can also get a tuple:
73+
By default, `concatenate_functions` returns a tuple. You can also get a dictionary:
7274

7375
```python
76+
# Default: returns tuple
7477
combined = dags.concatenate_functions(
7578
functions=functions,
7679
targets=["a", "b", "c"],
77-
return_type="tuple", # or "dict" (default)
7880
)
79-
8081
a, b, c = combined()
82+
83+
# Returns dictionary with target names as keys
84+
combined = dags.concatenate_functions(
85+
functions=functions,
86+
targets=["a", "b", "c"],
87+
return_type="dict",
88+
)
89+
result = combined() # {"a": ..., "b": ..., "c": ...}
8190
```
8291

8392
## Inspecting the DAG
@@ -125,14 +134,14 @@ args = dags.get_free_arguments(my_func)
125134

126135
### Getting Type Annotations
127136

128-
{func}`~dags.get_annotations` returns type annotations as strings:
137+
{func}`~dags.get_annotations` returns type annotations:
129138

130139
```python
131140
def my_func(a: int, b: float) -> float:
132141
return a + b
133142

134143
annotations = dags.get_annotations(my_func)
135-
# annotations = {"a": "int", "b": "float", "return": "float"}
144+
# annotations = {"a": int, "b": float, "return": float}
136145
```
137146

138147
## Renaming Arguments

docs/source/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def c(a, b):
3232
combined = dags.concatenate_functions(
3333
functions={"a": a, "b": b, "c": c},
3434
targets=["c"],
35+
return_type="dict",
3536
)
3637

3738
result = combined(x=5) # Returns {"c": 51}

0 commit comments

Comments
 (0)