An example robot producing toy enhancements against destiny repository.
uv is used for dependency management and managing virtual environments. You can install uv either using pipx or the uv installer script:
curl -LsSf https://astral.sh/uv/install.sh | shOnce uv is installed, install dependencies:
uv syncsource .venv/bin/activateBefore commiting any changes, please run the pre-commit hooks. This will ensure that the code is formatted correctly and minimise diffs to code changes when submitting a pull request.
Install the pre-commit hooks:
uv run pre-commit installpre-commit hooks will run automatically when you commit changes. To run them manually, use:
uv run pre-commit run --all-filesSee .pre-commit-config.yaml for the list of pre-commit hooks and their configuration.
Copy the example .env.example file:
cp .env.example .envThe robot can be configured using environment variables:
DESTINY_REPOSITORY_URL: URL of the destiny repository to pollROBOT_ID: The robot's client ID for authenticationROBOT_SECRET: The robot's secret key for HMAC authenticationPOLL_INTERVAL_SECONDS: How often to poll for new batches (default: 30)BATCH_SIZE: The number of references to include per enhancement batch (default: 5)
Run the robot:
uv run python run_robot.py sequenceDiagram
participant Data Repository
participant Blob Storage
participant Robot
Note over Data Repository: Enhancement request is RECEIVED
Robot->>Data Repository: POST /robot-enhancement-batches/ : Poll for batches
Data Repository->>+Blob Storage: Store requested references and dependent data
Data Repository->>Robot: RobotEnhancementBatch (batch of references)
Note over Data Repository: Request status: PROCESSING
Blob Storage->>-Robot: GET reference_storage_url (download references)
Robot-->>Robot: Process references and create enhancements
alt More batches available
Robot->>Data Repository: POST /robot-enhancement-batches/ : Poll for next batch
Data Repository->>Robot: RobotEnhancementBatch (next batch)
Note over Robot: Process additional batches...
else No more batches
Robot->>Data Repository: POST /robot-enhancement-batches/ : Poll for batches
Data Repository->>Robot: HTTP 204 No Content
end
alt Batch success
Robot->>+Blob Storage: PUT result_storage_url (upload enhancements)
Robot->>Data Repository: POST /robot-enhancement-batches/<batch_id>/results/ : RobotEnhancementBatchResult
else Batch failure
Robot->>Data Repository: POST /robot-enhancement-batches/<batch_id>/results/ : RobotEnhancementBatchResult(error)
end
Note over Robot: Repeat...
Blob Storage->>-Data Repository: Validate and import all enhancements
Note over Data Repository: Update request state to IMPORTING → INDEXING → COMPLETED
Authentication between the Toy Robot and Destiny Repository uses HMAC authentication, where a request signature is encrypted with the robot's secret key and set as a header. To simplify this process, the destiny_sdk provides a client for communicating with destiny repository that handles adding signatures. In Toy Robot the client is inititalised in main.py and used for sending requests.
- If you are running the toy robot with a local instance of destiny repository that is not enforcing authentication, add
ENV=localto your.envfile. This will cause the toy-robot to bypass authentication. This is to allow easy development only and the robot should not be deployed withenv=local.- In this case you will need to set dummy values for the
ROBOT_IDand theROBOT_SECRET. For exampleROBOT_ID="9fa8b9bd-12b1-4450-affb-712face23390"andROBOT_SECRET="dummy_secret"
- In this case you will need to set dummy values for the
- If you want to deploy the Toy Robot and use it with destiny repository, the robot will need to be registered with that deployment of destiny repository. The registration process will provide the robot_id and client_secret needed to configure authentication. You can check out the proceedure for registering a robot here.
When building the docker image
docker buildx build --tag toy-robot .Run the docker container
docker run -p 8001:8001 toy-robotIf you want to deploy the toy robot into Azure using the provided terraform infrastructure, you'll need to manually push the docker image to a container registry. We're using destiny-shared-infra for this.
az login
docker buildx build --platform linux/amd64 --tag destinyevidenceregistry.azurecr.io/toy-robot:[YOUR_TAG] .
az acr login --name destinyevidenceregistry
docker push destinyevidenceregistry.azurecr.io/toy-robot:YOUR_TAGThen you can deploy your image to the container app
az containerapp update -n toy-robot-stag-app -g rg-toy-robot-staging --image estinyevidenceregistry.azurecr.io/toy-robot:YOUR_TAGThen you can restart the revision with the following command
az containerapp revision restart --name toy-robot-stag-app --resource-group rg-toy-robot-staging --revision [REVISION_NAME]