Commit 29287c2
authored
feat(evaluation): add DatasetClient and dataset management service provider (#491)
* feat(evaluation): add DatasetClient and ServiceDatasetProvider
Add Dataset Management SDK support with:
- DatasetClient: pass-through client for all 11 dataset APIs
(create/get/list/update/delete datasets, versions, examples)
with 6 _and_wait helpers for async operations
- ServiceDatasetProvider: fetches datasets from the service and
returns SDK Dataset objects compatible with OnDemandEvaluationDatasetRunner
and BatchEvaluationRunner
- Unit tests (20 tests) and integration tests (17 tests, verified against
live AWS)
* refactor(evaluation): use downloadUrl for ServiceDatasetProvider
Switch ServiceDatasetProvider from list_dataset_examples pagination
to downloading the JSONL file via the presigned downloadUrl from
GetDataset. Single HTTP request is simpler and faster for large datasets.
* test(evaluation): add runner integ test helpers and skipped runner tests
- helpers.py: get_or_create_agent_runtime(), make_agent_invoker()
with retry logic and warmup for cold start handling
- test_runners_with_service_dataset.py: OnDemandRunner + ServiceDatasetProvider
end-to-end test (skipped until a working deployed agent is available —
current account has 30s init timeout that prevents cold starts)
* test(evaluation): runner integ test passes with real agent
Update test_runners_with_service_dataset.py to use env-var config:
- INTEG_AGENT_RUNTIME_ARN: skips if not set
- BEDROCK_TEST_REGION: region matching the agent
- Verified end-to-end: ServiceDatasetProvider → OnDemandRunner → real agent invocation → COMPLETED
* refactor: extract region from agent ARN, no separate BEDROCK_TEST_REGION needed
* fix(evaluation): address PR review feedback
- ServiceDatasetProvider: accept client in __init__ (eliminates region_name)
- ServiceDatasetProvider: validate schemaType against supported runner schemas
- ServiceDatasetProvider: proper error message on download failure
- Remove helpers.py (not needed)
- Add unit tests for unsupported schema and download failure cases
* fix(evaluation): address second round of PR feedback
- ServiceDatasetProvider: import DatasetClient at top, default in __init__
- ScenarioExecutor: add schema_type field, override in Predefined/Simulated
- ServiceDatasetProvider: collect supported schemas dynamically from executors
- delete_dataset_and_wait: add DELETE_FAILED as failed status
* style: fix lint and formatting
* style: fix remaining line-too-long issues
* fix: remove unused variable assignment (F841)
* refactor: move schema_type to Scenario classes, _parse_scenario to module level
- Add schema_type field to Scenario base, PredefinedScenario, SimulatedScenario
- Remove schema_type from ScenarioExecutor (doesn't belong there)
- Move _parse_scenario from FileDatasetProvider to module-level function
- SUPPORTED_SCHEMA_TYPES derived from Scenario classes directly
* fix: remove unused _DATASET_FAILED_STATUSES constant
* fix(evaluation): address reviewer findings
- Add timeout=60 to requests.get() for presigned URL download (#1)
- Use r.content.decode("utf-8") instead of r.text for explicit encoding (#3)
- Replace model_fields introspection with plain constant set (#8)
- Guard __getattr__ against recursion when _cp_client not initialized (#5)
- Remove dead _mock_client function from tests (#11)
* fix(evaluation): stream JSONL download and consolidate test fixtures
- Stream JSONL via iter_lines() instead of loading entire file into memory (#2)
- Consolidate repetitive test mock setup with pytest fixtures (#12)
* refactor(evaluation): rename ServiceDatasetProvider to DatasetManagementServiceProvider
Addresses PR review feedback: the name makes explicit which service
the provider loads datasets from (Dataset Management Service).
* fix: Removed delete_dataset_version api from allowlist
* feat(evaluation): support JSONL files in FileDatasetProvider
Dispatch on file extension: paths ending in .jsonl are read line-by-line
(one scenario per line). All other paths keep the existing
{"scenarios": [...]} JSON shape.
Adds 8 unit tests covering predefined/simulated/mixed JSONL content,
blank-line tolerance, malformed lines, and extension dispatch.
* fix(evaluation): handle version-specific deletes in delete_dataset_and_wait
A version-specific delete (datasetVersion provided) does not remove the
dataset itself — it transitions the dataset to UPDATING and back to ACTIVE.
The previous waiter polled for ResourceNotFoundException and timed out.
Branch on whether datasetVersion is passed:
- Without datasetVersion: poll until ResourceNotFoundException (DELETE_FAILED)
- With datasetVersion: poll until ACTIVE (UPDATE_FAILED), return dataset dict
Add unit tests for both version-delete paths (success + UPDATE_FAILED)
and an integ test that creates two versions, deletes the oldest via
delete_dataset_and_wait, and verifies the dataset stays ACTIVE.1 parent 0b2b34f commit 29287c2
10 files changed
Lines changed: 1459 additions & 39 deletions
File tree
- src/bedrock_agentcore/evaluation
- runner
- tests_integ/evaluation
- tests/bedrock_agentcore/evaluation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
| 92 | + | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments