Skip to main content

Install via pip

The AveniECA Python SDK is available on PyPI and can be installed using pip:
pip install avenieca-python

Dependencies

The SDK automatically installs the following dependencies:
install_requires=[
    "kafka-python",      # Kafka streaming support
    "numpy",             # Numerical operations on state vectors
    "requests",          # HTTP client for REST API
    "dataclass-wizard"   # JSON serialization for dataclasses
]

Python Version

The SDK requires Python 3.6 or higher.

Environment Configuration

After installation, configure your environment variables to connect to your AveniECA instance.
1

Set up Kafka connection

For streaming functionality, configure your Kafka broker URL:
export KAFKA_URL="your-kafka-broker:9092"
The Kafka URL should point to your AveniECA instance’s Kafka broker. Contact your system administrator for the correct endpoint.
2

Set up REST API credentials

For REST API access, configure your authentication credentials:
export USERNAME="your-username"
export PASSWORD="your-password"
Never commit credentials to version control. Use environment variables or a secrets management system.
3

Configure API endpoint (optional)

If your AveniECA API endpoint differs from the default, set the base URI:
export ECA_API_URI="http://your-eca-instance:2580/v1"
The default endpoint is http://localhost:2580/v1.

Verify Installation

Verify that the SDK is installed correctly by importing it in Python:
python3 -c "import avenieca; print('AveniECA SDK installed successfully')"

Test Kafka Configuration

Verify your Kafka configuration:
test_kafka.py
import os
from avenieca.config.broker import Broker

# This will raise an error if KAFKA_URL is not set
try:
    config = Broker(
        url=os.environ["KAFKA_URL"],
        sub_topic="test_topic",
        pub_topic="",
        group="test_group"
    )
    print(f"Kafka configured: {config.url}")
except KeyError:
    print("ERROR: KAFKA_URL environment variable not set")

Test API Configuration

Verify your REST API configuration:
test_api.py
import os
from avenieca.api.model import Config
from avenieca.api.eca import ECA

try:
    config = Config(
        uri=os.getenv("ECA_API_URI", "http://localhost:2580/v1"),
        username=os.environ["USERNAME"],
        password=os.environ["PASSWORD"]
    )
    
    eca = ECA(config)
    print("API client initialized successfully")
    
    # Optional: Test authentication
    # res, status = eca.ess.get_all(module_id="test")
    # print(f"API connection status: {status}")
    
except KeyError as e:
    print(f"ERROR: Missing environment variable: {e}")

Docker Setup (Optional)

If you’re running AveniECA in Docker, ensure your Python environment can reach the Kafka and API endpoints:
docker-compose.yml
services:
  python-client:
    image: python:3.9
    environment:
      - KAFKA_URL=kafka:9092
      - ECA_API_URI=http://eca-api:2580/v1
      - USERNAME=${USERNAME}
      - PASSWORD=${PASSWORD}
    networks:
      - eca-network

Troubleshooting

Ensure you’ve installed the package:
pip install avenieca-python
If using a virtual environment, make sure it’s activated.
The KAFKA_URL environment variable is not set. Set it in your shell:
export KAFKA_URL="your-kafka-broker:9092"
Or set it programmatically in Python:
os.environ["KAFKA_URL"] = "your-kafka-broker:9092"
  • Verify the AveniECA instance is running
  • Check firewall rules and network connectivity
  • Ensure the URLs are correct and accessible
  • For Docker setups, verify network configuration
Some systems may need additional build tools for kafka-python:Ubuntu/Debian:
sudo apt-get install python3-dev build-essential
macOS:
xcode-select --install

Next Steps

Quickstart Guide

Start building with streaming and API examples

Build docs developers (and LLMs) love