[PR #110] [MERGED] server: flattened handler metadata in responses, shared OpenAPI components, and test updates #128

Closed
opened 2026-02-16 02:16:40 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/run-llama/workflows-py/pull/110
Author: @zhaotai
Created: 9/23/2025
Status: Merged
Merged: 9/23/2025
Merged by: @zhaotai

Base: mainHead: feat/server-metadata-typed


📝 Commits (4)

  • 586b94f server: return ISO 8601 timestamps (Z) for started_at/updated_at/completed_at and update OpenAPI to date-time format
  • 23e7b4b server: format timestamps with strftime('%Y-%m-%dT%H:%M:%SZ') for canonical ISO-8601Z output
  • e512310 tests(server): add datetime progression test for handler started_at/updated_at/completed_at
  • 5366d41 fix lint

📊 Changes

3 files changed (+90 additions, -32 deletions)

View changed files

📝 src/workflows/server/server.py (+36 -29)
📝 tests/server/test_server_endpoints.py (+52 -1)
📝 uv.lock (+2 -2)

📄 Description

Summary

  • Add and surface flattened runtime handler metadata across server endpoints (no new endpoints).
  • Replace per-endpoint, hand-built dicts with a single source to_dict() on the server-side wrapper.
  • Consolidate OpenAPI schemas via shared components to remove duplication.
  • Update tests to reflect expected behavioral changes.

API changes (intentional)

  • Flattened metadata fields are now included in these responses:
    • POST /workflows/{name}/run (200)
    • POST /workflows/{name}/run-nowait (200)
    • GET /results/{handler_id} (200, 202)
    • GET /handlers (200, each item)
  • Run-nowait response:
    • status was previously “started”; it now returns status: "running".
  • Get result error response:
    • GET /results/{handler_id} now returns a detailed error as text/plain on 500 (instead of a JSON object).

Implementation details

  • Introduced server-side wrapper _WorkflowHandler.to_dict() returning a typed HandlerDict.
  • Safe accessors on _WorkflowHandler:
    • status: guards unfinished futures and maps to "running" | "completed" | "failed".
    • error: None when unfinished, stringified exception when failed.
    • result: None when unfinished; returns final result when completed.
  • Centralized response construction to avoid ad-hoc dict assembly.
  • OpenAPI:
    • Added shared components:
      • components.schemas.Handler: flattened, reusable handler response shape.
      • components.schemas.HandlersList: { handlers: Handler[] }.
    • Endpoint docstrings now reference $ref to the above, removing duplication.

Backward compatibility notes

  • Run-nowait clients should expect "status": "running" instead of "started".
  • Consumers of GET /results/{handler_id} on error (500) should parse a text/plain body (detailed error message) rather than a JSON object.

Testing

  • Updated server tests to reflect the above behavioral changes.
  • All server tests passing: 72 passed locally.

Migration/Deployment

  • No persistence or schema migrations needed.
  • No new configuration flags introduced.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/run-llama/workflows-py/pull/110 **Author:** [@zhaotai](https://github.com/zhaotai) **Created:** 9/23/2025 **Status:** ✅ Merged **Merged:** 9/23/2025 **Merged by:** [@zhaotai](https://github.com/zhaotai) **Base:** `main` ← **Head:** `feat/server-metadata-typed` --- ### 📝 Commits (4) - [`586b94f`](https://github.com/run-llama/workflows-py/commit/586b94fb93b4e9781163990952df3a2ba2ea5d38) server: return ISO 8601 timestamps (Z) for started_at/updated_at/completed_at and update OpenAPI to date-time format - [`23e7b4b`](https://github.com/run-llama/workflows-py/commit/23e7b4ba6ba99a72e70101697ecba52deb40c171) server: format timestamps with strftime('%Y-%m-%dT%H:%M:%SZ') for canonical ISO-8601Z output - [`e512310`](https://github.com/run-llama/workflows-py/commit/e5123107fdfbb6d9c6a6020d008e585ce32f9c69) tests(server): add datetime progression test for handler started_at/updated_at/completed_at - [`5366d41`](https://github.com/run-llama/workflows-py/commit/5366d41acc68292f4fee7ae0dd45fb59223a83c7) fix lint ### 📊 Changes **3 files changed** (+90 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `src/workflows/server/server.py` (+36 -29) 📝 `tests/server/test_server_endpoints.py` (+52 -1) 📝 `uv.lock` (+2 -2) </details> ### 📄 Description Summary - Add and surface flattened runtime handler metadata across server endpoints (no new endpoints). - Replace per-endpoint, hand-built dicts with a single source `to_dict()` on the server-side wrapper. - Consolidate OpenAPI schemas via shared components to remove duplication. - Update tests to reflect expected behavioral changes. API changes (intentional) - Flattened metadata fields are now included in these responses: - POST /workflows/{name}/run (200) - POST /workflows/{name}/run-nowait (200) - GET /results/{handler_id} (200, 202) - GET /handlers (200, each item) - Run-nowait response: - status was previously “started”; it now returns status: "running". - Get result error response: - GET /results/{handler_id} now returns a detailed error as text/plain on 500 (instead of a JSON object). Implementation details - Introduced server-side wrapper `_WorkflowHandler.to_dict()` returning a typed `HandlerDict`. - Safe accessors on `_WorkflowHandler`: - `status`: guards unfinished futures and maps to "running" | "completed" | "failed". - `error`: None when unfinished, stringified exception when failed. - `result`: None when unfinished; returns final result when completed. - Centralized response construction to avoid ad-hoc dict assembly. - OpenAPI: - Added shared components: - `components.schemas.Handler`: flattened, reusable handler response shape. - `components.schemas.HandlersList`: `{ handlers: Handler[] }`. - Endpoint docstrings now reference `$ref` to the above, removing duplication. Backward compatibility notes - Run-nowait clients should expect `"status": "running"` instead of `"started"`. - Consumers of GET /results/{handler_id} on error (500) should parse a text/plain body (detailed error message) rather than a JSON object. Testing - Updated server tests to reflect the above behavioral changes. - All server tests passing: 72 passed locally. Migration/Deployment - No persistence or schema migrations needed. - No new configuration flags introduced. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 02:16:40 -05:00
yindo closed this issue 2026-02-16 02:16:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/workflows-py#128