[PR #202] [MERGED] Make client more useful/up to date #315

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

📋 Pull Request Information

Original PR: https://github.com/run-llama/llama_deploy/pull/202
Author: @logan-markewich
Created: 8/26/2024
Status: Merged
Merged: 8/27/2024
Merged by: @logan-markewich

Base: v0.1.0Head: logan/client_update


📝 Commits (7)

📊 Changes

7 files changed (+483 additions, -173 deletions)

View changed files

📝 llama_agents/client/async_client.py (+185 -70)
📝 llama_agents/client/sync_client.py (+183 -71)
📝 llama_agents/control_plane/base.py (+10 -0)
📝 llama_agents/control_plane/server.py (+60 -6)
📝 llama_agents/orchestrators/simple.py (+39 -23)
llama_agents/orchestrators/utils.py (+2 -0)
📝 tests/orchestrators/test_simple_orchestrator.py (+4 -3)

📄 Description

This PR

  • re-implementes the clients (async and sync) to match the latest control plane endpints
  • introduces a session-based client to make API calls and session separation clearer

Unknown:

  • I'd love to add unit tests for the client, but I'm not sure how to do this without mocking out the entire control plane API 😢

Test Code

launch_core.py

from llama_agents import deploy_core, ControlPlaneConfig, SimpleMessageQueueConfig

async def main():
    await deploy_core(
        ControlPlaneConfig(),
        SimpleMessageQueueConfig(),
    )

if __name__ == "__main__":
    import asyncio

    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

launch_workflow.py

from llama_index.core.workflow import Workflow, StartEvent, StopEvent, step

class MyWorkflow(Workflow):

    @step()
    async def run_step(self, ev: StartEvent) -> StopEvent:
        arg1 = ev.get("arg1")
        if not arg1:
            raise ValueError("arg1 is required.")

        return StopEvent(result=str(arg1) + "_result")


from llama_agents import deploy_workflow, ControlPlaneConfig, SimpleMessageQueueConfig, WorkflowServiceConfig

async def main():
    await deploy_workflow(
        MyWorkflow(),
        WorkflowServiceConfig(host="127.0.0.1", port=8002, service_name="my_workflow"),
        ControlPlaneConfig(),
        SimpleMessageQueueConfig(),
    )

if __name__ == "__main__":
    import asyncio
    
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

test_client.py

from llama_agents import LlamaAgentsClient

# points to control plane URL
client = LlamaAgentsClient(ControlPlaneConfig())

session = client.create_session()
result = session.run("my_workflow", arg1="hello_world")
print(result)
> 'hello_world_result'

🔄 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/llama_deploy/pull/202 **Author:** [@logan-markewich](https://github.com/logan-markewich) **Created:** 8/26/2024 **Status:** ✅ Merged **Merged:** 8/27/2024 **Merged by:** [@logan-markewich](https://github.com/logan-markewich) **Base:** `v0.1.0` ← **Head:** `logan/client_update` --- ### 📝 Commits (7) - [`1715c1c`](https://github.com/run-llama/llama_deploy/commit/1715c1cb7aa9cb5ba910f2f8a7406adce2b46323) add sync and async client/sessions - [`253702b`](https://github.com/run-llama/llama_deploy/commit/253702b5a9ab6c2731fe88e0fd77cbe394f71953) fix orchestrator tests - [`554b4e1`](https://github.com/run-llama/llama_deploy/commit/554b4e1df313acba4cb83840046b90b371966f51) attempt at tests - [`c74d827`](https://github.com/run-llama/llama_deploy/commit/c74d827aa717e362d67fab39a3b35ba230ca853b) add wait_for - [`4844204`](https://github.com/run-llama/llama_deploy/commit/4844204dfeffac1e8253684e10210475571c559f) log debug sanity check - [`2134509`](https://github.com/run-llama/llama_deploy/commit/2134509eeb1c0979a930eb2a67f138e157b6da5e) pass in config - [`a78ee29`](https://github.com/run-llama/llama_deploy/commit/a78ee29fb28bc4a0de25c5658f157cd7cc9e83ff) remove broken tests ### 📊 Changes **7 files changed** (+483 additions, -173 deletions) <details> <summary>View changed files</summary> 📝 `llama_agents/client/async_client.py` (+185 -70) 📝 `llama_agents/client/sync_client.py` (+183 -71) 📝 `llama_agents/control_plane/base.py` (+10 -0) 📝 `llama_agents/control_plane/server.py` (+60 -6) 📝 `llama_agents/orchestrators/simple.py` (+39 -23) ➕ `llama_agents/orchestrators/utils.py` (+2 -0) 📝 `tests/orchestrators/test_simple_orchestrator.py` (+4 -3) </details> ### 📄 Description This PR - re-implementes the clients (async and sync) to match the latest control plane endpints - introduces a session-based client to make API calls and session separation clearer Unknown: - I'd love to add unit tests for the client, but I'm not sure how to do this without mocking out the entire control plane API 😢 ## Test Code ### `launch_core.py` ```python from llama_agents import deploy_core, ControlPlaneConfig, SimpleMessageQueueConfig async def main(): await deploy_core( ControlPlaneConfig(), SimpleMessageQueueConfig(), ) if __name__ == "__main__": import asyncio loop = asyncio.get_event_loop() loop.run_until_complete(main()) ``` ### `launch_workflow.py` ```python from llama_index.core.workflow import Workflow, StartEvent, StopEvent, step class MyWorkflow(Workflow): @step() async def run_step(self, ev: StartEvent) -> StopEvent: arg1 = ev.get("arg1") if not arg1: raise ValueError("arg1 is required.") return StopEvent(result=str(arg1) + "_result") from llama_agents import deploy_workflow, ControlPlaneConfig, SimpleMessageQueueConfig, WorkflowServiceConfig async def main(): await deploy_workflow( MyWorkflow(), WorkflowServiceConfig(host="127.0.0.1", port=8002, service_name="my_workflow"), ControlPlaneConfig(), SimpleMessageQueueConfig(), ) if __name__ == "__main__": import asyncio loop = asyncio.get_event_loop() loop.run_until_complete(main()) ``` ### `test_client.py` ```python from llama_agents import LlamaAgentsClient # points to control plane URL client = LlamaAgentsClient(ControlPlaneConfig()) session = client.create_session() result = session.run("my_workflow", arg1="hello_world") print(result) > 'hello_world_result' ``` --- <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 01:16:51 -05:00
yindo closed this issue 2026-02-16 01:16:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_deploy#315