Skip to main content
Prepare one retained evaluation fixture, then start two deterministic cases and one deliberately slow case from the same image. Record application item IDs, operation IDs, input image UUIDs, and result image UUIDs. Cancel only the slow operation owned_operations by this batch after collecting the other results.

Prerequisites

Complete Set up access. In a fresh project, run uv init --python 3.12 and uv add "contree-sdk[async]==0.5.1" "contree-client==0.6.0". The SDK reads the connection from your environment or saved profile; credentials stay in the local client and are not passed to guest code. The available tag:alpine:latest image supplies /bin/sh, mkdir, chmod, test, printf, sleep, and /etc/os-release. ContreeAsyncSession gives each case an independent VM. spawn() returns without waiting, allowing all three accepted operations to run concurrently. The pass case checks an existing file; test-fail checks a missing file. The slow case waits until cancellation, with a 120-second execution limit as a fallback. Final records must classify them as passed, test-failure, and cancelled. A nonzero command exit remains separate from platform failure. This batch submits exactly three cases. For larger datasets, hold a semaphore or worker slot from submission through terminal observation; limiting client connections alone does not limit remote work. See Run concurrent workloads.

Complete source

Save as bounded_eval.py and run uv run python bounded_eval.py. Output includes the fixture image, every accepted item and operation ID, detailed records, and:
Each result record includes the input image, operation ID, optional result image, outcome, and process evidence. Disposable cases have no result image. The retained fixture follows image retention. collect() records FailedOperationError as platform-failure, a confirmed cancelled operation as cancelled, and other transport or event-reading errors as observation-failure. An observation failure does not establish the remote operation outcome. This recipe confirms requested cancellation through the underlying client’s bounded status polling (follow_events=False), because cancelled operations can drop their event logs. collect() keeps those separate from workload exit codes, execution timeout, process signals, and truncated output. An accepted case starts with outcome=None. Cleanup inspects and cancels only handles in owned_operations; an unconfirmed cleanup becomes cleanup-uncertain. Operation shutdown closes its reader and attempts to stop work still running. Cleanup can extend the 90-second collection deadline while it resolves accepted work. If submission fails before an ID is returned, the outcome can be uncertain. Resolve that existing request before resubmitting. Recover cancelled work from the recorded fixture image, without assuming cancellation produced reusable state.