Skip to content

Add bulk import #386

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

Merged
merged 27 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Some operationId > id fixes
  • Loading branch information
jhamon committed Sep 17, 2024
commit fe7f93fa72adc4b45caab6f5a7a30cd1783dc1fc
2 changes: 2 additions & 0 deletions pinecone/config/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def build(cls, api_key: str, host: Optional[str] = None, **kwargs):
openapi_config.host = host
openapi_config.ssl_ca_cert = certifi.where()
openapi_config.socket_options = cls._get_socket_options()
openapi_config.discard_unknown_keys = True
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Discovered this along the way. Seems like a better default behavior than erroring when unexpected data is returned.

Copy link

Choose a reason for hiding this comment

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

Looks sweet

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch


return openapi_config

@classmethod
Expand Down
12 changes: 6 additions & 6 deletions pinecone/data/features/bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,24 @@ def list_imports_paginated(
return self.__import_operations_api.list_imports(**args_dict)

@prerelease_feature
def describe_import(self, operation_id: str) -> ImportModel:
def describe_import(self, id: str) -> ImportModel:
"""
describe_import is used to get detailed information about a specific import operation.

Args:
operation_id (str): The id of the import operation. This value is returned when
id (str): The id of the import operation. This value is returned when
starting an import, and can be looked up using list_imports.

Returns:
ImportModel: An object containing operation id, status, and other details.
"""
return self.__import_operations_api.describe_import(operation_id=operation_id)
return self.__import_operations_api.describe_import(id=id)

@prerelease_feature
def cancel_import(self, operation_id: str):
def cancel_import(self, id: str):
"""Cancel an import operation.

Args:
operation_id (str): The id of the import operation to cancel.
id (str): The id of the import operation to cancel.
"""
return self.__import_operations_api.cancel_import(operation_id=operation_id)
return self.__import_operations_api.cancel_import(id=id)
40 changes: 40 additions & 0 deletions tests/unit/data/test_bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,43 @@ def test_no_arguments(self, mocker):
client.start_import()

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

class TestDescribeImport:
def test_describe_import(self, mocker):
# body = """
# {
# "id": "1",
# "records_imported": 1000,
# "uri": "s3://path/to/file.parquet",
# "status": "In Progress",
# "error_mode": "CONTINUE",
# "created_at": "2021-01-01T00:00:00Z",
# "updated_at": "2021-01-01T00:00:00Z",
# "integration": "s3",
# "error_message": ""
# "percent_complete": 43.2
# }
# """
body = """
{
"id": "1",
}
"""
client = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="prerelease"):
my_import = client.describe_import(id="1")
assert my_import.id == "1"
assert my_import["id"] == "1"
assert my_import.to_dict() == {
"id": "1",
"records_imported": 1000,
"uri": "s3://path/to/file.parquet",
"status": "In Progress",
"error_mode": "CONTINUE",
"created_at": "2021-01-01T00:00:00Z",
"updated_at": "2021-01-01T00:00:00Z",
"integration": "s3",
"error_message": "",
"percent_complete": 43.2,
}