Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Polaris Python SDK

中文

Python client for Polaris service discovery, registration, service governance, AI Registry resources, observability, and TLS.

The distribution is polaris-python; import it as polaris.

The categorized documentation index is docs/README.md.

Install

Requires Python 3.12+.

uv sync --group dev --locked
uv run pytest

The project uses a src layout. uv sync installs src/polaris/ in editable mode, so source changes take effect immediately.

See Version and release for release and development package publishing.

Configure

global:
  serverConnector:
    addresses:
      - ${POLARIS_SERVER_ADDRESS:127.0.0.1:8091}
    token: ${POLARIS_TOKEN:}

Use Configuration.from_file() for YAML, Configuration.from_env() for environment variables, or Configuration.from_dict() for code-owned mappings. Python durations are integer milliseconds; YAML also accepts values such as 500ms, 1s, and 1m30s.

See:

Context

Each SDKContext owns its configuration snapshot, client ID, plugins, connections, caches, tasks, and logs. Reuse one context for APIs that should share that client.

from polaris import Configuration, init_context_by_config

config = Configuration()
config.set_default()
config.get_global().get_server_connector().addresses = ["127.0.0.1:8091"]

context = init_context_by_config(config)
try:
    ...
finally:
    context.destroy()

API calls after destroy() raise SDKError.

Provider

ProviderAPI supports synchronous methods and async_ counterparts. register_instance() enables SDK-managed heartbeats by default.

from polaris.pkg.model.server import InstanceRegisterRequest

response = provider.register_instance(InstanceRegisterRequest(
    service="demo",
    service_token="service-token",
    namespace="default",
    host="127.0.0.1",
    port=8080,
    ttl=5,
))

The service token authorizes register, heartbeat, and deregister. It is different from POLARIS_TOKEN, which authenticates the SDK connection.

Automatic re-registration runs after two consecutive 400202 responses and provider.minRegisterInterval. Deregistration stops heartbeat tasks before the RPC. Context destruction does not implicitly deregister instances.

Consumer

Reuse one ConsumerAPI per context. Synchronous calls are get_one_instance(), get_instances(), get_all_instances(), get_healthy_instances(), and get_services(); query methods have async_ counterparts. watch_service() pins a loaded resource and forwards cache lifecycle events; unwatch_service() releases it.

from polaris.pkg.model.service import GetOneInstanceRequest

instance = consumer.get_one_instance(GetOneInstanceRequest(
    namespace="default",
    service="demo",
))

After invoking the downstream service, report the result with update_service_call_result() or async_update_service_call_result().

Local cache behavior, idle eviction, disk retries, and restart recovery are covered by the examples and configuration reference.

AI Registry

  • MCP, A2A, and LangGraph use ordinary Instance registration and discovery.
  • Service contracts use report_service_contract() and get_service_contract().
  • SkillAPI provides read-only get/list/download operations over an independent connector.
  • Skill downloads can fall back to versioned local backups after network errors.

See AI Registry APIs and:

Plugins

Kind Names
Server connector grpc
Local cache inmemory, file
Service router isolatedRouter, metadataRouter, recoverRouter
Load balancer weightedRandom, random
Circuit breaker composite
Stat reporter prometheus (pushgateway chain alias for push mode)
Event reporter pushgateway

Legacy names wr and err_count normalize to weightedRandom and composite. Remote lossless rules are supported. Remote circuit-breaking, routing, rate-limiting and configuration rules remain disabled, and active health detection is not enabled.

Observability And Security

Public cloud currently uses Pushgateway as the default supported export path. Prometheus pull remains available for self-hosted or custom scraping setups. See Observability.

Each context has an isolated event center for implemented instance-cache and local circuit-breaker events, with an optional Pushgateway reporter. See Events.

The registry and Skill connectors support independent TLS and mTLS certificates. Invalid certificate configuration fails startup instead of falling back to plaintext. See TLS.

Examples

Run all offline verifications:

./examples/verify_all.sh

Run or inspect a single demo:

cd examples/quickstart
./run.sh --help
./verify.sh
./logs.sh --latest --tail 30
./cleanup.sh --force

Start with examples/README.md. Real registry examples require POLARIS_E2E=1.

License

BSD 3-Clause

Metadata

Release files for polaris-python 0.0.1.dev3

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

Source distribution (sdist)

Source distribution for polaris-python 0.0.1.dev3
File Size Uploaded Provenance Actions
polaris_python-0.0.1.dev3.tar.gz 196.8 kB With provenance Details for polaris_python-0.0.1.dev3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for polaris-python 0.0.1.dev3
File Interpreter ABI Platform Actions
polaris_python-0.0.1.dev3-py3-none-any.whl Python 3 none any Details for polaris_python-0.0.1.dev3-py3-none-any.whl

Total release size: 362.2 kB

Release files / polaris_python-0.0.1.dev3.tar.gz

Download URL polaris_python-0.0.1.dev3.tar.gz
Size 196.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fde6299fbbc37f3731fc95ea6a96298a24aaeb75d51acfd31eee4c5d5c4591b8
BLAKE2b-256 checksum
How to use checksums
19456525da396ed1b107a00da647445f3d7b8eb72396e2508bb3d59f3f3675c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / polaris_python-0.0.1.dev3-py3-none-any.whl

Download URL polaris_python-0.0.1.dev3-py3-none-any.whl
Size 165.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8978143a880819c84b843025b58952b14f4328f36fec81994aa0b9eeda6f38af
BLAKE2b-256 checksum
How to use checksums
aaaa72b6998fee9eb7d4967a74e7ece9d9feea9029cab6acf45132255e78a822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for polaris-python 0.0.1.dev3

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for polaris_python-0.0.1.dev3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

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