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

feat: Update API for OpenAPI compliance #2866

Merged
merged 5 commits into from
Apr 13, 2024

Conversation

anticorrelator
Copy link
Contributor

@anticorrelator anticorrelator commented Apr 11, 2024

  • Preserves existing API behavior, but adds an OpenAPI spec which better follows REST conventions

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Apr 11, 2024
@anticorrelator anticorrelator changed the title feat: Update API for OpenAPI compliance feat!: Update API for OpenAPI compliance Apr 11, 2024
src/phoenix/server/api/routers/v1/evaluations.py Outdated Show resolved Hide resolved
src/phoenix/server/api/routers/v1/evaluations.py Outdated Show resolved Hide resolved
src/phoenix/server/api/routers/v1/evaluations.py Outdated Show resolved Hide resolved
src/phoenix/server/app.py Outdated Show resolved Hide resolved
src/phoenix/server/api/routers/v1/spans.py Outdated Show resolved Hide resolved
src/phoenix/server/api/routers/v1/spans.py Outdated Show resolved Hide resolved
tests/session/test_client.py Show resolved Hide resolved
@mikeldking
Copy link
Contributor

Put deprecated flags on the get calls

Flesh out V2 API

Lint and clean up type annotations
Remove busywait

Swap out v2 routes for v1 routes!

Update Client API usage

Fill out get_spans body schema

Change reading spans from GET to POST

Update tests for new `/spans` route method

Update more tests for new `/spans` route method
@mikeldking mikeldking force-pushed the dustin/openapi-compliance-with-persistence branch from aa6fe6f to 8567699 Compare April 12, 2024 18:40
@anticorrelator anticorrelator changed the title feat!: Update API for OpenAPI compliance feat: Update API for OpenAPI compliance Apr 12, 2024
Comment on lines +66 to +67
# read from headers for backwards compatibility
or request.headers.get("project-name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to write a small thest for this?

Comment on lines 6 to 10
Route("/v1/evaluations", evaluations.post_evaluation, methods=["POST"]),
Route("/v1/evaluations", evaluations.get_evaluations, methods=["GET"]),
Route("/v1/traces", traces.post_traces, methods=["POST"]),
Route("/v1/spans", spans.query_spans_handler, methods=["POST"]),
Route("/v1/spans", spans.get_spans_handler, methods=["GET"]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no nested routing? NBD, just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure everything we can accomplish here, this was the pattern I saw recommended to use Starlette's OpenAPI APISpec mechanism, since we want a separate function for each route

Copy link
Contributor

@mikeldking mikeldking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might have inconsistent project-name vs project_name?


async def get_evaluations(request: Request) -> Response:
"""
summary: Get evaluations from Phoenix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
summary: Get evaluations from Phoenix
summary: Get evaluations for a given project

@@ -183,13 +183,13 @@ def log_evaluations(self, *evals: Evaluations, project_name: Optional[str] = Non
table = evaluation.to_pyarrow_table()
sink = pa.BufferOutputStream()
headers = {"content-type": "application/x-pandas-arrow"}
if project_name:
headers["project-name"] = project_name
params = {"project-name": project_name}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? because I think it's _ in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, replacing with project-name everywhere

Copy link
Contributor

@mikeldking mikeldking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock

@anticorrelator anticorrelator merged commit 0db65d8 into sql Apr 13, 2024
11 checks passed
@anticorrelator anticorrelator deleted the dustin/openapi-compliance-with-persistence branch April 13, 2024 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants