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

[Bug] createIndex switches to "Ready" state before it is actually is "Ready" for upserting #46

Open
2 tasks done
Kureev opened this issue Apr 18, 2023 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Kureev
Copy link

Kureev commented Apr 18, 2023

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

I have a function that programmatically creates a pinecone index. It should be resolved only once the index is "ready" for upserting.

async createIndex(owner: string, repo: string) {
    const name = this.getIndexName(owner, repo)

    await this.client.createIndex({
        createRequest: {
            name,
            dimension: 1536,
        },
    })

    const checkStatus = async () => {
        const { status } = await this.client.describeIndex({
            indexName: name,
        })
        if (status?.state === IndexMetaStatusStateEnum.Ready) {
            return status
        } else {
            return new Promise((resolve) => {
                setTimeout(() => resolve(checkStatus()), 5000)
            })
        }
    }

    const status = await checkStatus()
    return this.getIndex(owner, repo)
}

However, I experience an issue with this approach: even though the status returns me state: "Ready", the upserting command fails. If I create an index manually, the upserting works as intended. Hence, I think the issue is inside the logic that switches state to Ready way too early.

Expected Behavior

index's state switches to "Ready" only when index can be used for operations like upsert.

Steps To Reproduce

  1. Create a sample node application
  2. Install pinecone
  3. Create an instance of the pinecone using new PineconeClient()
  4. Call .createIndex with arbitrary parameters. For example,
const index = await client.createIndex({
    createRequest: {
        name,
        dimension: 1536,
    },
})
  1. Implement a similar function to the one in the example to await for index status to switch to Ready
  2. Try to upsert some data. For example, you can write a function similar to this:
async store(docs: Document[], pineconeIndex: VectorOperationsApi) {
    for (const chunk of this.splitDocuments(docs)) {
        await PineconeStore.fromDocuments(
            chunk,
            new OpenAIEmbeddings({
                verbose: true,
            }),
            {
                pineconeIndex,
            }
        )
    }
}
  1. You will have an error without a stack trace. However, if you pre-create an index and remove index creation part from the code, everything works fine.

Relevant log output

No response

Environment

- **OS**:
- **Language version**:
- **Pinecone client version**:

Additional Context

No response

@Kureev Kureev added the bug Something isn't working label Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant