Skip to content
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

Disallow positional args #10

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
17 changes: 11 additions & 6 deletions compass_sdk/compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(self, message="The maximum error rate was exceeded. Stopping the in
class CompassClient:
def __init__(
self,
*,
index_url: str = "http://localhost:80",
username: Optional[str] = None,
password: Optional[str] = None,
Expand Down Expand Up @@ -106,7 +107,7 @@ def __init__(
}
logger.setLevel(logger_level.value)

def create_index(self, index_name: str):
def create_index(self, *, index_name: str):
"""
Create an index in Compass
:param index_name: the name of the index
Expand All @@ -119,7 +120,7 @@ def create_index(self, index_name: str):
sleep_retry_seconds=DEFAULT_SLEEP_RETRY_SECONDS,
)

def delete_index(self, index_name: str):
def delete_index(self, *, index_name: str):
"""
Delete an index from Compass
:param index_name: the name of the index
Expand All @@ -132,7 +133,7 @@ def delete_index(self, index_name: str):
sleep_retry_seconds=DEFAULT_SLEEP_RETRY_SECONDS,
)

def delete_document(self, index_name: str, doc_id: str):
def delete_document(self, *, index_name: str, doc_id: str):
"""
Delete a document from Compass
:param index_name: the name of the index
Expand All @@ -147,7 +148,7 @@ def delete_document(self, index_name: str, doc_id: str):
sleep_retry_seconds=DEFAULT_SLEEP_RETRY_SECONDS,
)

def get_document(self, index_name: str, doc_id: str):
def get_document(self, *, index_name: str, doc_id: str):
"""
Get a document from Compass
:param index_name: the name of the index
Expand Down Expand Up @@ -176,6 +177,7 @@ def list_indexes(self):

def add_context(
self,
*,
index_name: str,
doc_id: str,
context: Dict,
Expand Down Expand Up @@ -203,6 +205,7 @@ def add_context(

def insert_doc(
self,
*,
index_name: str,
doc: CompassDocument,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand All @@ -219,7 +222,7 @@ def insert_doc(
index_name=index_name, docs=iter([doc]), max_retries=max_retries, sleep_retry_seconds=sleep_retry_seconds
)

def insert_docs_batch(self, uuid: str, index_name: str):
def insert_docs_batch(self, *, uuid: str, index_name: str):
"""
Insert a batch of parsed documents into an index in Compass
:param uuid: the uuid of the batch
Expand All @@ -233,7 +236,7 @@ def insert_docs_batch(self, uuid: str, index_name: str):
sleep_retry_seconds=DEFAULT_SLEEP_RETRY_SECONDS,
)

def batch_status(self, uuid: str):
def batch_status(self, *, uuid: str):
"""
Get the status of a batch
:param uuid: the uuid of the batch
Expand All @@ -251,6 +254,7 @@ def batch_status(self, uuid: str):

def insert_docs(
self,
*,
index_name: str,
docs: Iterator[CompassDocument],
max_chunks_per_request: int = DEFAULT_MAX_CHUNKS_PER_REQUEST,
Expand Down Expand Up @@ -374,6 +378,7 @@ def _get_request_blocks(

def search(
self,
*,
index_name: str,
query: str,
top_k: int = 10,
Expand Down
Loading