Skip to main content

gushwork-argus

Python client for Argus, Gushwork's image ingestion and search API. You give Argus pages and images; it finds every image, describes it, and makes it searchable by meaning.

  • One client, two settings: an API key and the API host.
  • Argus (blocking) and AsyncArgus (asyncio) with the same methods.
  • Typed responses (Pydantic v2), typed errors, retries with backoff.
  • Python 3.10+. Depends only on httpx and pydantic.

Install

pip install gushwork-argus
# or
uv add gushwork-argus

Pin a version in services (gushwork-argus==0.2.0); see CHANGELOG.md.

Configure

from gushwork_argus import Argus

argus = Argus(api_key="...", base_url="https://<argus host>")

Or set ARGUS_API_KEY and ARGUS_BASE_URL and call Argus(). The Argus team gives you both: a key with the scopes your service needs, and the host for each environment.

Optional: timeout=30.0 (seconds per request), max_retries=2. Create one client per process and reuse it; it keeps a connection pool. Close it with argus.close() or use with Argus(...) as argus:.

Use

from pathlib import Path
from gushwork_argus import Argus, ConflictError

argus = Argus()

# 1. Create a namespace (admin key). Safe to retry with the same fields.
namespace = argus.namespaces.create(
    slug="acme-dental", name="Acme Dental", site_name="Acme Dental", domain="acme.com"
)

# 2. Get it back, by id or slug
namespace = argus.namespaces.get(namespace.id)
namespace = argus.namespaces.find_by_slug("acme-dental")  # None when there is none

# 3. Add a page or an image (ingest scope). Files go to S3 through a presigned upload.
page = argus.pages.add(namespace.id, Path("about.md"), page_url="https://acme.com/about")
page = argus.pages.add(namespace.id, html_text, type="html", page_url="https://acme.com/")
image = argus.images.add(namespace.id, file=Path("crown.jpg"), alt="Dentist fitting a crown")
image = argus.images.add(namespace.id, url="https://cdn.acme.com/crown.jpg")  # no upload
# Tags go on every image of the page (or on the one image) and act as filters later
page = argus.pages.add(namespace.id, html_text, type="html", tags=["google_business_profile"])
image = argus.images.add(namespace.id, file=Path("kitchen.jpg"), tags=["customer_uploaded"])

# 7. Check an ingestion, or wait until it is complete
status = argus.ingestions.get(page.ingestion_id)
status = argus.ingestions.wait(page.ingestion_id, timeout=600)
print(status.status, status.images.searchable, "of", status.images.total, "searchable")

# 4. Search (retrieve scope)
response = argus.images.search(
    namespace.id, "dentist fitting a crown", top_k=5, filters={"orientation": "landscape"}
)
for result in response.results:
    print(result.rank, result.match, result.image.url, result.description, result.tags)
# Only images carrying any of `tags`, and none of `exclude_tags`
response = argus.images.search(
    namespace.id,
    "kitchen remodel",
    filters={"tags": ["customer_uploaded"], "exclude_tags": ["stock"]},
)

# 5. List namespaces: one page, or all of them
page_of_namespaces = argus.namespaces.list(limit=50)  # CursorPage: .items, .next_cursor
for ns in argus.namespaces.list_all():
    print(ns.slug)

# 6. List images, newest first
for img in argus.images.list_all(namespace.id, status="RETRIEVAL_READY"):
    print(img.media_id, img.description, img.file.url if img.file else None)
for img in argus.images.list_all(namespace.id, tags=["google_business_profile"]):
    print(img.media_id, img.tags)

Async

from gushwork_argus import AsyncArgus

async with AsyncArgus() as argus:
    namespace = await argus.namespaces.get(namespace_id)
    page = await argus.pages.add(namespace.id, Path("about.md"))
    async for img in argus.images.list_all(namespace.id):
        ...

Pages and images, in detail

  • pages.add(namespace_id, content, *, type=None, page_url=None, page_title=None, markdown=None, tags=None) content is a Path (type read from .md/.html), or the page itself as str or bytes with type="md" or type="html". A str is always page text, never a file name. Send page_url whenever you have it: it resolves relative image links and tells the describer where each image appears. For HTML, markdown (the same page converted to markdown, if your scraper has it) improves captions. A page is identified by its bytes: sending the same bytes again returns the first ingestion with duplicate=True, and any new page_url, page_title or markdown is ignored. New tags are still added.
  • images.add(namespace_id, *, file=None, url=None, alt=None, caption=None, page_url=None, tags=None) Exactly one of file (a Path, bytes or a file opened "rb") or url.
  • Tags: up to 20 per call, each 1-64 of a-z 0-9 _ . : -, lowercased by Argus. They only grow: an image carries the tags of every page and upload it came from, near duplicates included, so a tag filter returns the image's group by its representative. images.list(..., tags=, exclude_tags=) and the search filters tags (any of) and exclude_tags (none of) filter on them; results and images return tags.
  • An ingestion is complete when the page is parsed (or failed) and every image on it is searchable or failed. Complete is not success: check status, error and images.failed.
  • Signed image links (url, thumbnail_url) expire after an hour. Store media_id, not the link.

Errors

Every runtime error is an ArgusError. Bad arguments raise ValueError before any request is sent.

Exception When
APIConnectionError / APITimeoutError No answer from Argus (after retries)
BadRequestError (400) Request refused, e.g. a search filter Argus can't apply
AuthenticationError (401) API key missing, wrong or revoked
PermissionDeniedError (403) Key lacks the scope, or the namespace is another tenant's
NotFoundError (404) No such namespace or ingestion
ConflictError (409) Slug taken with different fields (.namespace_id), or nothing searchable yet
UnprocessableEntityError (422) A field has the wrong shape
RateLimitError (429) / InternalServerError (5xx) After retries
UploadError S3 refused the file
APIResponseValidationError A 2xx body the SDK can't read (a proxy page, or a much newer server)
IngestionTimeoutError ingestions.wait() ran out of time (.ingestion has the last status)

Every APIStatusError has status_code, detail (the server's message, or a list of field errors) and body.

try:
    argus.namespaces.create(slug="acme-dental", name="Acme")
except ConflictError as exc:
    namespace = argus.namespaces.get(exc.namespace_id)

Retries

Writes are safe to repeat: namespaces are keyed by slug, pages by their content hash, images by their source and context. So every call except search is retried on connection errors, timeouts, 429, 502, 503 and 504, with exponential backoff and jitter (max_retries=2 by default; 0 turns retries off).

A search runs paid model calls each time, so it is retried only when it certainly never reached Argus (a refused connection, or 429). A search that times out raises APITimeoutError instead of running again; raise timeout if accurate searches on large namespaces need longer. ingestions.wait() keeps polling through connection errors and 5xx until its own timeout.

Retries are logged at INFO on the gushwork_argus logger.

S3 uploads go through a separate HTTP client that never carries the API key. It does not use a custom http_client; like any httpx client it reads HTTPS_PROXY and SSL_CERT_FILE from the environment.

API keys and scopes

Scope Can
admin create and edit namespaces, read anything
ingest add pages and images, check ingestions
retrieve search

Any key can read namespaces and list images. A key bound to a namespace sees only that namespace.

Develop

See CLAUDE.md for the layout, conventions and the release process.

cd sdk/python
uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check . && uv run pyright

Metadata

Release files for gushwork-argus 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gushwork-argus 0.2.0
File Size Uploaded Provenance Actions
gushwork_argus-0.2.0.tar.gz 17.5 kB Without provenance Details for gushwork_argus-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gushwork-argus 0.2.0
File Interpreter ABI Platform Actions
gushwork_argus-0.2.0-py3-none-any.whl Python 3 none any Details for gushwork_argus-0.2.0-py3-none-any.whl

Total release size: 40.4 kB

Release files / gushwork_argus-0.2.0.tar.gz

Download URL gushwork_argus-0.2.0.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3e21f0fb0287cbc74a463e5a838ba7b464da1dc9f89b45877a2a60574f3b0878
BLAKE2b-256 checksum
How to use checksums
a9375d46cfe911ecbad0cd72a2cc32b7e125b8408331e440da079a2be9117186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gushwork_argus-0.2.0-py3-none-any.whl

Download URL gushwork_argus-0.2.0-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0ba84e62c89d3677eaabe5ebecd66b6e3de670cddbc0d0682e928403c5e4ff3
BLAKE2b-256 checksum
How to use checksums
d34e33c651f64b45766d9c5485bb25c1cd42df5f2300b9bce77396fdd66a1c7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for gushwork-argus 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page