-
Notifications
You must be signed in to change notification settings - Fork 84
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
Update generated client code #215
Conversation
54bd898
to
b758766
Compare
pyproject.toml
Outdated
loguru = "0.5.3" | ||
typing-extensions = ">=3.7.4" | ||
dnspython = ">=2.0.0" | ||
python-dateutil = ">=2.5.3" | ||
urllib3 = ">=1.21.1" | ||
urllib3 = "1.25.3" | ||
tqdm = ">=4.64.1" | ||
numpy = ">=1.22.0" | ||
grpcio = ">=1.44.0" | ||
grpc-gateway-protoc-gen-openapiv2 = "0.1.0" | ||
googleapis-common-protos = ">=1.53.0" | ||
lz4 = ">=3.1.3" | ||
protobuf = "~=3.20.0" | ||
aenum = "3.1.11" | ||
pydantic = "1.10.12" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and added dependencies to satisfy the requirements of the generated openapi code. Both have permissive open source licenses, so no issue there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could potentially use pydantic in a similar way to typebox in the TS client if we wanted to add better runtime validation and error handling, if I'm understanding things correctly.
|
||
@pytest.mark.skip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of black changes in this file, but all the tests are currently marked skip
because they can't pass until we overhaul configuration.
The urllib3_mock
we are depending on throws a lot of deprecation warnings and appears to be abandoned so we should figure out some other tool there if we need to do request mocking in the future. But in reality I don't think we need to mock requests at that level if we refactor our tests into either pure unit tests or real integration tests against a live environment.
@@ -6,210 +6,204 @@ | |||
import tempfile | |||
import os | |||
|
|||
|
|||
@pytest.fixture(autouse=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed references to project name from these config tests.
tests/unit/test_grpc_index.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think much changed inhere besides formatting.
import pinecone | ||
from pinecone import UpsertRequest, Vector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these imports to make the tests a bit less verbose.
chunks = [ | ||
[Vector(id="vec1", values=self.vals1, metadata=self.md1)], | ||
[Vector(id="vec2", values=self.vals2, metadata=self.md2)], | ||
] | ||
with pinecone.Index("example-index", pool_threads=30) as index: | ||
mocker.patch.object(index._vector_api, "upsert", autospec=True) | ||
|
||
# Send requests in parallel | ||
async_results = [ | ||
index.upsert(vectors=ids_vectors_chunk, namespace="ns", async_req=True) | ||
for ids_vectors_chunk in chunks | ||
index.upsert(vectors=ids_vectors_chunk, namespace="ns", async_req=True) for ids_vectors_chunk in chunks | ||
] | ||
# Wait for and retrieve responses (this raises in case of error) | ||
[async_result.get() for async_result in async_results] | ||
|
||
Endpoint.__call__.assert_any_call( | ||
index._vector_api.upsert, | ||
pinecone.UpsertRequest(vectors=[ | ||
pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), | ||
], | ||
namespace='ns'), | ||
async_req=True | ||
index._vector_api.upsert.assert_any_call( | ||
UpsertRequest( | ||
vectors=[ | ||
Vector(id="vec1", values=self.vals1, metadata=self.md1), | ||
], | ||
namespace="ns", | ||
), | ||
async_req=True, | ||
) | ||
|
||
Endpoint.__call__.assert_any_call( | ||
index._vector_api.upsert, | ||
pinecone.UpsertRequest(vectors=[ | ||
pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2), | ||
], | ||
namespace='ns'), | ||
async_req=True | ||
index._vector_api.upsert.assert_any_call( | ||
UpsertRequest( | ||
vectors=[ | ||
Vector(id="vec2", values=self.vals2, metadata=self.md2), | ||
], | ||
namespace="ns", | ||
), | ||
async_req=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was pretty heavily refactored to mock out at the vector_api level instead of reaching in to touch the Endpoint
internals, which got changed between v5 and v7 openapi versions.
import pytest | ||
import warnings | ||
|
||
from pinecone.core.client.api_client import Endpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This export is not available, and most substantive changes in this test file are to refactor away from depending on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, thank you.
@@ -6,10 +6,10 @@ function bumpVersion(currentVersion, bumpType, prerelease) { | |||
if (prerelease) { | |||
newVersion = `${newVersion}.${prerelease}`; | |||
} | |||
core.setOutput('previous_version', currentVersion) | |||
core.setOutput('previous_version_tag', `v${currentVersion}`) | |||
core.setOutput('previous_version', currentVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe black did this? Not really my intention, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, I think it was prettier / lint since it's a .js file. I had the same thing happen when I was working on workflows: https://github.com/pinecone-io/pinecone-python-client/pull/216/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all the work that went into getting the core regenerated and updated. Overall this looks good, it seems like we'll need a few tickets for follow-up here around re-enabling integration tests, and replacing urllib3
if needed for mocking.
It looks like the pdoc build is also failing due to a couple import related issues. I think this is due to it using dynamic analysis when extracting docstrings, so Python modules are executed/imported when it runs:
ModuleNotFoundError: No module named 'pinecone.core.client.model'
ImportError: cannot import name 'Endpoint' from 'pinecone.core.client.api_client' (/home/runner/work/pinecone-python-client/pinecone-python-client/pinecone/core/client/api_client.py)
I can pull things down and maybe take a look, we could also skip / disable for now since we're in a feature branch. I think this also still may need a rebase against origin/spruce
to pull in the workflow changes.
@@ -6,10 +6,10 @@ function bumpVersion(currentVersion, bumpType, prerelease) { | |||
if (prerelease) { | |||
newVersion = `${newVersion}.${prerelease}`; | |||
} | |||
core.setOutput('previous_version', currentVersion) | |||
core.setOutput('previous_version_tag', `v${currentVersion}`) | |||
core.setOutput('previous_version', currentVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, I think it was prettier / lint since it's a .js file. I had the same thing happen when I was working on workflows: https://github.com/pinecone-io/pinecone-python-client/pull/216/files
Makefile
Outdated
|
||
upload-spruce: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to add upload-spruce
to the .PHONY: ...
line at the top so it's callable.
from .config import * | ||
from .exceptions import * | ||
from .info import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Thanks for pulling these out. I had stripped them out of the docs as well because they're all internal and I don't think we expect external users to have access to these.
pyproject.toml
Outdated
loguru = "0.5.3" | ||
typing-extensions = ">=3.7.4" | ||
dnspython = ">=2.0.0" | ||
python-dateutil = ">=2.5.3" | ||
urllib3 = ">=1.21.1" | ||
urllib3 = "1.25.3" | ||
tqdm = ">=4.64.1" | ||
numpy = ">=1.22.0" | ||
grpcio = ">=1.44.0" | ||
grpc-gateway-protoc-gen-openapiv2 = "0.1.0" | ||
googleapis-common-protos = ">=1.53.0" | ||
lz4 = ">=3.1.3" | ||
protobuf = "~=3.20.0" | ||
aenum = "3.1.11" | ||
pydantic = "1.10.12" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could potentially use pydantic in a similar way to typebox in the TS client if we wanted to add better runtime validation and error handling, if I'm understanding things correctly.
import pytest | ||
import warnings | ||
|
||
from pinecone.core.client.api_client import Endpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, thank you.
tests/unit/test_index.py
Outdated
pinecone.init(api_key='example-key') | ||
self.index = pinecone.Index('example-name') | ||
|
||
def test_upsert_numpy_deprecation_warning(self, mocker): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Are we still planning on deprecating numpy? I've seen references to that in the codebase and this seems to confirm that.
If so we can probably add a ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should remove it before releasing spruce. I'll add a ticket.
@@ -15,8 +15,8 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be good for actually adding some documentation around the GRPC bits, thank you. 👍
0e79c67
to
199c7f4
Compare
Problem
We need to update the generated core module to reflect upcoming API changes
Solution
pinecone.core
using pinecone-protos (private) repo.pinecone.core
. These never should have been underpinecone.core
in the first place.pinecone.utils
pinecone.grpc
to holdGRPCIndex
and related code.pydantic
for typechecking,aenum
for enums)integ
tests which won't work until we refactor configuration.Type of Change