Skip to content

Conversation

@GeLi2001
Copy link
Contributor

@GeLi2001 GeLi2001 commented Aug 22, 2025

#9057
one more pr for edit dataset example to resolve the issue

@github-project-automation github-project-automation bot moved this to 📘 Todo in phoenix Aug 22, 2025
@GeLi2001 GeLi2001 changed the title enhance: phoenix-client-py delete example from dataset feat: phoenix-client-py delete example from dataset Aug 22, 2025
@GeLi2001 GeLi2001 marked this pull request as ready for review August 22, 2025 16:31
@GeLi2001 GeLi2001 requested a review from a team as a code owner August 22, 2025 16:31
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 22, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not use mocks. Update the integration tests in Phoenix instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it, updated integration test instead

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need these mocked tests if we have the IT?

from io import BytesIO
from pathlib import Path
from typing import TYPE_CHECKING, Any, BinaryIO, Iterator, Literal, Optional, Union
from typing import TYPE_CHECKING, Any, BinaryIO, Iterator, List, Literal, Optional, Union
Copy link
Contributor

Choose a reason for hiding this comment

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

As of Python 3.9, you can use list as a type hint, no need to import List from typing.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@GeLi2001 GeLi2001 requested a review from a team as a code owner August 28, 2025 07:16
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 28, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 28, 2025

Open in StackBlitz

npm i https://pkg.pr.new/Arize-ai/phoenix/@arizeai/phoenix-client@9193
npm i https://pkg.pr.new/Arize-ai/phoenix/@arizeai/phoenix-mcp@9193

commit: a888ef1

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@axiomofjoy axiomofjoy left a comment

Choose a reason for hiding this comment

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

It looks good, would just adjust the route to use a DELETE method and think about nixing those mocked tests if we have sufficient coverage from the integration test since mocks tend to be difficult to maintain.

Small nits: It looks like some of the type hints have unnecessary quotes ("Union[str, List[str]]" can just be Union[str, list[str]]). Some of the comments feel verbose.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need these mocked tests if we have the IT?

cursor[bot]

This comment was marked as outdated.

@GeLi2001 GeLi2001 force-pushed the enhance/phxclient-delete-dataset-example branch from 43cea27 to 55b8118 Compare September 4, 2025 00:39
if version_metadata is not None:
payload["version_metadata"] = version_metadata

response = self._client.delete(
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an HTTP method inconsistency between the sync and async implementations. The sync client uses self._client.delete() (line 1104) while the async client uses self._client.post() (line 1851). Since the OpenAPI specification defines this endpoint with the DELETE method, the async implementation should be updated to use delete() instead of post() for consistency with both the sync implementation and the API specification.

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

rest_response = Mock()
rest_response.raise_for_status.return_value = None

mock_datasets_client._client.post.return_value = rest_response
Copy link
Contributor

Choose a reason for hiding this comment

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

The test is mocking _client.post() but the implementation uses _client.request() with method='DELETE'. This mismatch will cause the test to fail. The mock setup should be changed to:

mock_datasets_client._client.request.return_value = rest_response

Additionally, when verifying the call, the assertions should check request() was called with the correct parameters including method='DELETE'.

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

assert call_args[1]["url"] == "v1/datasets/examples/delete"

# Verify payload structure (REST format)
payload = call_args[1]["json"]
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a mismatch between the test and implementation. The test expects the request payload to be accessible via call_args[1]["json"], but the actual implementation in delete_examples() sends the data using content=json.dumps(payload) with a Content-Type header. This will cause a KeyError when the test runs.

To fix this, either:

  1. Update the test to parse the JSON content from call_args[1]["content"], or
  2. Update the mock setup to properly capture how the request is being made

The test should align with how the client actually makes the request to ensure proper validation.

Suggested change
payload = call_args[1]["json"]
payload = json.loads(call_args[1]["content"])

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

)

await session.commit()

Copy link

Choose a reason for hiding this comment

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

Bug: Validation and Revision Check Issues

The deleteDatasetExamples endpoint has two issues. It doesn't fully validate that all provided example IDs exist, which can lead to foreign key errors during batch insert for non-existent IDs. Additionally, the check for already deleted examples incorrectly looks for any DELETE revision instead of the most recent one, preventing deletion of examples that were previously deleted and then re-added.

Fix in Cursor Fix in Web

@GeLi2001 GeLi2001 marked this pull request as draft October 7, 2025 15:51
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

Status: 📘 Todo

Development

Successfully merging this pull request may close these issues.

4 participants