Skip to content

Commit 82c0cfd

Browse files
authored
Adrian/viz (#163)
* cp * wip * wip * wip * working again * test gha * fix precommits * Add llama-index-utils-workflow release * woops * clean up pyproject * Update docs * ugly toml sort fix * oops
1 parent 66d2c49 commit 82c0cfd

File tree

12 files changed

+3522
-28
lines changed

12 files changed

+3522
-28
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
- name: Run linter
1919
shell: bash
2020
run: |
21-
uv sync --all-extras
21+
uv sync --all-extras --all-packages
2222
uv run -- pre-commit run -a

.github/workflows/publish_release.yml

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ on:
1919
type: string
2020
push:
2121
tags:
22-
- "v*"
22+
- "v*" # core package tags
23+
- "*@v*" # package-scoped tags like package@v1.2.3
2324

2425
jobs:
2526
build-n-publish:
@@ -28,6 +29,15 @@ jobs:
2829
runs-on: ubuntu-latest
2930
permissions:
3031
contents: write
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
package: [llama-index-workflows, llama-index-utils-workflow]
36+
include:
37+
- package: llama-index-workflows
38+
is_core: true
39+
- package: llama-index-utils-workflow
40+
is_core: false
3141

3242
steps:
3343
- uses: actions/checkout@v4
@@ -37,42 +47,76 @@ jobs:
3747
- name: Install uv
3848
uses: astral-sh/setup-uv@v6
3949

40-
- name: Validate version
41-
if: startsWith(github.ref, 'refs/tags/')
50+
- name: Parse tag
51+
id: tag
52+
run: |
53+
REF_NAME="${GITHUB_REF_NAME}"
54+
if [[ "${REF_NAME}" == v* ]]; then
55+
PKG="llama-index-workflows"
56+
VERSION="${REF_NAME#v}"
57+
else
58+
# strip optional leading '@'
59+
REF_TRIMMED="${REF_NAME#@}"
60+
PKG_PART="${REF_TRIMMED%@v*}"
61+
PKG="${PKG_PART}"
62+
VERSION_PART="${REF_TRIMMED#*@v}"
63+
VERSION="${VERSION_PART}"
64+
fi
65+
echo "package=${PKG}" >> $GITHUB_OUTPUT
66+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
67+
68+
- name: Compute directory flag
69+
id: dir
70+
run: |
71+
if [ "${{ matrix.is_core }}" = "true" ]; then
72+
echo "dir_flag=" >> $GITHUB_OUTPUT
73+
else
74+
echo "dir_flag=--directory packages/${{ matrix.package }}" >> $GITHUB_OUTPUT
75+
fi
76+
77+
- name: Guard non-target matrix entry
78+
if: steps.tag.outputs.package != matrix.package
79+
run: echo "Skipping matrix package ${{ matrix.package }} for tag ${{ steps.tag.outputs.package }}" && exit 0
80+
81+
- name: Validate version (core only)
82+
if: startsWith(github.ref, 'refs/tags/') && matrix.is_core == true
4283
run: uv run python scripts/validate_version.py
4384

4485
- name: Set version output
4586
id: version
4687
run: |
47-
VERSION=$(uv run python -c "from importlib.metadata import version; print(version('llama-index-workflows'))")
88+
VERSION=$(uv run ${{ steps.dir.outputs.dir_flag }} python -c "from importlib.metadata import version; print(version('${{ matrix.package }}'))")
4889
echo "Version: $VERSION"
4990
echo "version=$VERSION" >> $GITHUB_OUTPUT
5091
5192
- name: Build and publish
5293
env:
5394
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
5495
run: |
55-
uv build
56-
uv publish
96+
uv build ${{ steps.dir.outputs.dir_flag }}
97+
uv publish ${{ steps.dir.outputs.dir_flag }}
5798
58-
- name: Generate OpenAPI spec
99+
- name: Generate OpenAPI spec (core only)
100+
if: matrix.is_core == true
59101
run: |
60102
uv sync --all-extras
61103
uv run hatch run server:openapi
62104
63-
- name: Create GitHub Release
105+
- name: Create GitHub Release (core only)
106+
if: matrix.is_core == true
64107
uses: ncipollo/release-action@v1
65108
with:
66109
artifacts: "dist/*,openapi.json"
67110
generateReleaseNotes: true
68111

69-
- name: Detect change type for tags
112+
- name: Detect change type for tags (core only)
70113
id: detect_change
71-
if: startsWith(github.ref, 'refs/tags/')
114+
if: startsWith(github.ref, 'refs/tags/') && matrix.is_core == true
72115
run: uv run python scripts/detect_change_type.py
73116

74117
- name: Set SDK trigger parameters
75118
id: sdk_params
119+
if: matrix.is_core == true
76120
run: |
77121
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
78122
echo "change_type=${{ github.event.inputs.server_change_type }}" >> $GITHUB_OUTPUT
@@ -84,14 +128,15 @@ jobs:
84128
85129
- name: Generate GitHub App Token
86130
id: app-token
131+
if: matrix.is_core == true
87132
uses: actions/create-github-app-token@v1
88133
with:
89134
app-id: ${{ secrets.CI_BOT_APP_ID }}
90135
private-key: ${{ secrets.CI_BOT_PRIVATE_KEY }}
91136
owner: run-llama
92137

93138
- name: Trigger SDK Update
94-
if: steps.sdk_params.outputs.change_type != 'none' && steps.sdk_params.outputs.change_type != ''
139+
if: matrix.is_core == true && steps.sdk_params.outputs.change_type != 'none' && steps.sdk_params.outputs.change_type != ''
95140
uses: peter-evans/repository-dispatch@v3
96141
with:
97142
token: ${{ steps.app-token.outputs.token }}

.github/workflows/test.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
20+
package: [llama-index-workflows, llama-index-utils-workflow]
21+
include:
22+
- package: llama-index-workflows
23+
is_root: true
24+
coverage_report: true
25+
- package: llama-index-utils-workflow
26+
is_root: false
27+
coverage_report: false
2028
steps:
2129
- uses: actions/checkout@v4
2230
with:
@@ -28,16 +36,22 @@ jobs:
2836
python-version: ${{ matrix.python-version }}
2937
enable-cache: true
3038

31-
- name: Run tests
32-
if: matrix.python-version != env.COV_PYTHON_VERSION
33-
run: uv run --all-extras pytest
39+
- name: Compute directory flag
40+
run: |
41+
if [ "${{ matrix.is_root }}" = "true" ]; then
42+
echo "DIR_FLAG=" >> $GITHUB_ENV
43+
else
44+
echo "DIR_FLAG=--directory packages/${{ matrix.package }}" >> $GITHUB_ENV
45+
fi
46+
47+
- name: Sync dev dependencies for selected package
48+
run: uv sync --all-extras $DIR_FLAG --group dev
3449

3550
- name: Run tests with coverage
36-
if: matrix.python-version == env.COV_PYTHON_VERSION
37-
run: uv run --all-extras -- pytest --cov --cov-report=xml
51+
run: uv run --all-extras $DIR_FLAG -- pytest --cov --cov-report=xml
3852

3953
- name: Report Coveralls
40-
if: matrix.python-version == env.COV_PYTHON_VERSION
54+
if: matrix.coverage_report == true && matrix.python-version == env.COV_PYTHON_VERSION
4155
uses: coverallsapp/github-action@v2
4256
env:
4357
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

docs/src/content/docs/workflows/drawing.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ draw_all_possible_flows(JokeFlow, filename="joke_flow_all.html")
2323

2424
# Draw an execution
2525
w = JokeFlow()
26-
await w.run(topic="Pirates")
27-
draw_most_recent_execution(w, filename="joke_flow_recent.html")
26+
handler = w.run(topic="Pirates")
27+
await handler
28+
draw_most_recent_execution(handler, filename="joke_flow_recent.html")
2829
```
2930

3031
<div id="working-with-global-context-state"></div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test*.html
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# LlamaIndex Utils: Workflow
2+
3+
Utilities for LlamaIndex workflows, including visualization tools.
4+
5+
```bash
6+
pip install llama-index-utils-workflow
7+
```
8+
9+
## Features
10+
11+
- **Workflow visualization** with `draw_all_possible_flows()`
12+
- **Latest execution visualization** with `draw_most_recent_execution()`
13+
- **Label truncation support** for better readability with long event names
14+
15+
## Usage
16+
17+
```python
18+
from llama_index.utils.workflow import draw_all_possible_flows
19+
20+
# Basic workflow visualization
21+
draw_all_possible_flows(my_workflow, "workflow.html")
22+
23+
# With label truncation for long event names (v0.4.0+)
24+
draw_all_possible_flows(my_workflow, "workflow.html", max_label_length=15)
25+
26+
# Latest execution visualization
27+
handler = my_workflow.run()
28+
await handler
29+
draw_most_recent_execution(handler, "workflow.html")
30+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[dependency-groups]
6+
dev = ["pytest>=8.4.2", "pytest-asyncio>=1.0.0", "pytest-cov>=6.1.1"]
7+
8+
[project]
9+
name = "llama-index-utils-workflow"
10+
version = "0.4.1"
11+
description = "llama-index utils for workflows"
12+
readme = "README.md"
13+
authors = [{name = "Adrian Lyjak", email = "adrianlyjak@gmail.com"}]
14+
requires-python = ">=3.9"
15+
dependencies = [
16+
"llama-index-core>=0.14,<0.15.0",
17+
"llama-index-workflows>=2.8.3,<3.0.0",
18+
"pyvis>=0.3.2"
19+
]
20+
21+
[tool.hatch.build.targets.sdist]
22+
only-include = ["src/llama_index"]
23+
24+
[tool.hatch.build.targets.wheel]
25+
packages = ["src/llama_index"]

0 commit comments

Comments
 (0)