From 09a79d29de6d1bc40f2cc318d9bda7a1fcad5af7 Mon Sep 17 00:00:00 2001 From: Francisco Castillo Date: Mon, 21 Oct 2024 15:49:36 -0700 Subject: [PATCH 1/8] Add branch to dangerously experimental images --- .github/workflows/docker-build-experimental.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-build-experimental.yml b/.github/workflows/docker-build-experimental.yml index 566efd63cb..934451f823 100644 --- a/.github/workflows/docker-build-experimental.yml +++ b/.github/workflows/docker-build-experimental.yml @@ -4,6 +4,7 @@ on: push: branches: - sessions + - managed-phoenix/test jobs: push_to_registry: From af0698d8f878aa165aa6043fa9e1f3e011a0f9e5 Mon Sep 17 00:00:00 2001 From: Francisco Castillo Date: Mon, 21 Oct 2024 15:50:48 -0700 Subject: [PATCH 2/8] wip --- src/phoenix/server/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phoenix/server/main.py b/src/phoenix/server/main.py index 7d00094136..7a13cb6a60 100644 --- a/src/phoenix/server/main.py +++ b/src/phoenix/server/main.py @@ -75,7 +75,7 @@ _WELCOME_MESSAGE = Environment(loader=BaseLoader()).from_string(""" -██████╗ ██╗ ██╗ ██████╗ ███████╗███╗ ██╗██╗██╗ ██╗ +██████╗ ██╗ ██╗ ██████╗ ███████╗███╗ ██╗██╗██╗ ██╗ (managed by Arize) ██╔══██╗██║ ██║██╔═══██╗██╔════╝████╗ ██║██║╚██╗██╔╝ ██████╔╝███████║██║ ██║█████╗ ██╔██╗ ██║██║ ╚███╔╝ ██╔═══╝ ██╔══██║██║ ██║██╔══╝ ██║╚██╗██║██║ ██╔██╗ From bbeaa0156b7dc9914ed43f5548f018f94d06cd32 Mon Sep 17 00:00:00 2001 From: Francisco Castillo Date: Mon, 21 Oct 2024 16:18:40 -0700 Subject: [PATCH 3/8] Non Streaming response and logs --- src/phoenix/server/api/routers/v1/spans.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/phoenix/server/api/routers/v1/spans.py b/src/phoenix/server/api/routers/v1/spans.py index 37a7ef23d2..52c4d5778a 100644 --- a/src/phoenix/server/api/routers/v1/spans.py +++ b/src/phoenix/server/api/routers/v1/spans.py @@ -93,6 +93,10 @@ async def query_spans_handler( detail=f"Invalid query: {e}", status_code=HTTP_422_UNPROCESSABLE_ENTITY, ) + print(f"{queries=}\n\n") + print(f"{span_queries=}\n\n") + print(f"{project_name=}\n\n") + print(f"{end_time=}\n\n") async with request.app.state.db() as session: results = [] for query in span_queries: @@ -114,12 +118,13 @@ async def query_spans_handler( ) if not results: raise HTTPException(status_code=HTTP_404_NOT_FOUND) + print(f"{results=}\n\n") async def content() -> AsyncIterator[bytes]: for result in results: yield df_to_bytes(result) - return StreamingResponse( + return Response( content=content(), media_type="application/x-pandas-arrow", ) From 5da0de417e2b2a53f3b4db1fd6c92211f64b9e26 Mon Sep 17 00:00:00 2001 From: Francisco Castillo Date: Mon, 21 Oct 2024 16:27:37 -0700 Subject: [PATCH 4/8] Use Response if only one dataframe, stream otherwise --- src/phoenix/server/api/routers/v1/spans.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/phoenix/server/api/routers/v1/spans.py b/src/phoenix/server/api/routers/v1/spans.py index 52c4d5778a..827b2a487b 100644 --- a/src/phoenix/server/api/routers/v1/spans.py +++ b/src/phoenix/server/api/routers/v1/spans.py @@ -120,14 +120,21 @@ async def query_spans_handler( raise HTTPException(status_code=HTTP_404_NOT_FOUND) print(f"{results=}\n\n") - async def content() -> AsyncIterator[bytes]: - for result in results: - yield df_to_bytes(result) + if len(results) == 1: + return Response( + content=df_to_bytes(results[0]), + media_type="application/x-pandas-arrow", + ) + else: - return Response( - content=content(), - media_type="application/x-pandas-arrow", - ) + async def content() -> AsyncIterator[bytes]: + for result in results: + yield df_to_bytes(result) + + return StreamingResponse( + content=content(), + media_type="application/x-pandas-arrow", + ) @router.get("/spans", include_in_schema=False, deprecated=True) From 1bcdd2f039e9935fc320e8896b0e08d2b48d7348 Mon Sep 17 00:00:00 2001 From: Francisco Castillo Date: Mon, 21 Oct 2024 16:30:02 -0700 Subject: [PATCH 5/8] Print byte array --- src/phoenix/server/api/routers/v1/spans.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/phoenix/server/api/routers/v1/spans.py b/src/phoenix/server/api/routers/v1/spans.py index 827b2a487b..6650f952fc 100644 --- a/src/phoenix/server/api/routers/v1/spans.py +++ b/src/phoenix/server/api/routers/v1/spans.py @@ -121,6 +121,7 @@ async def query_spans_handler( print(f"{results=}\n\n") if len(results) == 1: + print(f"{df_to_bytes(results[0])=}\n\n") return Response( content=df_to_bytes(results[0]), media_type="application/x-pandas-arrow", From d39db82d927dbc513590f03b429e5f4db7d4c4d0 Mon Sep 17 00:00:00 2001 From: Francisco Castillo Date: Tue, 22 Oct 2024 14:15:16 -0700 Subject: [PATCH 6/8] Print headers --- src/phoenix/session/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/phoenix/session/client.py b/src/phoenix/session/client.py index 906dbecf41..e3de760e4c 100644 --- a/src/phoenix/session/client.py +++ b/src/phoenix/session/client.py @@ -193,6 +193,7 @@ def query_spans( raise ValueError(response.content.decode()) response.raise_for_status() source = BytesIO(response.content) + print(f"{response.headers=}") results = [] while True: try: From dc17edf3719c17727fd7207ddc4913453ea7db64 Mon Sep 17 00:00:00 2001 From: Francisco Castillo Date: Thu, 24 Oct 2024 10:12:18 -0700 Subject: [PATCH 7/8] Change media type to octet-stream --- src/phoenix/server/api/routers/v1/spans.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phoenix/server/api/routers/v1/spans.py b/src/phoenix/server/api/routers/v1/spans.py index 6650f952fc..b3b8c1f82e 100644 --- a/src/phoenix/server/api/routers/v1/spans.py +++ b/src/phoenix/server/api/routers/v1/spans.py @@ -134,7 +134,7 @@ async def content() -> AsyncIterator[bytes]: return StreamingResponse( content=content(), - media_type="application/x-pandas-arrow", + media_type="application/octet-stream", ) From 8a9f73d1c0788893e248453834890a277b77c495 Mon Sep 17 00:00:00 2001 From: Francisco Castillo Date: Thu, 24 Oct 2024 10:30:36 -0700 Subject: [PATCH 8/8] wip --- src/phoenix/server/api/routers/v1/spans.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/phoenix/server/api/routers/v1/spans.py b/src/phoenix/server/api/routers/v1/spans.py index b3b8c1f82e..b4d2a41019 100644 --- a/src/phoenix/server/api/routers/v1/spans.py +++ b/src/phoenix/server/api/routers/v1/spans.py @@ -120,22 +120,14 @@ async def query_spans_handler( raise HTTPException(status_code=HTTP_404_NOT_FOUND) print(f"{results=}\n\n") - if len(results) == 1: - print(f"{df_to_bytes(results[0])=}\n\n") - return Response( - content=df_to_bytes(results[0]), - media_type="application/x-pandas-arrow", - ) - else: - - async def content() -> AsyncIterator[bytes]: - for result in results: - yield df_to_bytes(result) + async def content() -> AsyncIterator[bytes]: + for result in results: + yield df_to_bytes(result) - return StreamingResponse( - content=content(), - media_type="application/octet-stream", - ) + return StreamingResponse( + content=content(), + media_type="application/octet-stream", + ) @router.get("/spans", include_in_schema=False, deprecated=True)