Skip to content

Commit

Permalink
Dependency testing, support python3.8, downgrade urllib3 (#263)
Browse files Browse the repository at this point in the history
## Problem

Some goals:
- Verify our code works with the claimed dependency ranges
- Bring back python 3.8 support for LlamaIndex compatibility
- Add flexibility to urllib3 dependency version by extending the version
range back to 1.26.x.

## Solution

- Remove more unused dependencies
- `requests` (not sure when this was added; doesn't seem like it's been
used for a while)
- `python-dateutil` (no longer needed now that we've removed some date
parsing default behavior in the generated client code)
- Specify python-version specific dependency configuration for some dev
dependencies (numpy, pandas-stubs) that were pushing us toward dropping
py3.8 support
- Added new reusable workflow action, `.github/actions/create-index/`,
to create an index that will be used for subsequent testing.
- Add new test workflow jobs, `dependency-matrix-rest` and
`dependency-matrix-grpc`, with minimal integration test to verify the
package works with different combinations of installed python
dependencies.
  - New tests stored under `tests/dependency`  
- Integration test exercises control plane (list indexes, describe an
index ) and data plane (upsert and query). It does not create a new
index for each test as this is time-consuming, the test matrix is large,
and index creation is extensively tested elsewhere.
- Test configuration was getting unwieldy, so I split `testing.yaml`
into `testing-rest.yaml` and `testing-grpc.yaml`
- Data freshness isn't a huge issue for these tests, since the index is
reused for upsert/query across different configurations. It's sufficient
for these minimal tests to issue network calls and get responses without
throwing exceptions to verify the dependencies are working.

## Type of Change

Is "being able to install" a feature?

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)

## Test Plan

Add new test matrix to verify some dependencies work across the claimed
range.
  • Loading branch information
jhamon authored Jan 10, 2024
1 parent a858f52 commit 257ae25
Show file tree
Hide file tree
Showing 16 changed files with 654 additions and 182 deletions.
55 changes: 55 additions & 0 deletions .github/actions/create-index/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Create Index'
description: 'Creates an index to be used in other tests'

inputs:
region:
description: 'The region of the index'
required: false
default: 'us-west-2'
cloud:
description: 'The cloud of the index'
required: false
default: 'aws'
name_prefix:
description: 'The prefix of the index name'
required: false
default: 'index-name'
dimension:
description: 'The dimension of the index'
required: false
default: '3'
metric:
description: 'The metric of the index'
required: false
default: 'cosine'
PINECONE_API_KEY:
description: 'The Pinecone API key'
required: true

outputs:
index_name:
description: 'The name of the index, including randomized suffix'
value: ${{ steps.create-index.outputs.index_name }}

runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

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

- name: Create index
id: create-index
shell: bash
run: poetry run python3 scripts/create.py
env:
PINECONE_API_KEY: ${{ inputs.PINECONE_API_KEY }}
NAME_PREFIX: ${{ inputs.name_prefix }}
REGION: ${{ inputs.region }}
CLOUD: ${{ inputs.cloud }}
DIMENSION: ${{ inputs.dimension }}
METRIC: ${{ inputs.metric }}
29 changes: 29 additions & 0 deletions .github/actions/delete-index/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Delete Index'
description: 'Deletes an index to be used in other tests'

inputs:
index_name:
description: 'The name of the index to delete'
required: true
PINECONE_API_KEY:
description: 'The Pinecone API key'
required: true


runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

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

- name: Delete index
shell: bash
run: poetry run python3 scripts/delete.py
env:
PINECONE_API_KEY: ${{ inputs.PINECONE_API_KEY }}
INDEX_NAME: ${{ inputs.index_name }}
28 changes: 16 additions & 12 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ inputs:
description: 'Install gRPC dependencies'
required: true
default: 'false'
include_dev:
description: 'Install dev dependencies'
required: true
default: 'true'
include_types:
description: 'Install typing dependencies (mypy, type stubs, etc)'
required: true
default: 'true'

runs:
using: 'composite'
Expand All @@ -13,17 +21,13 @@ runs:
uses: snok/install-poetry@v1

- name: Install dependencies
if: ${{ inputs.include_grpc == 'false' }}
shell: bash
run: |
poetry install
# We separate the gRPC dependencies from the REST client's install
# behavior, so we test installing the grpc dependencies here as well
# 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
env:
INCLUDE_GRPC: ${{ inputs.include_grpc }}
INCLUDE_DEV: ${{ inputs.include_dev }}
INCLUDE_TYPES: ${{ inputs.include_types }}
run: |
poetry install --extras "grpc"
GRPC_FLAG=$( [ "$INCLUDE_GRPC" = "true" ] && echo "--extras grpc" || echo "" )
DEV_FLAG=$( [ "$INCLUDE_DEV" = "false" ] && echo "--without dev" || echo "" )
TYPING_FLAG=$( [ "$INCLUDE_TYPES" = "true" ] && echo "--with types" || echo "" )
poetry install $DEV_FLAG $TYPING_FLAG $GRPC_FLAG
25 changes: 23 additions & 2 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,30 @@ on:
workflow_dispatch: {}

jobs:
run-tests:
uses: './.github/workflows/testing.yaml'
run-tests-rest:
uses: './.github/workflows/testing-rest.yaml'
secrets: inherit
run-tests-grpc:
uses: './.github/workflows/testing-grpc.yaml'
secrets: inherit
package:
name: Check packaging
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', 3.11]
steps:
- uses: actions/checkout@v4
- 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: Package
run: poetry build



build-docs:
name: Build docs with pdoc
Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/testing-grpc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Testing GRPC

on:
workflow_call: {}

jobs:
units-grpc:
name: Unit tests (GRPC)
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', 3.11]

steps:
- uses: actions/checkout@v4

- 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

- name: mypy check
run: |
# Still lots of errors when running on the whole package (especially
# in the generated core module), but we can check these subpackages
# so we don't add new regressions.
poetry run mypy pinecone --exclude pinecone/core
dependency-matrix-grpc-setup:
name: Deps setup (GRPC)
runs-on: ubuntu-latest
outputs:
index_name: ${{ steps.setup-index.outputs.index_name }}
steps:
- uses: actions/checkout@v4
- name: Create index
id: setup-index
uses: ./.github/actions/create-index
timeout-minutes: 5
with:
name_prefix: depstest-grpc-${{ github.run_number }}
dimension: 2
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}

dependency-matrix-grpc:
name: Deps (GRPC)
needs: dependency-matrix-grpc-setup
runs-on: ubuntu-latest
strategy:
max-parallel: 5
fail-fast: false
matrix:
python-version:
- 3.8
# - 3.9
# - "3.10"
# - 3.11
grpcio-version:
- 1.44.0
# - 1.46.5
# - 1.47.5
# - 1.48.2
# - 1.49.1
- 1.50.0
# - 1.51.3
# - 1.53.2
# - 1.54.3
# - 1.55.3
- 1.56.2
# - 1.57.0
# - 1.58.0
# - 1.59.3
- 1.60.0
lz4-version:
- 3.1.3
# - 3.1.10
- 4.0.0
# - 4.0.1
# - 4.1.0
- 4.3.3
protobuf-version:
- 3.20.3
googleapis-common-protos-version:
- 1.53.0
- 1.62.0
grpc-gateway-protoc-gen-openapiv2-version:
- 0.1.0

steps:
- uses: actions/checkout@v4

- 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
include_types: false
- name: Install grpcio ${{ matrix.grpcio-version }}
run: poetry add grpcio==${{ matrix.grpcio-version }}
- name: Install lz4 ${{ matrix.lz4-version }}
run: poetry add lz4==${{ matrix.lz4-version }}
- name: Install protobuf ${{ matrix.protobuf-version }}
run: poetry add protobuf==${{ matrix.protobuf-version }}
- name: Install googleapis-common-protos ${{ matrix.googleapis-common-protos-version }}
run: poetry add googleapis-common-protos==${{ matrix.googleapis-common-protos-version }}

- uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 3
retry_on: error
command: poetry run pytest tests/dependency/grpc -s -v
env:
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
INDEX_NAME: ${{ needs.dependency-matrix-grpc-setup.outputs.index_name }}

Loading

0 comments on commit 257ae25

Please sign in to comment.