-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] Add send event endpoints to api server #412
Conversation
@@ -90,7 +90,7 @@ async def test_session_collection_list(client: Any) -> None: | |||
@pytest.mark.asyncio | |||
async def test_task_results(client: Any) -> None: | |||
res = TaskResult(task_id="a_result", history=[], result="some_text", data={}) | |||
client.request.return_value = mock.MagicMock(json=lambda: res.model_dump_json()) | |||
client.request.return_value = mock.MagicMock(json=lambda: res.model_dump()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we had this incorrectly mocked on the basis that httpx.Response.json()
returns a dict
rather than a str
.
I ran into this error when running the new hitl e2e test and the TaskResult
was failing Pydantic's validation. The modification made in this PR resolves it.
(The naming on Pydantic is confusing... model_dump
works with dict
and model_dump_json
works with str
.)
@@ -109,6 +109,18 @@ async def send_event(self, service_name: str, task_id: str, ev: Event) -> None: | |||
url = f"{self.client.control_plane_url}/sessions/{self.id}/tasks/{task_id}/send_event" | |||
await self.client.request("POST", url, json=event_def.model_dump()) | |||
|
|||
async def send_event_def(self, task_id: str, ev_def: EventDefinition) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I needed to add this in order for the apiserver to be able to just forward along an EventDefinition
to the WorkflowService
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the extra comments, LGTM!
This PR adds a new endpoint in api server allowing users to post a new
Event
that gets sent to a running workflow of a specified deployment.I've also added the
send_event()
method to theTask
apiserver/model class.