Skip to content

Commit bcae576

Browse files
committed
Revise installation guide and enhance introduction with dynamic execution details
1 parent 2567eb5 commit bcae576

6 files changed

Lines changed: 161 additions & 203 deletions

File tree

docs/getting-started/hello-world.mdx

Lines changed: 72 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 3
2+
sidebar_position: 4
33
---
44

55
import Tabs from '@theme/Tabs';
@@ -28,58 +28,105 @@ uv add graflow
2828
</TabItem>
2929
</Tabs>
3030

31-
## Create a Workflow File
31+
## Your First Task
3232

33-
Create a new file called `workflow.yaml`:
33+
Create a file called `hello.py`:
3434

35-
```yaml
36-
name: hello-world
37-
description: My first Graflow workflow
35+
```python
36+
from graflow import task
3837

39-
tasks:
40-
- name: greet
41-
script: |
42-
echo "Hello, Graflow!"
43-
```
38+
@task
39+
def hello():
40+
print("Hello, Graflow!")
41+
return "success"
4442

45-
## Run the Workflow
43+
if __name__ == "__main__":
44+
result = hello.run()
45+
print(f"Task completed with result: {result}")
46+
```
4647

47-
Execute your workflow using the Graflow CLI:
48+
Run it:
4849

4950
<Tabs>
5051
<TabItem value="pip" label="pip" default>
5152

5253
```bash
53-
graflow run workflow.yaml
54+
python hello.py
5455
```
5556

5657
</TabItem>
5758
<TabItem value="uv" label="uv">
5859

5960
```bash
60-
uv run graflow run workflow.yaml
61+
uv run hello.py
6162
```
6263

6364
</TabItem>
6465
</Tabs>
6566

66-
You should see output similar to:
67+
You should see:
6768

6869
```
69-
[2025-01-01 12:00:00] Starting workflow: hello-world
70-
[2025-01-01 12:00:00] Running task: greet
7170
Hello, Graflow!
72-
[2025-01-01 12:00:01] Task completed: greet
73-
[2025-01-01 12:00:01] Workflow completed successfully
71+
Task completed with result: success
72+
```
73+
74+
## Your First Workflow
75+
76+
Now let's chain multiple tasks into a workflow. Create `pipeline.py`:
77+
78+
```python
79+
from graflow import task, workflow
80+
81+
with workflow("simple_pipeline") as wf:
82+
83+
@task
84+
def start():
85+
print("Starting!")
86+
87+
@task
88+
def middle():
89+
print("Middle!")
90+
91+
@task
92+
def end():
93+
print("End!")
94+
95+
# Define sequential pipeline: start -> middle -> end
96+
start >> middle >> end
97+
98+
# Execute the workflow
99+
wf.execute()
100+
```
101+
102+
Run it:
103+
104+
<Tabs>
105+
<TabItem value="pip" label="pip" default>
106+
107+
```bash
108+
python pipeline.py
74109
```
75110

76-
## Understanding the Output
111+
</TabItem>
112+
<TabItem value="uv" label="uv">
77113

78-
Graflow provides detailed logging for every step:
114+
```bash
115+
uv run pipeline.py
116+
```
117+
118+
</TabItem>
119+
</Tabs>
120+
121+
You should see:
122+
123+
```
124+
Starting!
125+
Middle!
126+
End!
127+
```
79128

80-
- **Timestamps**: When each task started and completed
81-
- **Task names**: Which task is currently running
82-
- **Output**: The actual output from your scripts
129+
The `>>` operator chains tasks sequentially — `middle` runs after `start`, and `end` runs after `middle`.
83130

84131
## Next Steps
85132

docs/getting-started/installation.md

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
import Tabs from '@theme/Tabs';
6+
import TabItem from '@theme/TabItem';
7+
8+
# Installation
9+
10+
This guide will help you install Graflow on your system.
11+
12+
## System Requirements
13+
14+
- Python 3.9 or higher
15+
- Docker (optional, for containerized tasks)
16+
17+
## Installation Methods
18+
19+
<Tabs>
20+
<TabItem value="pip" label="pip" default>
21+
22+
```bash
23+
pip install graflow
24+
```
25+
26+
</TabItem>
27+
<TabItem value="uv" label="uv">
28+
29+
```bash
30+
uv add graflow
31+
```
32+
33+
</TabItem>
34+
</Tabs>
35+
36+
### Install with All Extras
37+
38+
To install Graflow with all optional dependencies:
39+
40+
<Tabs>
41+
<TabItem value="pip" label="pip" default>
42+
43+
```bash
44+
pip install "graflow[all]"
45+
```
46+
47+
</TabItem>
48+
<TabItem value="uv" label="uv">
49+
50+
```bash
51+
uv add "graflow[all]"
52+
```
53+
54+
</TabItem>
55+
</Tabs>
56+
57+
`graflow[all]` includes the following extras:
58+
59+
| Extra | Description |
60+
|-------|-------------|
61+
| `api` | REST API server (FastAPI, Uvicorn) |
62+
| `visualization` | Graph visualization (Matplotlib, Graphviz) |
63+
| `tracing` | Observability (OpenTelemetry, Langfuse) |
64+
| `docker` | Docker-based task execution |
65+
| `redis` | Redis-backed distributed execution |
66+
| `adk` | Google ADK agent integration |
67+
| `pydantic-ai` | Pydantic AI agent integration |
68+
69+
You can also install individual extras, e.g. `graflow[visualization]` or `graflow[tracing]`.
70+
71+
## Verify Installation
72+
73+
After installation, verify that Graflow is installed correctly:
74+
75+
```python
76+
import graflow
77+
print(graflow.__version__)
78+
```
79+
80+
You should see the version number printed to the console.
81+
82+
## Next Steps
83+
84+
Now that you have Graflow installed, let's create your first workflow in the [Hello World](./hello-world) tutorial.

docs/getting-started/introduction.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ with workflow("etl_pipeline") as wf:
4848
```
4949

5050
:::note
51-
Note Graflow also provides low-level APIs to define task graphs as well. See the [Reference](/docs/reference/configuration) for details.
51+
Note Graflow also provides low-level APIs to define task graphs as well.
5252
:::
5353

5454
### Dynamic Transitions at Runtime
5555

5656
Traditional DAG-based systems cannot express cycles by definition. With Graflow's **State Machine execution**, cycles and dynamic branching become natural:
5757

58+
:::tip Defined-by-Run
59+
This approach is conceptually similar to the **Define-by-Run** (also known as [Dynamic Computation Graph](https://apxml.com/courses/advanced-pytorch/chapter-1-pytorch-internals-autograd/computational-graph)) paradigm found in deep learning frameworks such as PyTorch and Chainer. Instead of declaring the entire computation graph upfront (Define-and-Run), the execution graph is constructed dynamically as the code runs, enabling flexible control flow like cycles and conditional branching.
60+
:::
61+
5862
```python
5963
@task(inject_context=True)
6064
def process_data(context: TaskExecutionContext):

docs/reference/cli.md

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)