Skip to content

Commit

Permalink
Remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Sep 17, 2024
1 parent b19cce2 commit 5711249
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 95 deletions.
8 changes: 0 additions & 8 deletions pinecone/data/features/bulk_import.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from enum import Enum
from typing import Optional, Literal, Iterator, List, Type, cast

from pinecone.utils.decorators import prerelease_feature
from pinecone.config.config import ConfigBuilder
from pinecone.core_ea.openapi.db_data import ApiClient
from pinecone.core_ea.openapi.db_data.api.bulk_operations_api import BulkOperationsApi
Expand Down Expand Up @@ -44,9 +43,6 @@ def __init__(self, **kwargs):
api_version=API_VERSION,
)

usage_warning = "The bulk import feature is in early access."

@prerelease_feature(message=usage_warning, api_version=API_VERSION)
def start_import(
self,
uri: str,
Expand Down Expand Up @@ -90,7 +86,6 @@ def start_import(

return self.__import_operations_api.start_import(StartImportRequest(**args_dict))

@prerelease_feature(message=usage_warning, api_version=API_VERSION)
def list_imports(self, **kwargs) -> Iterator[List[ImportModel]]:
"""
Returns a generator that yields each import operation. It automatically handles pagination tokens on your behalf so you can
Expand Down Expand Up @@ -127,7 +122,6 @@ def list_imports(self, **kwargs) -> Iterator[List[ImportModel]]:
else:
done = True

@prerelease_feature(message=usage_warning, api_version=API_VERSION)
def list_imports_paginated(
self,
limit: Optional[int] = None,
Expand Down Expand Up @@ -172,7 +166,6 @@ def list_imports_paginated(
)
return self.__import_operations_api.list_imports(**args_dict)

@prerelease_feature(message=usage_warning, api_version=API_VERSION)
def describe_import(self, id: str) -> ImportModel:
"""
describe_import is used to get detailed information about a specific import operation.
Expand All @@ -189,7 +182,6 @@ def describe_import(self, id: str) -> ImportModel:

return self.__import_operations_api.describe_import(id=id)

@prerelease_feature(message=usage_warning, api_version=API_VERSION)
def cancel_import(self, id: str):
"""Cancel an import operation.
Expand Down
1 change: 0 additions & 1 deletion pinecone/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
from .parse_args import parse_non_empty_args
from .docslinks import docslinks
from .repr_overrides import install_json_repr_override
from .decorators import prerelease_feature
34 changes: 0 additions & 34 deletions pinecone/utils/decorators.py

This file was deleted.

95 changes: 43 additions & 52 deletions tests/unit/data/test_bulk_import.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
import warnings

from urllib3 import BaseHTTPResponse

Expand Down Expand Up @@ -36,17 +35,16 @@ def test_start_import_minimal(self, mocker):
"""
client, mock_req = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
my_import = client.start_import("s3://path/to/file.parquet")
my_import = client.start_import("s3://path/to/file.parquet")

# We made some overrides to the print behavior, so we need to
# call it to ensure it doesn't raise an exception
print(my_import)
# We made some overrides to the print behavior, so we need to
# call it to ensure it doesn't raise an exception
print(my_import)

assert my_import.id == "1"
assert my_import["id"] == "1"
assert my_import.to_dict() == {"id": "1"}
assert my_import.__class__ == StartImportResponse
assert my_import.id == "1"
assert my_import["id"] == "1"
assert my_import.to_dict() == {"id": "1"}
assert my_import.__class__ == StartImportResponse

def test_start_import_with_kwargs(self, mocker):
body = """
Expand All @@ -56,19 +54,18 @@ def test_start_import_with_kwargs(self, mocker):
"""
client, mock_req = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
my_import = client.start_import(uri="s3://path/to/file.parquet", integration_id="123-456-789")
assert my_import.id == "1"
assert my_import["id"] == "1"
assert my_import.to_dict() == {"id": "1"}
assert my_import.__class__ == StartImportResponse
my_import = client.start_import(uri="s3://path/to/file.parquet", integration_id="123-456-789")
assert my_import.id == "1"
assert my_import["id"] == "1"
assert my_import.to_dict() == {"id": "1"}
assert my_import.__class__ == StartImportResponse

# By default, use continue error mode
_, call_kwargs = mock_req.call_args
assert (
call_kwargs["body"]
== '{"uri": "s3://path/to/file.parquet", "integrationId": "123-456-789", "errorMode": {"onError": "continue"}}'
)
# By default, use continue error mode
_, call_kwargs = mock_req.call_args
assert (
call_kwargs["body"]
== '{"uri": "s3://path/to/file.parquet", "integrationId": "123-456-789", "errorMode": {"onError": "continue"}}'
)

@pytest.mark.parametrize(
"error_mode_input",
Expand All @@ -87,10 +84,9 @@ def test_start_import_with_explicit_error_mode(self, mocker, error_mode_input):
"""
client, mock_req = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
my_import = client.start_import(uri="s3://path/to/file.parquet", error_mode=error_mode_input)
_, call_kwargs = mock_req.call_args
assert call_kwargs["body"] == '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "continue"}}'
my_import = client.start_import(uri="s3://path/to/file.parquet", error_mode=error_mode_input)
_, call_kwargs = mock_req.call_args
assert call_kwargs["body"] == '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "continue"}}'

def test_start_import_with_abort_error_mode(self, mocker):
body = """
Expand All @@ -100,10 +96,9 @@ def test_start_import_with_abort_error_mode(self, mocker):
"""
client, mock_req = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
my_import = client.start_import(uri="s3://path/to/file.parquet", error_mode=ImportErrorMode.ABORT)
_, call_kwargs = mock_req.call_args
assert call_kwargs["body"] == '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "abort"}}'
my_import = client.start_import(uri="s3://path/to/file.parquet", error_mode=ImportErrorMode.ABORT)
_, call_kwargs = mock_req.call_args
assert call_kwargs["body"] == '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "abort"}}'

def test_start_import_with_unknown_error_mode(self, mocker):
body = """
Expand All @@ -113,11 +108,10 @@ def test_start_import_with_unknown_error_mode(self, mocker):
"""
client, mock_req = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
with pytest.raises(ValueError) as e:
my_import = client.start_import(uri="s3://path/to/file.parquet", error_mode="unknown")
with pytest.raises(ValueError) as e:
my_import = client.start_import(uri="s3://path/to/file.parquet", error_mode="unknown")

assert "Invalid error_mode value: unknown" in str(e.value)
assert "Invalid error_mode value: unknown" in str(e.value)

def test_start_invalid_uri(self, mocker):
body = """
Expand All @@ -129,9 +123,8 @@ def test_start_invalid_uri(self, mocker):
"""
client, mock_req = build_client_w_faked_response(mocker, body, 400)

with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
with pytest.raises(PineconeApiException) as e:
my_import = client.start_import(uri="invalid path")
with pytest.raises(PineconeApiException) as e:
my_import = client.start_import(uri="invalid path")

assert e.value.status == 400
assert e.value.body == body
Expand All @@ -140,9 +133,8 @@ def test_start_invalid_uri(self, mocker):
def test_no_arguments(self, mocker):
client, mock_req = build_client_w_faked_response(mocker, "")

with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
with pytest.raises(TypeError) as e:
client.start_import()
with pytest.raises(TypeError) as e:
client.start_import()

assert "missing 1 required positional argument" in str(e.value)

Expand All @@ -165,17 +157,16 @@ def test_describe_import(self, mocker):
"""
client, mock_req = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
my_import = client.describe_import(id="1")
my_import = client.describe_import(id="1")

# We made some overrides to the print behavior, so we need to
# call it to ensure it doesn't raise an exception
print(my_import)
# We made some overrides to the print behavior, so we need to
# call it to ensure it doesn't raise an exception
print(my_import)

assert my_import.id == "1"
assert my_import["id"] == "1"
desc = my_import.to_dict()
assert desc["id"] == "1"
assert desc["records_imported"] == 1000
assert desc["uri"] == "s3://path/to/file.parquet"
assert desc["status"] == "InProgress"
assert my_import.id == "1"
assert my_import["id"] == "1"
desc = my_import.to_dict()
assert desc["id"] == "1"
assert desc["records_imported"] == 1000
assert desc["uri"] == "s3://path/to/file.parquet"
assert desc["status"] == "InProgress"

0 comments on commit 5711249

Please sign in to comment.