Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
341 lines (311 loc) · 12.8 KB
/
Copy pathTaskfile.yml
File metadata and controls
341 lines (311 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
---
# https://taskfile.dev
version: '3'
env :
RENDER_DIR: .rendered
tasks:
default:
desc: "Show all available tasks"
cmds:
- task --list
silent: true
install:
desc: "Install development dependencies for all agents into .venv_dev directory"
cmds:
- echo "Installing development dependencies for all agents"
- uv sync --all-extras
- mv pyproject.toml pyproject.toml.bak
- uv run jinja -D agent_app_name DockerContext -D agent_template_framework docker template/\{\{agent_app_name\}\}/pyproject.toml.jinja -o pyproject.toml
- UV_PROJECT_ENVIRONMENT=.venv_dev uv sync --all-extras
- rm pyproject.toml
- mv pyproject.toml.bak pyproject.toml
- uv sync --all-extras
install-e2e:
desc: "Install dependencies needed to run E2E tests (prefers active venv when activated)"
cmds:
- echo "Installing E2E dependencies"
- |
if [ -n "${VIRTUAL_ENV:-}" ]; then
uv sync --all-extras --active
else
uv sync --all-extras
fi
test-e2e:
desc: "Install + run full deployment E2E"
cmds:
- task: install-e2e
- task: e2e
render-template:
desc: "Render template"
cmds:
- echo "Rendering template {{.AGENT}}"
# Clean up the existing rendered directory except for .venv to speed up rendering and avoid conflict checks
- cd ./$RENDER_DIR/agent_{{.AGENT}}/ && [ -d . ] && find . -mindepth 1 -maxdepth 1 ! -name '.venv' -exec rm -rf {} + || true
- mkdir -p ./$RENDER_DIR/agent_{{.AGENT}}/.datarobot/answers/
- cp ./fixtures/.datarobot/answers/llm-llm.yml ./$RENDER_DIR/agent_{{.AGENT}}/.datarobot/answers/llm-llm.yml
- cp ./fixtures/.datarobot/answers/drmcp-mcp_server.yml ./$RENDER_DIR/agent_{{.AGENT}}/.datarobot/answers/drmcp-mcp_server.yml
- uvx copier copy . ./$RENDER_DIR/agent_{{.AGENT}} --defaults --data agent_template_framework={{.AGENT}} --vcs-ref=HEAD
- cp ./fixtures/Taskfile.yml ./$RENDER_DIR/agent_{{.AGENT}}/Taskfile.yml
- mkdir -p ./$RENDER_DIR/agent_{{.AGENT}}/infra/infra
- cp ./fixtures/infra/Taskfile.yml ./$RENDER_DIR/agent_{{.AGENT}}/infra/Taskfile.yml
- cp ./fixtures/infra/pyproject.toml ./$RENDER_DIR/agent_{{.AGENT}}/infra/pyproject.toml
- cp ./fixtures/infra/__init__.py ./$RENDER_DIR/agent_{{.AGENT}}/infra/infra/__init__.py
- cp ./fixtures/infra/llm.py ./$RENDER_DIR/agent_{{.AGENT}}/infra/infra/llm.py
render-template-e2e:
desc: "Render template + inject test scaffolding used by E2E (Taskfiles + minimal infra entrypoint/files)"
cmds:
- task: render-template
vars:
AGENT: "{{.AGENT}}"
# Add base component scaffolding used by our tests (Taskfiles + minimal infra entrypoint/files).
- cp ./fixtures/Taskfile.yml ./$RENDER_DIR/agent_{{.AGENT}}/Taskfile.yml
- mkdir -p ./$RENDER_DIR/agent_{{.AGENT}}/infra/infra
- cp ./fixtures/infra/Taskfile.yml ./$RENDER_DIR/agent_{{.AGENT}}/infra/Taskfile.yml
# Inject minimal infra scaffolding so `pulumi up` can run in this component repo.
# (In a real AF project this is provided by the base/llm/mcp components.)
- cp ./fixtures/infra/Pulumi.yaml ./$RENDER_DIR/agent_{{.AGENT}}/infra/Pulumi.yaml
- cp ./fixtures/infra/__main__.py ./$RENDER_DIR/agent_{{.AGENT}}/infra/__main__.py
- cp ./fixtures/infra/pyproject.toml ./$RENDER_DIR/agent_{{.AGENT}}/infra/pyproject.toml
- cp ./fixtures/infra/__init__.py ./$RENDER_DIR/agent_{{.AGENT}}/infra/infra/__init__.py
- cp ./fixtures/infra/llm.py ./$RENDER_DIR/agent_{{.AGENT}}/infra/infra/llm.py
- cp ./fixtures/infra/mcp_server.py ./$RENDER_DIR/agent_{{.AGENT}}/infra/infra/mcp_server.py
install-rendered:
desc: "Install dev"
cmds:
- echo "Installing dev for {{.AGENT}}"
- task: render-template
vars:
AGENT: "{{.AGENT}}"
- task agent:install --dir $RENDER_DIR/agent_{{.AGENT}}
- task infra:install --dir $RENDER_DIR/agent_{{.AGENT}}
docker_update_reqs:
desc: "Update Docker requirements pyproject.toml from jinja template"
vars:
genai_agents_path: "{{.AGENT_PATH}}"
cmds:
- |
if [ -z "{{.AGENT_PATH}}" ]; then
echo "AGENT_PATH is not set. Please set AGENT_PATH to the path of the genai-agents repository."
echo "task docker_update_reqs AGENT_PATH=/path/to/datarobot-user-models/public_dropin_environments/python311_genai_agents"
exit 1
fi
- uv run jinja -D agent_app_name DockerContext -D agent_template_framework docker template/\{\{agent_app_name\}\}/pyproject.toml.jinja -o {{.AGENT_PATH}}/pyproject.toml
- cd {{.AGENT_PATH}} && uv lock --no-upgrade && uv sync
# This command is temporary. It is using pip compile to produce a truncated requirements.txt without dependencies to avoid overloading the HHI installer.
- cd {{.AGENT_PATH}} && uv pip compile --python=3.11 --python-platform=x86_64-manylinux_2_28 --no-header --no-annotate --no-deps --extra agentic_playground --output-file=requirements.txt pyproject.toml
# Need to extend support for larger requirements.txt files to enable this.
# - cd {{.AGENT_PATH}} && uv pip freeze > {{.AGENT_PATH}}/requirements.txt
# - cat {{.AGENT_PATH}}/requirements.txt
docker_build_local:
desc: "Build docker image locally (Check container builds)"
cmds:
- cd template/\{\{agent_app_name\}\}/docker_context && docker build -f Dockerfile . -t test --platform linux/amd64
test-agent:
desc: "Run tests"
cmds:
- task: install-rendered
vars:
AGENT: "{{.AGENT}}"
SKIP_LINT: "{{.SKIP_LINT| default 0}}"
SKIP_INFRA: "{{.SKIP_INFRA| default 0}}"
- echo "Running tests for {{.AGENT}}"
- |
if [ "{{.SKIP_LINT}}" != "1" ]; then
task agent:lint-check --dir $RENDER_DIR/agent_{{.AGENT}}
else
echo "Skipping lint check for agent: {{.AGENT}} because SKIP_LINT=1"
fi
- task agent:test-coverage --dir $RENDER_DIR/agent_{{.AGENT}}
- |
if [ "{{.SKIP_INFRA}}" != "1" ]; then
task infra:lint-check --dir $RENDER_DIR/agent_{{.AGENT}}
task infra:test-coverage --dir $RENDER_DIR/agent_{{.AGENT}}
else
echo "Skipping lint check for agent: {{.AGENT}} because SKIP_INFRA=1"
fi
test-base:
desc: "Run tests for base agent"
cmds:
- task: test-agent
vars:
AGENT: base
SKIP_LINT: "{{.SKIP_LINT| default 0}}"
SKIP_INFRA: "{{.SKIP_INFRA| default 0}}"
test-nat:
desc: "Run tests for base agent"
cmds:
- task: test-agent
vars:
AGENT: nat
SKIP_LINT: "{{.SKIP_LINT| default 0}}"
SKIP_INFRA: "{{.SKIP_INFRA| default 0}}"
test-crewai:
desc: "Run tests for crewai agent"
cmds:
- task: test-agent
vars:
AGENT: crewai
SKIP_LINT: "{{.SKIP_LINT| default 0}}"
SKIP_INFRA: "{{.SKIP_INFRA| default 0}}"
test-langgraph:
desc: "Run tests for langgraph agent"
cmds:
- task: test-agent
vars:
AGENT: langgraph
SKIP_LINT: "{{.SKIP_LINT| default 0}}"
SKIP_INFRA: "{{.SKIP_INFRA| default 0}}"
test-llamaindex:
desc: "Run tests for llamaindex agent"
cmds:
- task: test-agent
vars:
AGENT: llamaindex
SKIP_LINT: "{{.SKIP_LINT| default 0}}"
SKIP_INFRA: "{{.SKIP_INFRA| default 0}}"
validate-windows-compatibility:
desc: "Validate that file paths don't contain characters illegal on Windows"
cmds:
- cmd: |
echo "Scanning for Windows-incompatible file names (<>:\"|?*)..."
total=$(find ./template -type f | wc -l | tr -d ' ')
failures=$(find ./template -type f | while IFS= read -r f; do
if echo "$f" | grep -q '[<>:"|?*]'; then
echo "FAIL: $f" >&2
echo "$f"
else
echo " ok: $f" >&2
fi
done)
bad=0
if [ -n "$failures" ]; then
bad=$(echo "$failures" | wc -l | tr -d ' ')
echo ""
echo "Offending files:"
echo "$failures"
fi
echo ""
echo "Checked $total files, $bad incompatible."
[ "$bad" -gt 0 ] && exit 1 || true
platforms: [linux, darwin]
test:
desc: "Run tests for all agents"
cmds:
- task: validate-windows-compatibility
- task: test-base
- task: test-crewai
- task: test-langgraph
- task: test-llamaindex
- task: test-cli
- task: test-cli-json
- task: test-cli-streaming
run-cli:
desc: "Run CLI"
cmds:
- task: install-rendered
vars:
AGENT: "base"
- echo "Running tests for {{.AGENT}}"
- cd $RENDER_DIR/agent_base && echo "DATAROBOT_API_TOKEN=secret" > .env && echo "DATAROBOT_ENDPOINT=https://test.com/api/v2" >> .env
- task agent:cli --dir $RENDER_DIR/agent_base -- execute --show_output --user_prompt "Artificial Intelligence" > $RENDER_DIR/agent_base/agent/output.log 2>&1
test-cli:
desc: "Test CLI"
cmds:
- task: run-cli
- task: check-output
vars:
ASSERTION: "success"
check-output:
- if [ $(wc -l < $RENDER_DIR/agent_base/agent/output.log) -lt 13 ]; then exit 1; fi
- if ! cat $RENDER_DIR/agent_base/agent/output.log | grep -q "Running CLI execute"; then exit 1; fi
- if ! cat $RENDER_DIR/agent_base/agent/output.log | grep -q "INFO - Parsing args"; then exit 1; fi
- if ! cat $RENDER_DIR/agent_base/agent/output.log | grep -q "INFO - Starting DRUM runner"; then exit 1; fi
- if ! cat $RENDER_DIR/agent_base/agent/output.log | grep -q "Running agent with user prompt"; then exit 1; fi
- 'if ! cat $RENDER_DIR/agent_base/agent/output.log | grep -q "\"content\": \"{{.ASSERTION}}\""; then exit 1; fi'
run-cli-json:
desc: "Run CLI with JSON"
cmds:
- task: install-rendered
vars:
AGENT: "base"
- echo "Running tests for {{.AGENT}}"
- cd $RENDER_DIR/agent_base && echo "DATAROBOT_API_TOKEN=secret" > .env && echo "DATAROBOT_ENDPOINT=https://test.com/api/v2" >> .env
- task agent:cli --dir $RENDER_DIR/agent_base -- execute --show_output --completion_json example-completion.json > $RENDER_DIR/agent_base/agent/output.log 2>&1
test-cli-json:
desc: "Test CLI with JSON"
cmds:
- task: run-cli-json
- task: check-output
vars:
ASSERTION: "success"
run-cli-streaming:
desc: "Run CLI with Streaming"
cmds:
- task: install-rendered
vars:
AGENT: "base"
- echo "Running tests for {{.AGENT}}"
- cd $RENDER_DIR/agent_base && echo "DATAROBOT_API_TOKEN=secret" > .env && echo "DATAROBOT_ENDPOINT=https://test.com/api/v2" >> .env
- task agent:cli --dir $RENDER_DIR/agent_base -- execute --show_output --user_prompt "Artificial Intelligence" --stream > $RENDER_DIR/agent_base/agent/output.log 2>&1
test-cli-streaming:
desc: "Test CLI with Streaming"
cmds:
- task: run-cli-streaming
- task: check-output
vars:
ASSERTION: "streaming success"
build-docker:
desc: "Build docker image"
cmds:
- task: install-rendered
vars:
AGENT: "{{.AGENT}}"
- echo "Building docker image for {{.AGENT}}"
- task agent:build-docker --dir $RENDER_DIR/agent_{{.AGENT}}
build-docker-base:
desc: "Build docker for base agent"
cmds:
- task: build-docker
vars:
AGENT: base
build-docker-crewai:
desc: "Build docker for crewai agent"
cmds:
- task: build-docker
vars:
AGENT: crewai
build-docker-langgraph:
desc: "Build docker for langgraph agent"
cmds:
- task: build-docker
vars:
AGENT: langgraph
build-docker-llamaindex:
desc: "Build docker for llamaindex agent"
cmds:
- task: build-docker
vars:
AGENT: llamaindex
build-docker-nat:
desc: "Build docker image for NAT"
cmds:
- task: build-docker
vars:
AGENT: nat
e2e:
desc: "Run full deployment E2E for all agents (requires DATAROBOT_ENDPOINT + DATAROBOT_API_TOKEN)"
cmds:
- echo "Running full deployment E2E (all agent frameworks)"
- |
# Load local repo `.env` (gitignored) if present.
# Keep it scoped to E2E so credentials don't leak into unrelated tasks.
set -a
if [ -f ".env" ]; then
. ".env"
fi
set +a
if [ -n "${VIRTUAL_ENV:-}" ]; then
RUN_E2E=1 uv run --all-extras --active pytest --import-mode=importlib -vv -s ./tests/e2e/test_agent_e2e.py
else
RUN_E2E=1 uv run --all-extras pytest --import-mode=importlib -vv -s ./tests/e2e/test_agent_e2e.py
fi