Run a task
Inside a Wherobots notebook or job, the Wherobots Python SDK uses your Wherobots credentials. Anywhere else, set a Wherobots API key inWHEROBOTS_API_KEY. The SDK needs Python 3.11 or later.
Run states
A run starts asPENDING, and is still in progress while its state is PENDING, SUBMITTED, RUNNING or CANCELLING. When a run stops, read its state:
SUCCEEDED:resultsholds the task’s output.- Any other final state:
error_messagesays why.
run_and_wait polls the run until it stops, every 5 seconds at first and then less often, up to every 30 seconds. When the run succeeds, read its named outputs from run.results. For a task with a single output, run.output returns that value. Any other final state raises wherobots.WherobotsTaskRunError with the run’s error_message. Stopping the wait, with Ctrl-C or max_wait_seconds, doesn’t stop the run: resume waiting with wb.task_runs.wait_for_completion(task_run_id), or stop the run with wb.task_runs.cancel(task_run_id).
A run’s state can lag the run by up to two minutes, so over REST, poll every 30 seconds or so rather than in a tight loop. If you pass inputs that don’t match the task’s input schema, the API rejects the run with a 400 error before anything is launched or billed.
Task run results
When a run succeeds,results holds its named outputs. Most tasks return a single URI:
The recipe tasks,
predict_mosaic_recipe and predict_mosaic_geometries_recipe, each return input_mosaic and a task-specific prediction output:
input_mosaic: the imagery the run built.mosaic_index_uriis its mosaic index, andfirst_row_mosaicis the first Zarr store in it.prediction_mosaicholds the prediction mosaic frompredict_mosaic_recipe. Itsmosaic_index_uripoints to the prediction index.detection_geometriesholds the GeoParquet directory URI frompredict_mosaic_geometries_recipe, or null when nothing cleared the confidence threshold.
run.results["prediction_mosaic"]["mosaic_index_uri"] for predict_mosaic_recipe, and run.results["detection_geometries"] for predict_mosaic_geometries_recipe.
To download an output from outside Wherobots, see Download a task run’s results.
Areas of interest
For mosaic builds, inference recipes, and mosaic change detection, pass the area of interest inaoi. The value can be an S3 URI of a GeoParquet or GeoJSON file, or a polygon or multipolygon
WKT string with longitude/latitude coordinates in EPSG:4326. You do not need to upload a file
to use inline WKT. For mosaic builds with inline WKT, also supply target_crs for the output grid.
Choose NAIP resolution for SAM3
When you runpredict_mosaic_geometries_recipe with sam3-text-geometry (polygons) or sam3-text-bbox (bounding boxes), you can omit naip_resolution or set it to "auto". The recipe uses one native NAIP RGB resolution for the whole run. It prefers 30 cm and uses 60 cm when only 60 cm qualifies.
For each AOI feature, the recipe checks every year with imagery on that feature between start and end, inclusive. The same resolution must cover the entire feature and at least 90% of the surrounding area the model reads, including the feature. If different features or years need different resolutions, split the request by the rows or years listed in the error. If a feature has no imagery in the interval, change the dates or the area.
To keep the College Park example at 30 cm, add this field to its inputs object. Use "60cm" for an area and date range with native 60 cm coverage.
Find a task’s inputs and outputs
Each task describes itself. With the Python SDK,wb.tasks.get(...) returns its description, input_schema, output_schema and examples:
wb.tasks.list() lists every task your Organization can run. If your list includes run_mosaics_change, use alpha_earth_cosine_distance for AlphaEarth Foundations embeddings. For floating-point embeddings, choose cosine_distance or euclidean. See the task’s input schema for the scoring defaults.
The Tasks API reference documents the endpoints these calls use, including Get a task and List tasks. It doesn’t list each task’s inputs: those come from the task itself, in the inputSchema that Get a task returns, so they always match what the task accepts.
Region
Passregion="aws-us-west-2" (or "region": "aws-us-west-2" with the REST API) on every run. Without it, the run uses your Organization’s default region.
During Public Preview, RasterFlow is available in
aws-us-west-2. If you’re interested in running RasterFlow in another region, contact Wherobots.
