Skip to content

Commit

Permalink
Some operationId > id fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Aug 30, 2024
1 parent 615d079 commit ad6ced9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
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

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,
}

0 comments on commit ad6ced9

Please sign in to comment.