Skip to content
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

The client ( version 0.3.0) ignores the URL configuration parameter. #368

Closed
jdelacasa opened this issue Nov 17, 2024 · 4 comments
Closed
Labels
question Further information is requested

Comments

@jdelacasa
Copy link

Client machine: 192.168.1.12
Machine with control plane: 192.168.1.23

===== Script =====
import llama_deploy

apiserver_url = 'http://192.168.1.23:4501'

async def check_status(apiserver_url):
# Pass other config settings to the Client constructor
client = llama_deploy.Client(api_server_url=apiserver_url,
timeout=10
)
status = await client.apiserver.status()
logger.info(status)
yield status

(...)

Output:

(...)

File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 761, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://localhost:8000/sessions/create'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

@masci masci added this to Framework Nov 17, 2024
@masci
Copy link
Member

masci commented Nov 18, 2024

Hi @jdelacasa I see in the logs the error is for sessions/create but in the code you do client.apiserver.status(), could it be the error is actually in the parts of the script omitted?

@jdelacasa
Copy link
Author

yes sorry , the correct:

async def stream_events(apiserver_url, deployment_name, payload):
    
    client = llama_deploy.Client(api_server_url=apiserver_url,
                                timeout=10
                                )
    
    
    

    # Create a new session
    session = await client.core.sessions.create()

    task_id = await session.run_nowait(
        deployment_name, payload
    )


    async for event in session.get_task_result_stream(task_id):
        if "progress" in event:
            yield f'Workflow Progress: {event["progress"]}\n'


    final_result = await session.get_task_result(task_id)
    yield f'Final Result: {final_result}\n'

    # Clean up the session
    await client.core.sessions.delete(session.id)
    



return StreamingResponse(stream_events(apiserver_url, deployment_name, payload), media_type="application/octet-stream")

===============================0
output:

INFO: 127.0.0.1:37382 - "POST /sessions/create HTTP/1.1" 404 Not Found
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 113, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 715, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 74, in app
await response(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/responses.py", line 250, in call
async with anyio.create_task_group() as task_group:
File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 597, in aexit
raise exceptions[0]
File "/usr/local/lib/python3.11/site-packages/starlette/responses.py", line 253, in wrap
await func()
File "/usr/local/lib/python3.11/site-packages/starlette/responses.py", line 242, in stream_response
async for chunk in self.body_iterator:
File "/maarifa/maarifa-api/routes/workflow.py", line 451, in stream_events
session = await client.core.sessions.create()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/llama_deploy/client/models/core.py", line 162, in create
return await self._create()
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/llama_deploy/client/models/core.py", line 167, in _create
response = await self.client.request("POST", create_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/llama_deploy/client/base.py", line 30, in request
response.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 761, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://localhost:8000/sessions/create'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

@masci
Copy link
Member

masci commented Nov 20, 2024

@jdelacasa gotcha, you have to also pass the control_plane_url to the client, like this:

apiserver_url = "http://192.168.1.23:4501"
control_plane_url = "http://192.168.1.23:8000"

client = llama_deploy.Client(api_server_url=apiserver_url, control_plane_url=control_plane_url)

@masci masci added the question Further information is requested label Nov 20, 2024
@jdelacasa
Copy link
Author

jdelacasa commented Nov 20, 2024

Thanks, initially I also got a connection error,
I realized that the control_plane was also running at http:127.0.0.1:8000 by default and I had to put in my deployment.yml file:

control-plane:
port: 8000
host: "0.0.0.0"

it seems to work fine now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Archived in project
Development

No branches or pull requests

2 participants