Vectorstore Deployment

The progress of a Vectorstore’s deploy: its conditions, its attempts, and its last error.

Creating a vector database takes minutes: Pinecone initializes a new index, and a self-hosted Qdrant server needs a volume, an image and a pod that starts. Each of those can fail on its own, and most failures are temporary. So deploy only checks what it can check at once, e.g. that Pinecone accepts the api key, and queues the Celery task deploy_vectorstore(), which checks the database again every DEPLOY_CHECK_INTERVAL seconds, backs off after an error, and gives up after DEPLOY_MAX_ATTEMPTS checks.

VectorstoreDeploymentState is what the task records, in the Vectorstore’s deployment column. The Vectorstore manifest’s status and the REST api’s vectorstore show it, so that a person, or the web console, can follow a deploy: which conditions are met, which attempt it is on, when it checks again, and why the last attempt failed.

smarter.apps.vectorstore.deployment.CONDITION_ORDER: tuple[Literal['Credentials', 'Volume', 'Server', 'Index'], ...] = ('Credentials', 'Volume', 'Server', 'Index')

The conditions in the order that a deploy meets them, which is the order that they are shown.

('Credentials', 'Volume', 'Server', 'Index')
smarter.apps.vectorstore.deployment.DEPLOY_CHECK_INTERVAL = 15

Seconds between the checks of a deploy that is waiting, e.g. for a server to start.

smarter.apps.vectorstore.deployment.DEPLOY_MAX_ATTEMPTS = 80

The checks that a deploy makes before it fails, about 20 minutes of waiting.

smarter.apps.vectorstore.deployment.DEPLOY_MAX_BACKOFF = 300

the wait doubles after each error in a row, up to this.

Type:

The longest wait, in seconds, after errors

smarter.apps.vectorstore.deployment.DEPLOY_STALLED_AFTER = datetime.timedelta(seconds=600)

A deploy whose next check is this late lost its Celery task, and Celery Beat’s reconcile takes it over.

class smarter.apps.vectorstore.deployment.VectorstoreDeploymentState(**data)[source]

Bases: BaseModel

The progress of a Vectorstore’s last deploy, as the deploy task records it.

It is stored as JSON in VectorstoreMeta.deployment. Read it with of(), and save it with save_to().

attempt: int
backoff()[source]

Return the seconds to wait before the next check.

It is DEPLOY_CHECK_INTERVAL while the deploy is only waiting, and doubles with each error in a row, up to DEPLOY_MAX_BACKOFF.

Return type:

int

condition(condition_type)[source]

Return a condition.

Parameters:

condition_type (str) – Its type, e.g. Index.

Return type:

SAMVectorstoreCondition | None

Returns:

The condition, or None if it hasn’t been recorded.

conditions: List[SAMVectorstoreCondition]
consecutiveErrors: int
finishedAt: datetime | None
id: str
property in_progress: bool

Whether a deploy began and hasn’t ended.

is_stalled(now=None)[source]

Whether a deploy in progress lost its Celery task: its next check is long overdue.

Parameters:

now (datetime | None) – The time, by default now.

Return type:

bool

Returns:

True if the deploy’s next check is later than DEPLOY_STALLED_AFTER.

lastError: str | None
maxAttempts: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

nextRetryAt: datetime | None
classmethod of(vectorstore)[source]

Return a Vectorstore’s deployment state.

Parameters:

vectorstore (VectorstoreMeta) – The Vectorstore.

Return type:

VectorstoreDeploymentState

Returns:

Its state, or an empty one if it was never deployed.

provisioned: bool
save_to(vectorstore)[source]

Save the state on a Vectorstore.

Parameters:

vectorstore (VectorstoreMeta) – The Vectorstore.

Return type:

None

set_condition(condition_type, status, reason='', message='')[source]

Record a condition.

Its lastTransitionTime changes only when its status changes, as in Kubernetes, so that it says how long a condition has been what it is.

Parameters:
  • condition_type (Literal['Credentials', 'Volume', 'Server', 'Index']) – The condition’s type, e.g. Server.

  • status (Literal['True', 'False', 'Unknown']) – True, False or Unknown.

  • reason (str) – One word, e.g. ImagePullBackOff.

  • message (str) – What was found, for a person.

Return type:

SAMVectorstoreCondition

Returns:

The condition.

classmethod start()[source]

Return the state of a new deploy, with a new id.

Return type:

VectorstoreDeploymentState