Skip to main content

AWS Lambda

wrappers

editor_agent

Wrapper to make resources available for AWS Lambda Custom Agents.

Dependencies

DAssetPath

Get a local file path to data asset temporarily stored till end of agent execution.

dep_asset

Returns a local file path to the data asset, temporarily stored for the duration of the agent’s execution. This dependency fetches the underlying data asset using a signed URL. The asset is temporarily stored on disk for the duration of the task and is automatically removed once the task completes. Example:
Returns: The path to the asset. Raises:
  • ValueError - if the underlying assets are not videos, images, or audio.
  • EncordException - if data type not supported by SDK yet.

DEncordClient

Get an authenticated user client.

dep_client

Dependency to provide an authenticated user client. Example:

DObjectCrops

Get all object crops that the agent was triggered on. The instance crop contains the object instance, the frame content (pixel values), and the frame.

dep_object_crops

Returns a list of object instances and frame crops associated with each object. One example use-case is to run each crop against a model. Example:
Arguments:
  • filter_ontology_objects - Specify a list of ontology objects to include. If provided, only instances of these object types are included. Strings are matched against feature_node_hashes.
  • Returns - The dependency to be injected into the cloud function.

DObjectsInstances

Get all object instances that the agent was triggered on. No pixels, just the annotation.

dep_objects

Description not available in Core reference MDX.

DSingleFrame

Get the single frame that the agent was triggered on.

dep_single_frame

Dependency to inject the first frame of the underlying asset. The downloaded asset will be named lr.data_hash.{suffix}. When the function has finished running, the downloaded file is removed from the file system. Example:
Arguments:
  • storage_item - The Storage item. Automatically injected (see example above).
Returns: Numpy array of shape [h, w, 3] RGB colors.

DStorageItem

Get the storage item associated with the underlying agent task to, for example, read/write client metadata or read data properties.

dependencies.shares

DataLookup Objects

!!! warning “Deprecated” DataLookup is deprecated and will be removed in version 0.2.10. Migration Guide:
  • For accessing storage items, use dep_storage_item instead:

dep_storage_item

Get the storage item associated with the underlying agent task. The StorageItem is useful for multiple things like
  • Updating client metadata
  • Reading file properties like storage location, fps, duration, DICOM tags, etc.
Example

DVideoIterator

Get a video frame iterator for doing things over many frames.

dep_video_iterator

Dependency to inject a video frame iterator for performing operations over many frames. Example:
Arguments:
  • storage_item - Automatically injected storage item dependency.
Raises:
  • NotImplementedError - Fails for data types other than video.
Yields: An iterator.

GCP

wrappers

editor_agent

Wrapper to make resources available for GCP Custom Agents. The Custom Agents are intended to be used with dependency injections. Arguments:
  • label_row_metadata_include_args - arguments to overwrite default arguments on project.list_label_rows_v2().
  • label_row_initialise_labels_args - Arguments to overwrite default arguments on label_row.initialise_labels(...)
  • custom_cors_regex - A regex to use for the CORS settings. If not provided, the default regex will be used. Only required if the agent is not deployed on Encord’s platform.
Returns: A wrapped function suitable for gcp functions.

Dependencies

DAssetPath

Get a local file path to data asset temporarily stored till end of agent execution.

dep_asset

Returns a local file path to the data asset, temporarily stored for the duration of the agent’s execution. This dependency fetches the underlying data asset using a signed URL. The asset is temporarily stored on disk for the duration of the task and is automatically removed once the task completes. Example:
Returns: The path to the asset. Raises:
  • ValueError - if the underlying assets are not videos, images, or audio.
  • EncordException - if data type not supported by SDK yet.

DEncordClient

Get an authenticated user client.

dep_client

Dependency to provide an authenticated user client. Example:

DObjectCrops

Get all object crops that the agent was triggered on. The instance crop contains the object instance, the frame content (pixel values), and the frame.

dep_object_crops

Returns a list of object instances and frame crops associated with each object. One example use-case is to run each crop against a model. Example:
Arguments:
  • filter_ontology_objects - Specify a list of ontology objects to include. If provided, only instances of these object types are included. Strings are matched against feature_node_hashes.
  • Returns - The dependency to be injected into the cloud function.

DObjectsInstances

Get all object instances that the agent was triggered on. No pixels, just the annotation.

dep_objects

Description not available in Core reference MDX.

DSingleFrame

Get the single frame that the agent was triggered on.

dep_single_frame

Dependency to inject the first frame of the underlying asset. The downloaded asset will be named lr.data_hash.{suffix}. When the function has finished running, the downloaded file is removed from the file system. Example:
Arguments:
  • storage_item - The Storage item. Automatically injected (see example above).
Returns: Numpy array of shape [h, w, 3] RGB colors.

DStorageItem

Get the storage item associated with the underlying agent task to, for example, read/write client metadata or read data properties.

dependencies.shares

DataLookup Objects

!!! warning “Deprecated” DataLookup is deprecated and will be removed in version 0.2.10. Migration Guide:
  • For accessing storage items, use dep_storage_item instead:

dep_storage_item

Get the storage item associated with the underlying agent task. The StorageItem is useful for multiple things like
  • Updating client metadata
  • Reading file properties like storage location, fps, duration, DICOM tags, etc.
Example

DVideoIterator

Get a video frame iterator for doing things over many frames.

dep_video_iterator

Dependency to inject a video frame iterator for performing operations over many frames. Example:
Arguments:
  • storage_item - Automatically injected storage item dependency.
Raises:
  • NotImplementedError - Fails for data types other than video.
Yields: An iterator.

FastAPI

cors

Convenience method to easily extend FastAPI servers with the appropriate CORS Middleware to allow interactions from the Encord platform.

EncordCORSMiddleware Objects

Like a regular fastapi.middleware.cors.CORSMiddleware but matches against the Encord origin by default and handles X-Encord-Editor-Agent test header Example: The CORS middleware will allow POST requests from the Encord domain.

EncordTestHeaderMiddleware Objects

dispatch

Middleware to handle the X-Encord-Editor-Agent test header. Arguments: request (Request): call_next (RequestResponseEndpoint): Returns: Response

get_encord_app

Get a FastAPI app with the Encord middleware. Arguments:
  • custom_cors_regex str | None, optional - A regex to use for the CORS middleware. Only necessary if you are not using the default Encord domain.
Returns:
  • FastAPI - A FastAPI app with the Encord middleware.

utils

verify_auth

FastAPI lifecycle start hook to fail early if access key is missing. Example: This will make the server fail early if auth is not set up.

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

Dependency to provide an authenticated user client. Example:

dep_label_row_with_args

Dependency to provide an initialized label row. Example:
Arguments:
  • label_row_metadata_include_args - What arguments to include on the metadata front
  • label_row_initialise_labels_args - How and whether to initialize the label rows
Returns: The initialized label row.

dep_label_row

Dependency to provide an initialized label row. Example:
Arguments:
  • 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: The initialized label row.

dep_storage_item

Get the storage item associated with the underlying agent task. The StorageItem is useful for multiple things like
  • Updating client metadata
  • Reading file properties like storage location, fps, duration, DICOM tags, etc.
Example

dep_single_frame

Dependency to inject the underlying asset of the frame data. The downloaded asset will be named lr.data_hash.{suffix}. When the function has finished, the downloaded file will be removed from the file system. Example:
Arguments:
  • 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

Get a local file path to data asset temporarily stored till end of agent execution. This dependency will fetch the underlying data asset based on a signed url. It will temporarily store the data on disk. Once the task is completed, the asset will be removed from disk again. Example:
Returns: The path to the asset. Raises:
  • ValueError - if the underlying assets are not videos, images, or audio.
  • EncordException - if data type not supported by SDK yet.

dep_video_iterator

Dependency to inject a video frame iterator for doing things over many frames. Example:
Arguments:
  • storage_item - Automatically injected storage item dependency.
Raises:
  • NotImplementedError - Will fail for other data types than video.
Yields: An iterator.

dep_project

Dependency to provide an instantiated Project. Example:
Arguments: frame_data: client:

dep_data_lookup

Get a lookup to easily retrieve data rows and storage items associated with the given task. !!! warning “Deprecated” 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:
Arguments:
  • lookup - The object that you can use to lookup data rows and storage items. Automatically injected.
Returns: The (shared) lookup object.

dep_object_crops

Create a dependency that provides crops of object instances. Useful, e.g., to be able to run each crop against a model. Example:
Arguments:
  • filter_ontology_objects - Optional list of ontology objects to filter by. If provided, only instances of these object types will be included. Strings are matched against feature_node_hashes.
Returns: A FastAPI dependency function that yields a list of InstanceCrop.