GCP
wrappers
editor_agent
label_row_metadata_include_args- arguments to overwrite default arguments onproject.list_label_rows_v2().label_row_initialise_labels_args- Arguments to overwrite default arguments onlabel_row.initialise_labels(...)custom_cors_regex- A regex to use for the CORS settings. If not provided, the default regex is used. Only required if the agent is not deployed on Encord’s platform.
dependencies
FastAPI
cors
Convenience method to easily extend FastAPI servers with the appropriate CORS Middleware to allow interactions from the Encord platform.EncordCORSMiddleware Objects
fastapi.middleware.cors.CORSMiddleware but matches against
the Encord origin by default and handles X-Encord-Editor-Agent test header
Example:
The CORS middleware allows POST requests from the Encord domain.
EncordTestHeaderMiddleware Objects
dispatch
get_encord_app
custom_cors_regexstr | None, optional - A regex to use for the CORS middleware. Only necessary if you are not using the default Encord domain.
FastAPI- A FastAPI app with the Encord middleware.
utils
verify_auth
notifications
Receiving the task-ready notifications an agent stage sends. The verified notification is injected like any other dependency:project_hash is an input to check rather than an
instruction to follow. Decide which projects a deployment serves, and act only on
those.
Returning None answers 200, which is what Encord expects; it records any other
status as a failed delivery. Answer before doing the work, as above: Encord gives a
response 180 seconds and retries on timeout, so a handler that drains the stage inline
is re-notified while the first drain is still running.
Requests that cannot be verified never reach the route. They are turned into responses
by the handlers get_encord_app installs; on an app built by hand, call
add_notification_handlers instead, or they surface as unhandled errors.
dep_task_notification
project_hash names a project this deployment serves. Check that
before doing any work — see the example above.
The signing secret comes from ENCORD_WEBHOOK_SECRET. To pass one explicitly, or
to widen the timestamp tolerance, call verify_and_parse_notification from a
dependency of your own.
Raises:
WebhookVerificationError- The request is not provably from Encord.UnexpectedEventType- It is, but carries an event this receiver does not read.UnsupportedNotificationVersion- It is on an envelope version this package cannot read.
dep_task_notification_with_args
ENCORD_WEBHOOK_SECRET holds one secret. Use this where a single secret does not
cover everything a deployment verifies: it gives one route the secret to verify
against, rather than taking it from the environment.
Example:
secret- The signing secret this route verifies against. Read fromENCORD_WEBHOOK_SECRETwhen not given.tolerance_seconds- How far the signed timestamp may be from now. Widen it only for a deployment whose clock cannot be kept closer than the default.
Depends.
add_notification_handlers
get_encord_app
calls this already. Use it on an app constructed by hand, so that a request which
fails verification is refused rather than raised as an unhandled error.
Arguments:
app- The FastAPI app serving the notification route.
dependencies
Dependencies for injection in FastAPI servers. This module contains dependencies that you can inject within your api routes. Dependencies that depend on others don’t need to be used together. They’ll work just fine alone. Note that you can also use the function parameter:FrameData is automatically injected via the api request body.
dep_client
dep_label_row_with_args
label_row_metadata_include_args- What arguments to include on the metadata frontlabel_row_initialise_labels_args- How and whether to initialise the label rows
dep_label_row
frame_data- the frame data from the route. This parameter is automatically injected if it’s a part of your route (see example above)
dep_storage_item
StorageItem
is useful for multiple things like
- Updating client metadata
- Reading file properties like storage location, fps, duration, DICOM tags, etc.
dep_single_frame
lr.data_hash.{suffix}.
When the function has finished, the downloaded file is removed from the file system.
Example:
-
storage_item- The label row. Automatically injected (see example above). -
frame_data- the frame data from the route. This parameter is automatically injected if it’s a part of your route (see example above). -
Returns- Numpy array of shape [h, w, 3] RGB colors.
dep_asset
ValueError- if the underlying assets are not videos, images, or audio.EncordException- if data type not supported by SDK yet.
dep_video_iterator
storage_item- Automatically injected storage item dependency.
NotImplementedError- Fails for other data types than video.
dep_project
dep_data_lookup
dep_data_lookup is deprecated and will be removed in version 0.2.10.
Use dep_storage_item instead for accessing storage items.
Migration Guide:
lookup- The object that you can use to lookup data rows and storage items. Automatically injected.
dep_object_crops
filter_ontology_objects- Optional list of ontology objects to filter by. If provided, only instances of these object types are be included. Strings are matched againstfeature_node_hashes.

