Skip to content

Commit

Permalink
Adjust warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Sep 17, 2024
1 parent 4864f8d commit 31ee39a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
12 changes: 7 additions & 5 deletions pinecone/data/features/bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def __init__(self, **kwargs):
api_version=API_VERSION,
)

@prerelease_feature(message="The bulk import feature is in pre-release.", 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 @@ -89,7 +91,7 @@ def start_import(

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

@prerelease_feature(message="The bulk import feature is in pre-release.", api_version=API_VERSION)
@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 @@ -126,7 +128,7 @@ def list_imports(self, **kwargs) -> Iterator[List[ImportModel]]:
else:
done = True

@prerelease_feature(message="The bulk import feature is in pre-release.", api_version=API_VERSION)
@prerelease_feature(message=usage_warning, api_version=API_VERSION)
def list_imports_paginated(
self,
limit: Optional[int] = None,
Expand Down Expand Up @@ -171,7 +173,7 @@ def list_imports_paginated(
)
return self.__import_operations_api.list_imports(**args_dict)

@prerelease_feature(message="The bulk import feature is in pre-release.", api_version=API_VERSION)
@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 @@ -188,7 +190,7 @@ def describe_import(self, id: str) -> ImportModel:

return self.__import_operations_api.describe_import(id=id)

@prerelease_feature(message="The bulk import feature is in pre-release.", api_version=API_VERSION)
@prerelease_feature(message=usage_warning, api_version=API_VERSION)
def cancel_import(self, id: str):
"""Cancel an import operation.
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/data/test_bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_start_import_minimal(self, mocker):
"""
client, mock_req = build_client_w_faked_response(mocker, body)

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

# We made some overrides to the print behavior, so we need to
Expand All @@ -56,7 +56,7 @@ def test_start_import_with_kwargs(self, mocker):
"""
client, mock_req = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="pre-release"):
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"
Expand Down Expand Up @@ -87,7 +87,7 @@ 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="pre-release"):
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"}}'
Expand All @@ -100,7 +100,7 @@ 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="pre-release"):
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"}}'
Expand All @@ -113,7 +113,7 @@ 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="pre-release"):
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")

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

with pytest.warns(UserWarning, match="pre-release"):
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")

Expand All @@ -140,7 +140,7 @@ 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="pre-release"):
with pytest.warns(UserWarning, match="The bulk import feature is in early access"):
with pytest.raises(TypeError) as e:
client.start_import()

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

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

# We made some overrides to the print behavior, so we need to
Expand Down

0 comments on commit 31ee39a

Please sign in to comment.