Repository: run-llama/llama_deploy

Issue:
error running llama_deploy basic example
I was trying to run the basic [llama_deploy example](https://docs.llamaindex.ai/en/stable/module_guides/llama_deploy/30_manual_orchestration/#running-the-core-system) but I ran into an error after trying to stream events. 

I deployed core, the message queue and the workflow per the URL. Then I tried interacting with the deployment using the code example in the link:

```
from llama_deploy import Client, ControlPlaneConfig
client = Client(control_plane_url="http://localhost:8000")

async def run_task_and_stream():
    # create a session
    session = await client.core.sessions.create()

    # kick off task run
    task_id = session.run_nowait("my_workflow", arg="Hello Streaming!")

    # stream events
    async for event in session.get_task_result_stream(task_id):
        print(event)

    # get final result
    final_result = await session.get_task_result(task_id)

    print(final_result.result)
    # prints 'Hello Streaming! result'
```
The error I faced was at the `async for event in session.get_task_result_stream(task_id):`. The error is:
`HTTPStatusError: Client error '404 Not Found' for url 'http://localhost:8000/sessions/e1fdf52b-ec50-4591-8bae-66292d18b480/tasks/%3Ccoroutine%20object%20Session.run_nowait%20at%200x12eaf4400%3E/result_stream'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404`

I debugged further and found that my task_id is a coroutine object (`<coroutine object Session.run_nowait at 0x12eaf4400>`). Not too sure if there's something I did wrong?

1. deploy_core.py
```
from llama_deploy import (
    deploy_core,
    ControlPlaneConfig,
    SimpleMessageQueueConfig
)

control_plane_config = ControlPlaneConfig()
message_queue_config = SimpleMessageQueueConfig()

if __name__ == "__main__":
    import asyncio

    asyncio.run(
        deploy_core(
            control_plane_config=control_plane_config,
            message_queue_config=message_queue_config,
        )
    )
```

2. deploy_workflow.py
```
from llama_deploy import (
    deploy_workflow,
    WorkflowServiceConfig,
    ControlPlaneConfig,
)
from llama_index.core.workflow import (
    Context,
    Event,
    Workflow,
    StartEvent,
    StopEvent,
    step,
)


class ProgressEvent(Event):
    progress: str


# create a dummy workflow
class MyWorkflow(Workflow):
    @step()
    async def run_step(self, ctx: Context, ev: StartEvent) -> StopEvent:
        # Your workflow logic here
        arg1 = str(ev.get("arg1", ""))
        result = arg1 + " result"

        # stream events as steps run
        ctx.write_event_to_stream(
            ProgressEvent(progress="I am doing something!")
        )

        return StopEvent(result=result)


async def main():
    # This will run forever until you interrupt the process, like by pressing CTRL+C
    await deploy_workflow(
        workflow=MyWorkflow(),
        workflow_config=WorkflowServiceConfig(
            host="127.0.0.1", port=8002, service_name="my_workflow"
        ),
        control_plane_config=ControlPlaneConfig(),
    )


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())
```



Discussion:
Hi @masci , I am facing the same issue when i follow the code in the documentation. Please help to share the workaround. Thank you..
There were a couple of bugs in that docs page, see the diff here https://github.com/run-llama/llama_deploy/pull/500
Thanks for reporting!



Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ca027ea8..633c4ba1 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -4,7 +4,7 @@ default_language_version:
 
 repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v4.5.0
+    rev: v5.0.0
     hooks:
       - id: check-byte-order-marker
       - id: check-merge-conflict
@@ -26,7 +26,7 @@ repos:
       - id: ruff-format
 
   - repo: https://github.com/pre-commit/mirrors-mypy
-    rev: v1.11.2
+    rev: v1.15.0
     hooks:
       - id: mypy
         additional_dependencies:
@@ -41,6 +41,7 @@ repos:
             "types-redis",
             "types-requests",
             "types-setuptools",
+            "types-click",
           ]
         args:
           [
diff --git a/docs/docs/module_guides/llama_deploy/30_manual_orchestration.md b/docs/docs/module_guides/llama_deploy/30_manual_orchestration.md
index 314f7f4a..2fd9c4d2 100644
--- a/docs/docs/module_guides/llama_deploy/30_manual_orchestration.md
+++ b/docs/docs/module_guides/llama_deploy/30_manual_orchestration.md
@@ -75,8 +75,8 @@ class MyWorkflow(Workflow):
     @step()
     async def run_step(self, ctx: Context, ev: StartEvent) -> StopEvent:
         # Your workflow logic here
-        arg1 = str(ev.get("arg1", ""))
-        result = arg1 + " result"
+        arg = str(ev.get("arg", ""))
+        result = arg + " result"
 
         # stream events as steps run
         ctx.write_event_to_stream(
@@ -133,7 +133,7 @@ async def run_task_and_stream():
     session = await c1.core.sessions.create()
 
     # kick off task run
-    task_id = session.run_nowait("my_workflow", arg="Hello Streaming!")
+    task_id = await session.run_nowait("my_workflow", arg="Hello Streaming!")
 
     # stream events
     async for event in session.get_task_result_stream(task_id):
diff --git a/llama_deploy/cli/config.py b/llama_deploy/cli/config.py
index cca99c82..952d90ac 100644
--- a/llama_deploy/cli/config.py
+++ b/llama_deploy/cli/config.py
@@ -24,7 +24,7 @@ def _strtobool(val: str) -> bool:
         raise ValueError("invalid truth value %r" % (val,))
 
 
-@click.group
+@click.group()
 @click.pass_context
 def config(ctx: click.Context) -> None:
     """Manage configuration profiles and settings.
diff --git a/llama_deploy/cli/sessions.py b/llama_deploy/cli/sessions.py
index 8b43fa9f..90f20061 100644
--- a/llama_deploy/cli/sessions.py
+++ b/llama_deploy/cli/sessions.py
@@ -5,7 +5,7 @@
 from .internal.config import ConfigProfile
 
 
-@click.group
+@click.group()
 def sessions() -> None:
     """Manage sessions for a given deployment."""
     pass


Test patch:
diff --git a/tests/cli/conftest.py b/tests/cli/conftest.py
index 40b5d671..65de13d1 100644
--- a/tests/cli/conftest.py
+++ b/tests/cli/conftest.py
@@ -1,17 +1,19 @@
 import shutil
 from pathlib import Path
-from typing import IO, Any, Mapping, Optional, Sequence, Union
+from typing import IO, TYPE_CHECKING, Any, Mapping, Optional, Sequence, Union
 
 import pytest
-from click import BaseCommand
 from click.testing import CliRunner, Result
 
+if TYPE_CHECKING:
+    from click.core import BaseCommand
+
 
 class ConfigCliRunner(CliRunner):
     tests_data_path: Path
     temp_config: Path
 
-    def invoke(
+    def invoke(  # type: ignore
         self,
         cli: "BaseCommand",
         args: Optional[Union[str, Sequence[str]]] = None,
@@ -29,7 +31,7 @@ def invoke(
         else:
             args = ["-c", str(self.temp_config)] + list(args)
 
-        return super().invoke(cli, args, input, env, catch_exceptions, color, **extra)
+        return super().invoke(cli, args, input, env, catch_exceptions, color, **extra)  # type: ignore
 
 
 @pytest.fixture