Installation and usage¶
INTERSECT-SDK requires a Python version >= 3.8.10 .
After installing Python, make a folder for your project, then create a virtual environment in that folder and activate the environment as follows:
# Create a project folder and change to that directory
mkdir myproject
cd myproject
# Create a virtual environment and activate it
python -m venv venv
source venv/bin/activate
Next, install the intersect-sdk package into the virtual environment using the command shown below.
# Install the intersect-sdk package into the virtual environment
pip install intersect-sdk
You should now be able to import the package in a Python script, notebook, or program using:
import intersect_sdk
Use the command shown below to deactivate the virtual environment:
# Deactivate the virtual environment
deactivate
If you would like to run the examples, such as the Hello world example, you may need to install Docker and run a broker service. See the sections below for more information.
Docker¶
Docker is used to create containers for using the Python SDK and to run the examples. Download and install Docker using the instructions provided on their website.
Backing Services (Brokers, Data planes)¶
A Docker Compose configuration for SDK development is included below. This sets up the primary backing services (message brokers, data storage layers) needed to use INTERSECT.
Note that this configuration is meant for testing, and should not be included in production.
# Simple docker-compose file which sets up all needed backing services
# Note that for the broker, the default credentials are ` intersect_username / intersect_password `
services:
broker:
image: "bitnamilegacy/rabbitmq:4.1"
ports:
- "1883:1883" # MQTT port
- "5672:5672" # AMQP port
- "15672:15672" # Web UI
environment:
# full list of env variables available at https://github.com/bitnami/containers/blob/main/bitnami/rabbitmq/README.md
RABBITMQ_PLUGINS: "rabbitmq_management rabbitmq_mqtt"
RABBITMQ_USERNAME: "intersect_username"
RABBITMQ_PASSWORD: "intersect_password"
RABBITMQ_MANAGEMENT_ALLOW_WEB_ACCESS: "yes"
healthcheck:
test: rabbitmq-diagnostics -q ping && rabbitmq-diagnostics -q check_running && rabbitmq-diagnostics -q check_local_alarms
interval: 10s
retries: 5
start_period: 10s
timeout: 10s
minio:
image: "bitnamilegacy/minio:2024.6.4"
environment:
# references: https://github.com/bitnami/containers/blob/main/bitnami/minio/README.md
MINIO_ROOT_USER: AKIAIOSFODNN7EXAMPLE
MINIO_ROOT_PASSWORD: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
ports:
- "9000:9000" # main MINIO API port
- "9001:9001" # web UI
#volumes:
#- "./tmp/minio:/bitnami/minio/data"
From the repository root, run the backing services using the Docker commands shown below.
# if you are copypasting from this website instead of running from the repository root, you should make sure you copy the contents into docker-compose.yml.
docker compose up -d
To see the broker’s management UI, you can navigate to localhost:15672 in your browser. The login credentials mirror RABBITMQ_USERNAME and RABBITMQ_PASSWORD from the docker-compose file.
To cleanup:
docker compose down -v