Skip to content
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
2 changes: 2 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ runs:

- name: Setup Poetry
uses: ./.github/actions/setup-poetry
with:
include_grpc: 'true'

- name: Build html documentation
shell: bash
Expand Down
7 changes: 7 additions & 0 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
name: 'Setup Poetry'
description: 'Installs Poetry and dependencies'
inputs:
include_grpc:
description: 'Install gRPC dependencies'
required: true
default: 'false'
runs:
using: 'composite'
steps:
- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
if: ${{ inputs.include_grpc == 'false' }}
shell: bash
run: |
poetry install
Expand All @@ -16,6 +22,7 @@ runs:
# The dependencies that are specific to gRPC are defined in pyproject.toml
# under tool.poetry.extras
- name: Install gRPC dependencies
if: ${{ inputs.include_grpc == 'true' }}
shell: bash
run: |
poetry install --extras "grpc"
54 changes: 46 additions & 8 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
workflow_call: {}

jobs:
run-tests:
name: Run tests
units-no-grpc:
name: Run tests (REST)
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -22,11 +22,49 @@ jobs:
- name: Setup Poetry
uses: ./.github/actions/setup-poetry

- name: Run tests
run: make tests
- name: Run unit tests
run: poetry run pytest --cov=pinecone --timeout=120 tests/unit

- name: Build Python client
run: make package
units-grpc:
name: Run tests (GRPC)
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', 3.11]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Poetry
uses: ./.github/actions/setup-poetry
with:
include_grpc: true

- name: Run unit tests (GRPC)
run: poetry run pytest --cov=pinecone --timeout=120 tests/unit_grpc

package:
name: Check packaging
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', 3.11]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Poetry
uses: ./.github/actions/setup-poetry

- name: Build docs
run: make docs
Comment on lines -31 to -32

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for pulling this out of here, this was a mistake on my part I think.

We cover this step in the pr workflow already so it may have been running twice.

- name: Package
run: poetry build
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ image:
develop:
poetry install -E grpc

tests:
@echo "Installing dependencies..."
poetry install
test-unit:
@echo "Running tests..."
poetry run pytest --cov=pinecone --timeout=120 tests/unit

test-grpc-unit:
@echo "Running tests..."
poetry run pytest --cov=pinecone --timeout=120 tests/unit_grpc

version:
poetry version

Expand Down
7 changes: 1 addition & 6 deletions pinecone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@
from .config import *
from .exceptions import *
from .control.pinecone import Pinecone
from .data.index import *

try:
from .data.grpc.index_grpc import *
except ImportError:
pass # ignore for non-[grpc] installations
from .data.index import *
5 changes: 0 additions & 5 deletions pinecone/control/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from pinecone.utils import get_user_agent

from pinecone.data import Index
from pinecone.data import GRPCIndex


class Pinecone:
def __init__(
Expand Down Expand Up @@ -270,6 +268,3 @@ def _get_status(self, name: str):
def Index(self, name: str):
index_host = self.index_host_store.get_host(self.index_api, self.config, name)
return Index(api_key=self.config.API_KEY, host=index_host)

def GRPCIndex(self, name: str):
return GRPCIndex(self.config, name)
3 changes: 1 addition & 2 deletions pinecone/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from .index import Index
from .grpc.index_grpc import GRPCIndex
from .index import Index
Empty file removed pinecone/data/grpc/__init__.py
Empty file.
1 change: 0 additions & 1 deletion pinecone/deprecated/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions pinecone/deprecated/legacy_utils.py

This file was deleted.

2 changes: 2 additions & 0 deletions pinecone/grpc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .index_grpc import GRPCIndex
from .pinecone import Pinecone
2 changes: 1 addition & 1 deletion pinecone/data/grpc/base.py → pinecone/grpc/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from abc import ABC, abstractmethod
from functools import wraps
from typing import NamedTuple, Optional, Dict
from typing import Dict

import certifi
import grpc
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
REQUIRED_VECTOR_FIELDS,
OPTIONAL_VECTOR_FIELDS,
)
from pinecone.data.grpc.base import GRPCIndexBase
from pinecone.data.grpc.future import PineconeGrpcFuture
from .base import GRPCIndexBase
from .future import PineconeGrpcFuture

__all__ = ["GRPCIndex", "GRPCVector", "GRPCQueryVector", "GRPCSparseValues"]

Expand Down
7 changes: 7 additions & 0 deletions pinecone/grpc/pinecone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ..control.pinecone import Pinecone
from .index_grpc import GRPCIndex

class Pinecone(Pinecone):
def Index(self, name: str):
index_host = self.index_host_store.get_host(self.index_api, self.config, name)
return GRPCIndex(api_key=self.config.API_KEY, host=index_host)
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ dnspython = ">=2.0.0"
python-dateutil = ">=2.5.3"
urllib3 = "1.25.3"
tqdm = ">=4.64.1"
grpcio = ">=1.44.0"
grpc-gateway-protoc-gen-openapiv2 = "0.1.0"
googleapis-common-protos = ">=1.53.0"
lz4 = ">=3.1.3"
protobuf = "~=3.20.0"
grpcio = { version = ">=1.44.0", optional = true }
grpc-gateway-protoc-gen-openapiv2 = { version = "0.1.0", optional = true }
googleapis-common-protos = { version = ">=1.53.0", optional = true }
lz4 = { version = ">=3.1.3", optional = true }
protobuf = { version = "~=3.20.0", optional = true }
Comment on lines +66 to +70

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did not know you could explicitly set optional like this. 👍


[tool.poetry.group.dev.dependencies]
numpy = ">=1.22"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import pandas as pd
import pytest

from pinecone import Config, GRPCIndex
from pinecone import Config
from pinecone.grpc import GRPCIndex
from pinecone import DescribeIndexStatsRequest
from pinecone.core.grpc.protos.vector_service_pb2 import (
Vector,
Expand All @@ -18,7 +19,7 @@
UpsertResponse,
SparseValues,
)
from pinecone.data.grpc.utils import dict_to_proto_struct
from pinecone.grpc.utils import dict_to_proto_struct

class TestGrpcIndex:
def setup_method(self):
Expand Down