data_resources - #24
Conversation
…larify optional callbacks
…ure and unique operationIds
…lts" section to CHANGELOG.md showing thelatest test summary (492 passed,0,0 failed, ~70). Insert a new release header for0.13.3 dated202604-14 preservethe existing "Added" entries describing CaseNodeUpdate.upsert / Case.patch and human-answer casestep_index. This documents the test health and records the new patch release sousers and maintainers can see the verification status alongside thefeature notes.
Review Summary by QodoAdd DataResource CRUD framework with auto-generated routes and metadata support
WalkthroughsDescription• Add DataResource and DataResourceField models for agent-owned CRUD endpoints • Introduce FieldType and Editable enums for field validation and form control • Add metadata field to AbstractJob and CaseAbstractModel for custom context • Auto-generate FastAPI CRUD routes for declared DataResources with bulk import support • Include data_resources in Agent.registration_info for Studio discovery Diagramflowchart LR
A["Agent declares<br/>DataResources"] -->|includes| B["DataResource<br/>with callbacks"]
B -->|defines| C["DataResourceField<br/>with FieldType"]
B -->|triggers| D["Auto-generated<br/>CRUD routes"]
D -->|secured by| E["API key auth"]
A -->|exposes via| F["registration_info"]
G["Job/Case<br/>metadata"] -->|flows to| F
File Changes1. src/supervaizer/data_resource.py
|
Code Review by Qodo
|
| def _make_import_handler(r: DataResource, prefix: str) -> Any: | ||
| async def _handler(records: list[dict[str, Any]] = Body(...)) -> dict[str, Any]: | ||
| log.info(f"📥 POST {prefix}/import/ [DataResource import: {r.name}]") | ||
| return r.on_import(records) # type: ignore[misc] | ||
| return _handler |
There was a problem hiding this comment.
7. Csv import not supported 🐞 Bug ≡ Correctness
The CHANGELOG claims the bulk import route accepts CSV or JSON, but the import handler only accepts a JSON body (list[dict]); CSV uploads will fail validation.
Agent Prompt
### Issue description
The bulk import route is documented as accepting CSV or JSON, but the handler only accepts JSON (`records: list[dict[str, Any]] = Body(...)`). CSV content will not be accepted.
### Issue Context
This is an API contract issue. Either implement CSV parsing or update the documentation to remove CSV claims.
### Fix Focus Areas
- src/supervaizer/data_routes.py[97-105]
- src/supervaizer/data_routes.py[162-166]
- docs/CHANGELOG.md[38-39]
### Suggested fix
Option A (implement CSV):
- Accept `UploadFile` (multipart/form-data) or raw `text/csv` body.
- Parse CSV into `list[dict[str, Any]]` (header row -> keys), then call `on_import(records)`.
- Keep existing JSON support.
Option B (docs-only):
- Update CHANGELOG and any docs to state JSON-only import until CSV is implemented.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
…lity and consistency- long import lists and DataResourceField instantiations across multiple lines to make diffs clearer and improve maintainability. - Break long Field(...) and model attribute declarations into multiple lines so descriptions and default factories are visually distinct. - Add and blank in data_routes separate logical blocks. - Annotate signature multiple lines for clarity. - Adjust slicing and HTTPException formatting to conform to the project's spacing and line-length style. These are purely stylist and do not alter behavior They make code easier to review and maintain, and keep lines within theproject's preferred width.
…Add a strict name pattern for DataResource (lowercase letters, digits, and hyphens; must start with a letter or digit) and apply it to the DataResource.name field. This ensures path and OpenAPI operation_id fragments remain safe and predictable. - Clarify and expand the DataResource.name Field description to document the allowed characters intent. - Adjust on_update signature to allow returning None from update handlers (Callable[[str, dict[str, Any]], dict[str, Any] | None to support handlers that may not always return an updated object. - Serialize event payloads in tests with SvBaseModel.serialize_value to match the application's payload serialization when sending events- Add a new test ensuring OpenAPI operation for data resource list endpoints unique per agent. This prevents collisions multiple agents expose resources with the same name. - Update and test scaffolding to support the new test (add DataResource and Parameters imports RSA key generation in the test server setup). These changes improve API, flexibility and test coveragefor OpenAPI uniqueness.
Summary- Add DataResource and DataResourceField models- metadata field to AbstractJob and CaseAbstractModel- Introduce FieldType enum, fix computed_field behavior, and clarify optional callbacks- Add data_resources field and registration_info support to agent- Generate CRUD routes for DataResource with factory functions for safe capture and unique operationIds- Remove duplicate entries from __all- Update CHANGELOG and version for DataResource release add test results section and release header for0.13.3