Configuration management
Most operational SDK calls read or modify a single record. Synonyms, stored shapes, bulk document upserts and async jobs are different. They touch configuration or batches, and they follow different rules from per-record reads. This page collects the rules so you can choose the right call for the situation.
Three concurrency models
The SDK exposes three distinct concurrency models. Knowing which one a call uses tells you whether two writers can silently overwrite each other.
Optimistic concurrency (ETag / If-Match)
Used by shapes and reference lists.
The server returns an ETag on read, and the SDK passes it back as If-Match on update. If the
server-side version moved in the meantime, the write fails with a precondition error. Shapes raise
AdminConflictError; reference lists raise ReferenceListConcurrentModificationError. Both derive
from ConflictError, so catch that when you want one branch for either.
shape = svi.admin.shapes.get(shape_id=shape_id)
shape.raw.name = "renamed"
svi.admin.shapes.update(shape) # may raise AdminConflictError on a concurrent edit
Recover by re-fetching, re-applying the edit, and retrying.
Whole-list replace
Used by synonyms.
The SAND endpoint accepts a single POST that replaces the entire synonym list. There is no ETag. Two writers reading and writing back-to-back can clobber each other.
The SDK gives you two patterns:
add(...)andremove(...)perform a read-modify-write under the hood. Convenient, but they race with concurrent writers.sync(desired, dry_run=True)returns the diff against current state without writing. Apply the plan withsync(desired)when you are confident.
plan = svi.admin.synonyms.sync(desired, dry_run=True)
print(len(plan.added), len(plan.removed), len(plan.unchanged))
svi.admin.synonyms.sync(desired)
The sync flow is the right choice when synonyms live in version control and a CI job pushes
them; the dry-run plan lets a reviewer see what would change before approval.
Partial failure (bulk)
Used by bulk document upsert and bulk link upsert.
A bulk POST returns a 200 / 201 with a per-input result row. Each row carries an id, an
operation, and either a null error (success) or a populated error (failure). The call
does not raise on per-item failures.
results = svi.documents.bulk_upsert(items)
failures = [row for row in results if not row.succeeded]
If you want fail-fast semantics, call raise_on_errors(results). If you want to retry only the
failures, use the row metadata to rebuild a smaller batch.
Single-call bulk versus per-record loop
The bulk endpoints exist because per-record loops are expensive at scale. A few rules of thumb:
- More than ~20 records. Prefer bulk. Per-record loops accumulate transport overhead and lose the server's ability to share validation work.
- Mixed creates and updates. Bulk handles both in one call, so you do not need to pre-classify the batch.
- Per-record exception handling. Easier with per-record calls. With bulk you inspect rows.
For very large batches (thousands of records) chunk into smaller bulks (~1k each) so the request body stays manageable and you get feedback before the whole job completes.
Stored shapes and the search DSL
Stored shapes are configuration, but the search DSL references them at query time. Two SDK design choices follow from that coupling:
Shape.as_filter(relation=...)returns aGeoShapeFilterExprbound to the shape's id, so the shape returned fromsvi.admin.shapesdrops straight intosvi.search.F.geo_shape(stored=<Shape>, ...)accepts aShapeinstance directly, so DSL code does not need to keep two parallel variables (the shape object and its id).
Either path produces the same wire payload. Pick the one that reads better at the call site.
Async jobs
svi.documents.submit_async_job(...) returns a JobHandle with id and status populated
from the submission response. The data hub spec marks POST /admin/asyncJobs as create-only, and
status polling lives on a separate SAS Visual Investigator job-monitor service that the SDK does
not wrap. svi.api.datahub carries the submission operation but no job-status operation. The
handle has no refresh() or wait(), and there is no SDK path to a job's later status today.
Practical impact:
- treat the submission as fire-and-forget
- record the job
idandstatusin your own logs so you can correlate with the monitor later
The one job the SDK already waits on is the full-solution transport import.
svi.admin.config.import_archive(...) polls the job URL the server returns with a 202 until the
job reports completed, failed, cancelled, reverted or invalid. The wait is bounded by the
call's timeout and a hard cap on status requests. Pass wait=False to take the job URL and poll
it yourself. See Full solution transport.