From 9e9ce5e5c275ca34e9a39f7e95ff75914c37fcf5 Mon Sep 17 00:00:00 2001 From: Zapple Date: Tue, 28 Nov 2023 15:49:00 -0600 Subject: [PATCH 1/5] Rename dir from python to starpoint --- {python => starpoint}/LICENSE | 0 {python => starpoint}/README.md | 0 {python => starpoint}/dev-requirements.txt | 0 {python => starpoint}/pyproject.toml | 0 {python => starpoint}/requirements.txt | 0 {python => starpoint}/starpoint/__init__.py | 0 {python => starpoint}/starpoint/_utils.py | 9 +++-- {python => starpoint}/starpoint/db.py | 0 {python => starpoint}/starpoint/embedding.py | 0 {python => starpoint}/starpoint/openai.py | 0 {python => starpoint}/starpoint/pandas.py | 1 - {python => starpoint}/starpoint/reader.py | 4 +-- {python => starpoint}/starpoint/writer.py | 4 ++- {python => starpoint}/tests/test__utils.py | 0 {python => starpoint}/tests/test_db.py | 11 ++++-- {python => starpoint}/tests/test_embedding.py | 0 {python => starpoint}/tests/test_openai.py | 0 {python => starpoint}/tests/test_pandas.py | 0 {python => starpoint}/tests/test_reader.py | 0 {python => starpoint}/tests/test_writer.py | 36 +++++++++---------- 20 files changed, 36 insertions(+), 29 deletions(-) rename {python => starpoint}/LICENSE (100%) rename {python => starpoint}/README.md (100%) rename {python => starpoint}/dev-requirements.txt (100%) rename {python => starpoint}/pyproject.toml (100%) rename {python => starpoint}/requirements.txt (100%) rename {python => starpoint}/starpoint/__init__.py (100%) rename {python => starpoint}/starpoint/_utils.py (94%) rename {python => starpoint}/starpoint/db.py (100%) rename {python => starpoint}/starpoint/embedding.py (100%) rename {python => starpoint}/starpoint/openai.py (100%) rename {python => starpoint}/starpoint/pandas.py (99%) rename {python => starpoint}/starpoint/reader.py (99%) rename {python => starpoint}/starpoint/writer.py (99%) rename {python => starpoint}/tests/test__utils.py (100%) rename {python => starpoint}/tests/test_db.py (90%) rename {python => starpoint}/tests/test_embedding.py (100%) rename {python => starpoint}/tests/test_openai.py (100%) rename {python => starpoint}/tests/test_pandas.py (100%) rename {python => starpoint}/tests/test_reader.py (100%) rename {python => starpoint}/tests/test_writer.py (95%) diff --git a/python/LICENSE b/starpoint/LICENSE similarity index 100% rename from python/LICENSE rename to starpoint/LICENSE diff --git a/python/README.md b/starpoint/README.md similarity index 100% rename from python/README.md rename to starpoint/README.md diff --git a/python/dev-requirements.txt b/starpoint/dev-requirements.txt similarity index 100% rename from python/dev-requirements.txt rename to starpoint/dev-requirements.txt diff --git a/python/pyproject.toml b/starpoint/pyproject.toml similarity index 100% rename from python/pyproject.toml rename to starpoint/pyproject.toml diff --git a/python/requirements.txt b/starpoint/requirements.txt similarity index 100% rename from python/requirements.txt rename to starpoint/requirements.txt diff --git a/python/starpoint/__init__.py b/starpoint/starpoint/__init__.py similarity index 100% rename from python/starpoint/__init__.py rename to starpoint/starpoint/__init__.py diff --git a/python/starpoint/_utils.py b/starpoint/starpoint/_utils.py similarity index 94% rename from python/starpoint/_utils.py rename to starpoint/starpoint/_utils.py index 5592754..99f1d16 100644 --- a/python/starpoint/_utils.py +++ b/starpoint/starpoint/_utils.py @@ -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 diff --git a/python/starpoint/db.py b/starpoint/starpoint/db.py similarity index 100% rename from python/starpoint/db.py rename to starpoint/starpoint/db.py diff --git a/python/starpoint/embedding.py b/starpoint/starpoint/embedding.py similarity index 100% rename from python/starpoint/embedding.py rename to starpoint/starpoint/embedding.py diff --git a/python/starpoint/openai.py b/starpoint/starpoint/openai.py similarity index 100% rename from python/starpoint/openai.py rename to starpoint/starpoint/openai.py diff --git a/python/starpoint/pandas.py b/starpoint/starpoint/pandas.py similarity index 99% rename from python/starpoint/pandas.py rename to starpoint/starpoint/pandas.py index 1ab33f7..9d13298 100644 --- a/python/starpoint/pandas.py +++ b/starpoint/starpoint/pandas.py @@ -111,4 +111,3 @@ def update_by_dataframe( collection_id=collection_id, collection_name=collection_name, ) - diff --git a/python/starpoint/reader.py b/starpoint/starpoint/reader.py similarity index 99% rename from python/starpoint/reader.py rename to starpoint/starpoint/reader.py index 9a0fed3..9e045de 100644 --- a/python/starpoint/reader.py +++ b/starpoint/starpoint/reader.py @@ -9,7 +9,7 @@ _build_header, _check_collection_identifier_collision, _validate_host, - _ensure_embedding_dict + _ensure_embedding_dict, ) @@ -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( diff --git a/python/starpoint/writer.py b/starpoint/starpoint/writer.py similarity index 99% rename from python/starpoint/writer.py rename to starpoint/starpoint/writer.py index 5c72ad1..f3129ee 100644 --- a/python/starpoint/writer.py +++ b/starpoint/starpoint/writer.py @@ -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( diff --git a/python/tests/test__utils.py b/starpoint/tests/test__utils.py similarity index 100% rename from python/tests/test__utils.py rename to starpoint/tests/test__utils.py diff --git a/python/tests/test_db.py b/starpoint/tests/test_db.py similarity index 90% rename from python/tests/test_db.py rename to starpoint/tests/test_db.py index 699933a..6f1821f 100644 --- a/python/tests/test_db.py +++ b/starpoint/tests/test_db.py @@ -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() @@ -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() diff --git a/python/tests/test_embedding.py b/starpoint/tests/test_embedding.py similarity index 100% rename from python/tests/test_embedding.py rename to starpoint/tests/test_embedding.py diff --git a/python/tests/test_openai.py b/starpoint/tests/test_openai.py similarity index 100% rename from python/tests/test_openai.py rename to starpoint/tests/test_openai.py diff --git a/python/tests/test_pandas.py b/starpoint/tests/test_pandas.py similarity index 100% rename from python/tests/test_pandas.py rename to starpoint/tests/test_pandas.py diff --git a/python/tests/test_reader.py b/starpoint/tests/test_reader.py similarity index 100% rename from python/tests/test_reader.py rename to starpoint/tests/test_reader.py diff --git a/python/tests/test_writer.py b/starpoint/tests/test_writer.py similarity index 95% rename from python/tests/test_writer.py rename to starpoint/tests/test_writer.py index 7afbee2..2e21d94 100644 --- a/python/tests/test_writer.py +++ b/starpoint/tests/test_writer.py @@ -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 = [ { @@ -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 = [ @@ -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 = [ { @@ -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 = [ { @@ -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 = [ { @@ -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 = [ { @@ -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 = [ { From 3ba735a352140bf3bc02734d48c618c8febe8378 Mon Sep 17 00:00:00 2001 From: Zapple Date: Tue, 28 Nov 2023 15:49:30 -0600 Subject: [PATCH 2/5] Fix gh actions to match dir rename --- .github/workflows/publish_python.yml | 4 ++-- .github/workflows/test_python.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_python.yml b/.github/workflows/publish_python.yml index e03db04..06ade19 100644 --- a/.github/workflows/publish_python.yml +++ b/.github/workflows/publish_python.yml @@ -16,7 +16,7 @@ jobs: id-token: write # IMPORTANT: this permission is mandatory for trusted publishing defaults: run: - working-directory: ./python + working-directory: ./starpoint steps: - uses: actions/checkout@v3 with: @@ -36,4 +36,4 @@ jobs: - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - packages-dir: ./python/dist/ + packages-dir: ./starpoint/dist/ diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index c31c9d2..c5d0c56 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./python + working-directory: ./starpoint steps: - uses: actions/checkout@v3 - name: Set up Python From 2c65c1dfb5115452439eafa816f8c512b4d6e7b7 Mon Sep 17 00:00:00 2001 From: Zapple Date: Tue, 28 Nov 2023 15:54:24 -0600 Subject: [PATCH 3/5] Move various top level files to root --- starpoint/LICENSE => LICENSE | 0 starpoint/README.md => README.md | 0 starpoint/dev-requirements.txt => dev-requirements.txt | 0 starpoint/pyproject.toml => pyproject.toml | 0 starpoint/requirements.txt => requirements.txt | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename starpoint/LICENSE => LICENSE (100%) rename starpoint/README.md => README.md (100%) rename starpoint/dev-requirements.txt => dev-requirements.txt (100%) rename starpoint/pyproject.toml => pyproject.toml (100%) rename starpoint/requirements.txt => requirements.txt (100%) diff --git a/starpoint/LICENSE b/LICENSE similarity index 100% rename from starpoint/LICENSE rename to LICENSE diff --git a/starpoint/README.md b/README.md similarity index 100% rename from starpoint/README.md rename to README.md diff --git a/starpoint/dev-requirements.txt b/dev-requirements.txt similarity index 100% rename from starpoint/dev-requirements.txt rename to dev-requirements.txt diff --git a/starpoint/pyproject.toml b/pyproject.toml similarity index 100% rename from starpoint/pyproject.toml rename to pyproject.toml diff --git a/starpoint/requirements.txt b/requirements.txt similarity index 100% rename from starpoint/requirements.txt rename to requirements.txt From 1a105ab9cf69d3b11b6ef6dcacf9835f2b36bd04 Mon Sep 17 00:00:00 2001 From: Zapple Date: Wed, 29 Nov 2023 13:10:34 -0600 Subject: [PATCH 4/5] Move dir around again to maintain same api structure --- starpoint/{starpoint => }/__init__.py | 0 starpoint/{starpoint => }/_utils.py | 0 starpoint/{starpoint => }/db.py | 0 starpoint/{starpoint => }/embedding.py | 0 starpoint/{starpoint => }/openai.py | 0 starpoint/{starpoint => }/pandas.py | 0 starpoint/{starpoint => }/reader.py | 0 starpoint/{starpoint => }/writer.py | 0 {starpoint/tests => tests}/test__utils.py | 0 {starpoint/tests => tests}/test_db.py | 0 {starpoint/tests => tests}/test_embedding.py | 0 {starpoint/tests => tests}/test_openai.py | 0 {starpoint/tests => tests}/test_pandas.py | 0 {starpoint/tests => tests}/test_reader.py | 0 {starpoint/tests => tests}/test_writer.py | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename starpoint/{starpoint => }/__init__.py (100%) rename starpoint/{starpoint => }/_utils.py (100%) rename starpoint/{starpoint => }/db.py (100%) rename starpoint/{starpoint => }/embedding.py (100%) rename starpoint/{starpoint => }/openai.py (100%) rename starpoint/{starpoint => }/pandas.py (100%) rename starpoint/{starpoint => }/reader.py (100%) rename starpoint/{starpoint => }/writer.py (100%) rename {starpoint/tests => tests}/test__utils.py (100%) rename {starpoint/tests => tests}/test_db.py (100%) rename {starpoint/tests => tests}/test_embedding.py (100%) rename {starpoint/tests => tests}/test_openai.py (100%) rename {starpoint/tests => tests}/test_pandas.py (100%) rename {starpoint/tests => tests}/test_reader.py (100%) rename {starpoint/tests => tests}/test_writer.py (100%) diff --git a/starpoint/starpoint/__init__.py b/starpoint/__init__.py similarity index 100% rename from starpoint/starpoint/__init__.py rename to starpoint/__init__.py diff --git a/starpoint/starpoint/_utils.py b/starpoint/_utils.py similarity index 100% rename from starpoint/starpoint/_utils.py rename to starpoint/_utils.py diff --git a/starpoint/starpoint/db.py b/starpoint/db.py similarity index 100% rename from starpoint/starpoint/db.py rename to starpoint/db.py diff --git a/starpoint/starpoint/embedding.py b/starpoint/embedding.py similarity index 100% rename from starpoint/starpoint/embedding.py rename to starpoint/embedding.py diff --git a/starpoint/starpoint/openai.py b/starpoint/openai.py similarity index 100% rename from starpoint/starpoint/openai.py rename to starpoint/openai.py diff --git a/starpoint/starpoint/pandas.py b/starpoint/pandas.py similarity index 100% rename from starpoint/starpoint/pandas.py rename to starpoint/pandas.py diff --git a/starpoint/starpoint/reader.py b/starpoint/reader.py similarity index 100% rename from starpoint/starpoint/reader.py rename to starpoint/reader.py diff --git a/starpoint/starpoint/writer.py b/starpoint/writer.py similarity index 100% rename from starpoint/starpoint/writer.py rename to starpoint/writer.py diff --git a/starpoint/tests/test__utils.py b/tests/test__utils.py similarity index 100% rename from starpoint/tests/test__utils.py rename to tests/test__utils.py diff --git a/starpoint/tests/test_db.py b/tests/test_db.py similarity index 100% rename from starpoint/tests/test_db.py rename to tests/test_db.py diff --git a/starpoint/tests/test_embedding.py b/tests/test_embedding.py similarity index 100% rename from starpoint/tests/test_embedding.py rename to tests/test_embedding.py diff --git a/starpoint/tests/test_openai.py b/tests/test_openai.py similarity index 100% rename from starpoint/tests/test_openai.py rename to tests/test_openai.py diff --git a/starpoint/tests/test_pandas.py b/tests/test_pandas.py similarity index 100% rename from starpoint/tests/test_pandas.py rename to tests/test_pandas.py diff --git a/starpoint/tests/test_reader.py b/tests/test_reader.py similarity index 100% rename from starpoint/tests/test_reader.py rename to tests/test_reader.py diff --git a/starpoint/tests/test_writer.py b/tests/test_writer.py similarity index 100% rename from starpoint/tests/test_writer.py rename to tests/test_writer.py From 402c38c53b46b235571ed28aca08b8263a1d0ce1 Mon Sep 17 00:00:00 2001 From: Zapple Date: Wed, 29 Nov 2023 13:10:51 -0600 Subject: [PATCH 5/5] Fix workflows --- .github/workflows/publish_python.yml | 5 +---- .github/workflows/test_python.yml | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/publish_python.yml b/.github/workflows/publish_python.yml index 06ade19..b7e430c 100644 --- a/.github/workflows/publish_python.yml +++ b/.github/workflows/publish_python.yml @@ -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: ./starpoint steps: - uses: actions/checkout@v3 with: @@ -36,4 +33,4 @@ jobs: - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - packages-dir: ./starpoint/dist/ + packages-dir: ./dist/ diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index c5d0c56..fea2e4d 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -13,9 +13,6 @@ jobs: test-python-sdk: name: Python SDK Tests runs-on: ubuntu-latest - defaults: - run: - working-directory: ./starpoint steps: - uses: actions/checkout@v3 - name: Set up Python