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

Rename dir #50

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions .github/workflows/publish_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ jobs:
url: https://pypi.org/p/starpoint
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
defaults:
run:
working-directory: ./python
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -36,4 +33,4 @@ jobs:
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./python/dist/
packages-dir: ./dist/
3 changes: 0 additions & 3 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
test-python-sdk:
name: Python SDK Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 4 additions & 5 deletions python/starpoint/_utils.py → starpoint/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ def _check_collection_identifier_collision(
raise ValueError(MULTI_COLLECTION_VALUE_ERROR)


def _ensure_embedding_dict(embeddings: List[float] | Dict[str, List[float] | int] | None):
def _ensure_embedding_dict(
embeddings: List[float] | Dict[str, List[float] | int] | None
):
if isinstance(embeddings, list):
dict_embeddings = {
"values": embeddings,
"dimensionality": len(embeddings)
}
dict_embeddings = {"values": embeddings, "dimensionality": len(embeddings)}
return dict_embeddings
return embeddings
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion python/starpoint/pandas.py → starpoint/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,3 @@ def update_by_dataframe(
collection_id=collection_id,
collection_name=collection_name,
)

4 changes: 2 additions & 2 deletions python/starpoint/reader.py → starpoint/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
_build_header,
_check_collection_identifier_collision,
_validate_host,
_ensure_embedding_dict
_ensure_embedding_dict,
)


Expand Down Expand Up @@ -89,7 +89,7 @@ def query(
)
"""

# check if type of query embeddings is list of float, if so convert to a dict
# check if type of query embeddings is list of float, if so convert to a dict
query_embeddings = _ensure_embedding_dict(query_embeddings)

request_data = dict(
Expand Down
4 changes: 3 additions & 1 deletion python/starpoint/writer.py → starpoint/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ def column_update(
"embeddings": embedding,
"metadata": document_metadata,
}
for embedding, document_metadata, id in zip(embeddings, document_metadatas, ids)
for embedding, document_metadata, id in zip(
embeddings, document_metadatas, ids
)
]

return self.update(
Expand Down
File renamed without changes.
11 changes: 9 additions & 2 deletions python/tests/test_db.py → tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def test_client_insert(mock_writer: MagicMock, mock_reader: MagicMock):
def test_client_column_insert(mock_writer: MagicMock, mock_reader: MagicMock):
client = db.Client(api_key=uuid4())

client.column_insert(embeddings=[{"values": [1.1], "dimensionality": 1}], document_metadatas=[{"mock": "value"}])
client.column_insert(
embeddings=[{"values": [1.1], "dimensionality": 1}],
document_metadatas=[{"mock": "value"}],
)

mock_reader.assert_called_once() # Only called during init
mock_writer().column_insert.assert_called_once()
Expand Down Expand Up @@ -90,6 +93,10 @@ def test_client_update(mock_writer: MagicMock, mock_reader: MagicMock):
def test_client_column_update(mock_writer: MagicMock, mock_reader: MagicMock):
client = db.Client(api_key=uuid4())

client.column_update(ids=["a"], embeddings=[{"values": [1.1], "dimensionality": 1}], document_metadatas=[{"mock": "value"}])
client.column_update(
ids=["a"],
embeddings=[{"values": [1.1], "dimensionality": 1}],
document_metadatas=[{"mock": "value"}],
)
mock_reader.assert_called_once() # Only called during init
mock_writer().column_update.assert_called_once()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 18 additions & 18 deletions python/tests/test_writer.py → tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ def test_writer_insert_SSLError(
@patch("starpoint.writer.Writer.insert")
def test_writer_column_insert(insert_mock: MagicMock, mock_writer: writer.Writer):
test_embeddings = [
{"values": [0.88], "dimensionality": 1},
{"values": [0.71], "dimensionality": 1}
]
{"values": [0.88], "dimensionality": 1},
{"values": [0.71], "dimensionality": 1},
]
test_document_metadatas = [{"mock": "metadata"}, {"mock2": "metadata2"}]
expected_insert_document = [
{
Expand Down Expand Up @@ -192,8 +192,8 @@ def test_writer_column_insert_collection_id_collection_name_passed_through(
insert_mock: MagicMock, mock_writer: writer.Writer
):
test_embeddings = [
{"values": [0.88], "dimensionality": 1},
]
{"values": [0.88], "dimensionality": 1},
]

test_document_metadatas = [{"mock": "metadata"}]
expected_insert_document = [
Expand Down Expand Up @@ -224,9 +224,9 @@ def test_writer_column_insert_shorter_metadatas_length(
insert_mock: MagicMock, mock_writer: writer.Writer, monkeypatch: MonkeyPatch
):
test_embeddings = [
{"values": [0.88], "dimensionality": 1},
{"values": [0.71], "dimensionality": 1}
]
{"values": [0.88], "dimensionality": 1},
{"values": [0.71], "dimensionality": 1},
]
test_document_metadatas = [{"mock": "metadata"}]
expected_insert_document = [
{
Expand Down Expand Up @@ -257,8 +257,8 @@ def test_writer_column_insert_shorter_embeddings_length(
insert_mock: MagicMock, mock_writer: writer.Writer, monkeypatch: MonkeyPatch
):
test_embeddings = [
{"values": [0.88], "dimensionality": 1},
]
{"values": [0.88], "dimensionality": 1},
]
test_document_metadatas = [{"mock": "metadata"}, {"mock2": "metadata2"}]
expected_insert_document = [
{
Expand Down Expand Up @@ -350,9 +350,9 @@ def test_writer_update_SSLError(
def test_writer_column_update(update_mock: MagicMock, mock_writer: writer.Writer):
ids = ["a", "b"]
test_embeddings = [
{"values": [0.88], "dimensionality": 1},
{"values": [0.71], "dimensionality": 1}
]
{"values": [0.88], "dimensionality": 1},
{"values": [0.71], "dimensionality": 1},
]
test_document_metadatas = [{"mock": "metadata"}, {"mock2": "metadata2"}]
expected_update_document = [
{
Expand Down Expand Up @@ -416,9 +416,9 @@ def test_writer_column_insert_shorter_metadatas_length(
):
ids = ["a", "b"]
test_embeddings = [
{"values": [0.88], "dimensionality": 1},
{"values": [0.71], "dimensionality": 1}
]
{"values": [0.88], "dimensionality": 1},
{"values": [0.71], "dimensionality": 1},
]
test_document_metadatas = [{"mock": "metadata"}]
expected_update_document = [
{
Expand Down Expand Up @@ -451,8 +451,8 @@ def test_writer_column_update_shorter_embeddings_length(
):
ids = ["a", "b"]
test_embeddings = [
{"values": [0.88], "dimensionality": 1},
]
{"values": [0.88], "dimensionality": 1},
]
test_document_metadatas = [{"mock": "metadata"}, {"mock2": "metadata2"}]
expected_update_document = [
{
Expand Down