EncordUserClient Objects
EncordUserClient is the primary interface for interacting with Encord resources such as Projects, Datasets,
Collections, Workflows, and Storage Items. It manages authentication, request signing, and low-level
communication on behalf of the user.
Create a client with one of the create_* methods, for example
create_with_ssh_private_key() or
create_with_bearer_token(), rather than calling the constructor
directly. Then use its methods for:
- Listing or retrieving projects and datasets
- Accessing project configuration, ontology, and workflows
- Managing storage and data units
- Running analytics queries
- Interacting with collections and Curate
config- The user configuration containing authentication credentials and client options.querier- Internal HTTP/query executor used to communicate with the Encord API. Users do not normally construct this directly.
ml_models
MlModelsClient- Client for interacting with Encord’s ML models
get_bearer_token
str- The bearer token.
get_dataset
- A Dataset Admin or User
- An Admin of a project that uses the dataset
- An Organization admin, or a user with a custom organization role that can manage all datasets
dataset_hash- The Dataset IDdataset_access_settings- Set the dataset_access_settings if you would like to change the defaults.include_data_rows- Whether to eagerly fetch the dataset’s data rows. Defaults toTrue. Set toFalseto fetch dataset metadata only and avoid pulling every data row.
include_data_rows is True (the default).
get_project
project_hash- The Project ID
Project- The project. See Project for details.
get_ontology
ontology_hash- The ontology ID.
Ontology- The ontology, including its structure. See Ontology for details.
create_private_dataset
create_dataset instead.
create_dataset
dataset_titlestr - Title of the dataset.dataset_typeStorageLocation - Type of storage location where the data will be stored.dataset_descriptionOptional[str] - Optional description of the dataset.create_backing_folderbool - Whether to create a mirrored backing Folder. If True (default), the Folder and Dataset are synced. Recommended to set False for complex or large-scale projects.
CreateDatasetResponse- The title, storage location, and ID (dataset_hash) of the new dataset, and the UUID of its backing folder if one was created.
get_datasets
title_eq- Optional exact title filter.title_like- Optional title pattern in SQLLIKEsyntax, where%matches any characters. Matching is case-sensitive. For example,"%cars%"matches titles that contain “cars”.desc_eq- Optional exact description filter.desc_like- Optional description pattern in SQLLIKEsyntax, where%matches any characters. Matching is case-sensitive.created_before- Optional filter to only include results created on or before this date. Accepts adatetimeor a date string.created_after- Optional filter to only include results created on or after this date. Accepts adatetimeor a date string.edited_before- Optional filter to only include results last edited on or before this date. Accepts adatetimeor a date string.edited_after- Optional filter to only include results last edited on or after this date. Accepts adatetimeor a date string.include_org_access- if set to true and the calling user is the organization admin, the method returns all datasets in the organization.
"dataset" and "user_role" keys. If include_org_access is set to
True, some of the datasets may have a None value for the "user_role" key.
create_with_ssh_private_key
- ENCORD_SSH_KEY: environment variable with the private key content
- ENCORD_SSH_KEY_FILE: environment variable with the path to the key file
ssh_private_key- the private key contentpassword- private key passwordrequests_settings- Request settings. Useful default providedssh_private_key_path- the path to the private key filedomain- The underlying Encord domain to connect to. Only needs to be changed for US or Private Clouds.
EncordUserClient- A client authenticated with the SSH key.
create_with_bearer_token
token- The bearer token.requests_settings- Request settings. Useful default provided.domain- The underlying Encord domain to connect to. Only needs to be changed for US or Private Clouds.
EncordUserClient- A client authenticated with the bearer token.
get_projects
title_eq- Optional exact title filter.title_like- Optional title pattern in SQLLIKEsyntax, where%matches any characters. Matching is case-sensitive. For example,"%cars%"matches titles that contain “cars”.desc_eq- Optional exact description filter.desc_like- Optional description pattern in SQLLIKEsyntax, where%matches any characters. Matching is case-sensitive.created_before- Optional filter to only include results created on or before this date. Accepts adatetimeor a date string.created_after- Optional filter to only include results created on or after this date. Accepts adatetimeor a date string.edited_before- Optional filter to only include results last edited on or before this date. Accepts adatetimeor a date string.edited_after- Optional filter to only include results last edited on or after this date. Accepts adatetimeor a date string.
"project" and "user_role" keys.
list_projects
title_eq- Optional exact title filter.title_like- Optional title pattern in SQLLIKEsyntax, where%matches any characters. Matching is case-sensitive. For example,"%cars%"matches titles that contain “cars”.desc_eq- Optional exact description filter.desc_like- Optional description pattern in SQLLIKEsyntax, where%matches any characters. Matching is case-sensitive.created_before- Optional filter to only include results created on or before this date. Accepts adatetimeor a date string.created_after- Optional filter to only include results created on or after this date. Accepts adatetimeor a date string.edited_before- Optional filter to only include results last edited on or before this date. Accepts adatetimeor a date string.edited_after- Optional filter to only include results last edited on or after this date. Accepts adatetimeor a date string.include_org_access- if set to true and the calling user is the organization admin, the method will return all projects in the organization.tags_anyof- optional tag names filter; matches projects having at least one of the tag names. Accepts either tag name strings or OrganisationTag instances.
Iterable[Project]- The projects that match the filters, as Project instances. Projects are fetched page by page as you iterate.
list_organisation_tags
List[OrganisationTag]- All tags in the organization. Each can be attached to projects or to storage folders.
list_project_tags
List[OrganisationTag]- All tags in the organization.
create_organisation_tag
tags.manage permission).
Arguments:
name- Name of the tag. Must be unique within the organization.description- Optional free-text description of the tag.
OrganisationTag- The newly created tag.
encord.exceptions.ResourceExistsError- A tag with this name already exists.encord.exceptions.AuthorisationError- The caller is not an organization admin.
delete_organisation_tag
tag_name or tag_uuid. This detaches the tag from every
project and storage folder it is attached to. Requires the caller to be an organization admin (the
tags.manage permission).
Arguments:
tag- The tag to delete, as returned bycreate_organisation_tagorlist_organisation_tags.tag_name- Name of the tag to delete.tag_uuid- Unique identifier of the tag to delete.
ValueError- If the tag is not identified by exactly one oftag,tag_nameortag_uuid.TypeError-tagis not an OrganisationTag.encord.exceptions.ResourceNotFoundError- No tag with this name or UUID exists in the organization.encord.exceptions.AuthorisationError- The caller is not an organization admin.
create_project
project_title- the title of the Projectdataset_hashes- a list of the Dataset uids that the project will useproject_description- the optional description of the projectontology_hash- the uid of an Ontology to be used. If omitted, a new empty Ontology will be createdworkflow_settings- selects and configures the type of the quality control Workflow to use, See ProjectWorkflowSettings for details. If omitted, ManualReviewWorkflowSettings is used.workflow_template_hash- Project is created using a Workflow based on the template provided. If omitted, the project will be created using the default standard workflow.
get_dataset_client
get_project_client
create_project_from_cvat_start
import_method- The chosen import method. Currently, only LocalImport is supported.dataset_name- The name of the dataset that will be created.review_mode- Set how much interaction is needed from the labeler and reviewer for the CVAT labels. See theReviewModedocumentation for more details.transform_bounding_boxes_to_polygons- If True, all instances of CVAT bounding boxes will be converted to polygons in the final Encord project.
UUID- A unique identifier for tracking the import process.
ValueError- If the CVAT directory has an invalid format or if a non-LocalImport method is used.
create_project_from_cvat_get_result
cvat_import_uuid- The UUID returned by create_project_from_cvat_start.timeout_seconds- Maximum time in seconds to wait for the import to complete. Defaults to 24 hours. The method polls the server periodically during this time.
- CvatImporterSuccess: Contains project_hash, dataset_hash, and any issues if the import succeeded.
- CvatImporterError: Contains any issues if the import failed.
ValueError- If the server returns an unexpected status or invalid response structure.
create_project_from_cvat
import_method- The chosen import method. Currently, only LocalImport is supported.dataset_name- The name of the dataset that will be created.review_mode- Set how much interaction is needed from the labeler and reviewer for the CVAT labels. See theReviewModedocumentation for more details. Defaults to ReviewMode.LABELLED.transform_bounding_boxes_to_polygons- If True, all instances of CVAT bounding boxes will be converted to polygons in the final Encord project. Defaults to False.timeout_seconds- Maximum time in seconds to wait for the import to complete. Defaults to 24 hours. The method polls the server periodically during this time.
- CvatImporterSuccess: Contains project_hash, dataset_hash, and any issues if the import succeeded.
- CvatImporterError: Contains any issues if the import failed.
ValueError- If the CVAT directory has an invalid format, if a non-LocalImport method is used, or if the server returns an unexpected status.
get_cloud_integrations
filter_integration_uuids and filter_integration_titles are both provided, the method returns
the integrations that match both of the filters.
Arguments:
filter_integration_uuids- optional list of integration UUIDs to include.filter_integration_titles- optional list of integration titles to include (exact match).include_org_access- if set to true and the calling user is the organization admin, the method will return all cloud integrations in the organization.
get_ontologies
title_eq- Optional exact title filter.title_like- Optional title pattern in SQLLIKEsyntax, where%matches any characters. Matching is case-sensitive. For example,"%cars%"matches titles that contain “cars”.desc_eq- Optional exact description filter.desc_like- Optional description pattern in SQLLIKEsyntax, where%matches any characters. Matching is case-sensitive.created_before- Optional filter to only include results created on or before this date. Accepts adatetimeor a date string.created_after- Optional filter to only include results created on or after this date. Accepts adatetimeor a date string.edited_before- Optional filter to only include results last edited on or before this date. Accepts adatetimeor a date string.edited_after- Optional filter to only include results last edited on or after this date. Accepts adatetimeor a date string.include_org_access- if set to true and the calling user is the organization admin, the method will return all ontologies in the organization.
"ontology" and "user_role" keys. If include_org_access is set to
True, some of the ontologies may have a None value for the "user_role" key.
create_ontology
titlestr - The title of the ontology.descriptionstr, optional - A brief description of the ontology. Defaults to an empty string.structureOptional[OntologyStructure], optional - The structural definition of the ontology. If not provided, a default structure is used.
Ontology- The newly created ontology object.
ValueError- If the provided structure contains a classification without any attributes.
list_groups
Iterator[Group]- The groups in the organization. See Group for details.
create_group
name- The name of the group.description- An optional description of the group.
Group- The newly created group. See Group for details.
get_group
group_hash- The unique identifier of the group to retrieve.
Group- The group. See Group for details.
ValueError- Ifgroup_hashis a badly formed UUID.ResourceNotFoundError- If no group with the given UUID exists in the organization.
delete_group
group_hash- The unique identifier of the group to delete.
ValueError- Ifgroup_hashis a badly formed UUID.
list_organisation_users
List[OrganisationUser]- The organization’s users, including their organization role and member type.
add_organisation_user
email- The email address of the user to add.role_mnemonic_name- Mnemonic name of the organization role to assign, one of"ADMIN","MEMBER","TASKER"or"WORKFORCE_MANAGER".member_type- Whether the user is an"internal"member of your organization or an"external"collaborator (e.g. from another company). Only internal members can hold the"ADMIN"role.
ResourceExistsError- If the user is already a member of the organization. Callers that only need to ensure the membership exists can treat this as a success.
remove_organisation_user
email- The email address of the user to remove.
ResourceNotFoundError- If no Encord account exists for the email.
deidentify_dicom_files_start
dicom_urls- A list of URLs pointing to DICOM files to be deidentified.integration_hash- Integration hash for the external storage integration.redact_dicom_tags- Flag to enable or disable DICOM tags redaction. Defaults to True.redact_pixels_mode- Policy for redacting text in pixel data. Defaults to DeidentifyRedactTextMode.REDACT_NO_TEXT.save_conditions- Optional list of conditions that must be met for a deidentified DICOM file to be saved.upload_dir- Optional directory for uploading deidentified files. If None, files will be uploaded to the same directory as source files.
deidentify_dicom_files_get_result
dicom_deid_uuid- The UUID of the deidentification job returned by deidentify_dicom_files_start(…).timeout_seconds- Maximum time to wait for job completion. Defaults to 1 day (86400 seconds).
deidentify_dicom_files
- x00080018 SOPInstanceUID
- x00100010 PatientName
- x00180050 SliceThickness
- x00180088 SpacingBetweenSlices
- x0020000d StudyInstanceUID
- x0020000e SeriesInstanceUID
- x00200032 ImagePositionPatient
- x00200037 ImageOrientationPatient
- x00280008 NumberOfFrames
- x00281050 WindowCenter
- x00281051 WindowWidth
- x00520014 ALinePixelSpacing
dicom_urls- a list of urls to DICOM files, for example:[ "https://s3.region-code.amazonaws.com/bucket-name/dicom-file-input.dcm" ]integration_hash- integration_hash parameter of Encord platform external storage integrationredact_dicom_tags- Specifies if DICOM tags redaction should be enabled.redact_pixels_mode- Specifies which text redaction policy should be applied to pixel data.save_conditions- Specifies a list of conditions which all have to be true for DICOM deidentified file to be saved.upload_dir- Specifies a directory that files will be uploaded to. By default, set to None, deidentified files will be uploaded to the same directory as source files.
[ "https://s3.region-code.amazonaws.com/bucket-name/deid_167294769118005312_dicom-file-input.dcm" ]
create_storage_folder
name- The name of the folder.description- The description of the folder.client_metadata- Optional arbitrary metadata to be associated with the folder. Should be a dictionary that is JSON-serializable.parent_folder- The parent folder of the folder; orNoneif the folder is to be created at the root level.cloud_synced_folder_params- Passing this will create cloud synced folder, leaving this aNonewill create a normal folder for further data uploads.
get_storage_folder
folder_uuid- The UUID of the folder to retrieve.
ValueError- Iffolder_uuidis a badly formed UUID.AuthorisationError- If the folder with the given UUID does not exist or the user does not have access to it.
get_storage_item
item_uuid- The UUID of the item to retrieve.sign_url- IfTrue, pre-fetch a signed URL for the item (otherwise the URL will be signed on demand).
ValueError- Ifitem_uuidis a badly formed UUID.AuthorisationError- If the item with the given UUID does not exist or the user does not have access to it.
get_storage_items
item_uuids- list of UUIDs of items to retrieve. Can be a list of strings or a list of UUID objects.sign_url- IfTrue, pre-fetch a signed URLs for the items (otherwise the URLs will be signed on demand).
item_uuids in the request
Raises:
ValueError- If any of the item uuids is a badly formed UUID.AuthorisationError- If some of the items with the given UUIDs do not exist or the user does not have access to them.
list_storage_folders
search- Search string to filter folders by name (optional)dataset_synced- Include or exclude folders that are mirrored by a dataset. Optional; ifNone, no filtering is applied.org_access- IfTrue, and if the caller isADMINof their organization, the results contain the folders belonging to the organization, instead of those accessible to the user. If enabled but the user is not an organization admin, theAuthorisationErroris raised. Default value isFalse.organisation_tags_allofOptional[Union[List[str], List[OrganisationTag]]] - Optional organisation-tag filter; matches only folders tagged with all of the given tags. Accepts either tag name strings or OrganisationTag instances (as returned by list_organisation_tags()). Tag names are matched exactly and are case-sensitive. The whole filter is a conjunction, so every name must resolve: if any string name is unknown, no folders are listed and a ResourceNotFoundError naming every unknown tag is raised before the folder is found.order- Sort order for the folders. See FoldersSortBy for available options.desc- If True, sort in descending order.page_size- Number of folders to return per page. Default if not specified is 100. Maximum value is 1000.
ResourceNotFoundError- One or moreorganisation_tags_allofnames do not match any organization tag. The error lists every unknown name.
find_storage_folders
search- Search string to filter folders by name (optional)dataset_synced- Include or exclude folders that are mirrored by a dataset. Optional; ifNone, no filtering is applied.org_access- IfTrue, and if the caller isADMINof their organization, the results contain the folders belonging to the organization, instead of those accessible to the user. If enabled but the user is not an organization admin, theAuthorisationErroris raised. Default value isFalse.organisation_tags_allofOptional[Union[List[str], List[OrganisationTag]]] - Optional organisation-tag filter; matches only folders tagged with all of the given tags. Accepts either tag name strings or OrganisationTag instances (as returned by list_organisation_tags()). Tag names are matched exactly and are case-sensitive. The whole filter is a conjunction, so every name must resolve: if any string name is unknown, no folders are listed and a ResourceNotFoundError naming every unknown tag is raised before the folder is found.order- Sort order for the folders. See FoldersSortBy for available options.desc- If True, sort in descending order.page_size- Number of folders to return per page. Default if not specified is 100. Maximum value is 1000.
ResourceNotFoundError- One or moreorganisation_tags_allofnames do not match any organization tag. The error lists every unknown name.
patch_storage_items_client_metadata
patches- Mapping from item UUID to the keys to add, change or remove for that item.timeout_seconds- How long to wait for all the patches to be applied.
ValueError- A patch is too large to send; nothing is sent.AuthorisationError- The first job has an item you cannot edit; nothing is started.ClientMetadataPatchPartiallyStartedError- Some jobs started, then the next could not be (for example, it has an item you cannot edit). Raised without waiting for the started jobs, which keep running; the error lists them, and the items whose patches were not sent.ClientMetadataPatchTimeoutError- Some jobs had not finished aftertimeout_seconds. They were not cancelled; the error lists them, and the failures reported so far.ClientMetadataPatchWaitError- Waiting for the jobs failed with another error. They were not cancelled; the error lists those not yet checked, and the failures reported so far.
start_client_metadata_patch_jobs
patches- Mapping from item UUID to the keys to add, change or remove for that item.
ValueError- A patch is too large to send; nothing is sent.AuthorisationError- The first job has an item you cannot edit; nothing is started.ClientMetadataPatchPartiallyStartedError- Some jobs started, then the next could not be (for example, it has an item you cannot edit). The error lists the started jobs, which keep running, and the items whose patches were not sent.
get_client_metadata_patch_job
job_uuid- The job, as returned by start_client_metadata_patch_jobs().
patch_storage_items_client_metadata_by_url
patches- Mapping from object URL to the keys to add, change or remove for the items with that URL.folders- The folders to look in. Look in the whole organization if omitted.timeout_seconds- How long to wait for all the patches to be applied.
ValueError-foldersor an object URL is empty, or a patch is too large to send; nothing is sent.AuthorisationError- You do not have access to one of the givenfolders, or the first job has an item you cannot edit, or one deleted since it was found; nothing is started.ClientMetadataPatchPartiallyStartedError- Some jobs started, then the next could not be (for example, it has an item you cannot edit). Raised without waiting for the started jobs, which keep running; the error lists them, with the items found for each URL, and the items whose patches were not sent.ClientMetadataPatchTimeoutError- Some jobs had not finished aftertimeout_seconds. They were not cancelled; the error lists them, with the items found for each URL, and the failures reported so far.ClientMetadataPatchWaitError- Waiting for the jobs failed with another error. They were not cancelled; the error lists those not yet checked, with the items found for each URL, and the failures reported so far.
start_client_metadata_patch_jobs_by_url
folders (not their subfolders) or, without folders, anywhere in your
organization; items in cloud synced folders are left out, as their client metadata can’t be patched. The
patches are split into jobs as with start_client_metadata_patch_jobs(); check each job with
get_client_metadata_patch_job().
Example:
patches- Mapping from object URL to the keys to add, change or remove for the items with that URL.folders- The folders to look in. Look in the whole organization if omitted.
ValueError-foldersor an object URL is empty, or a patch is too large to send; nothing is sent.AuthorisationError- You do not have access to one of the givenfolders, or the first job has an item you cannot edit, or one deleted since it was found; nothing is started.ClientMetadataPatchPartiallyStartedError- Some jobs started, then the next could not be (for example, it has an item you cannot edit). The started jobs keep running; the error lists them, with the items found for each URL, and the items whose patches were not sent.
find_storage_items
search or item_types must be provided.
Arguments:
search- Search string to filter items by name.is_in_dataset- Filter items by whether they are linked to any dataset.TrueandFalseselect only linked and only unlinked items, respectively.Noneincludes all items regardless of their dataset links.item_types- Filter items by type.org_access- IfTrue, and if the caller isADMINof their organization, the results contain the items belonging to the organization, instead of those accessible to the user. If enabled but the user is not an organization admin, theAuthorisationErroris raised. Default value isFalse.order- Sort order.desc- Sort in descending order.get_signed_urls- If True, return signed URLs for the items.page_size- Number of items to return per page. Default if not specified is 100. Maximum value is 1000.
metadata_schema
MetadataSchema- The organization’s metadata schema. See MetadataSchema for details.
get_collection
collection_uuid- The unique identifier of the collection to retrieve.
ValueError- Ifcollection_uuidis a badly formed UUID.AuthorisationError- If the item with the given UUID does not exist or the user does not have access to it.
list_collections
top_level_folder_uuid and collection_uuids are provided, only collections that match both
are returned.
Arguments:
top_level_folder_uuid- The unique identifier of the top level folder.collection_uuids- The unique identifiers (UUIDs) of the collections to retrieve.page_sizeint - Number of items to return per page. Default if not specified is 100. Maximum value is 1000.
ValueError- Iftop_level_folder_uuidor any of the collection uuids is a badly formed UUID.AuthorisationError- If the user does not have access to it.
delete_collection
collection_uuid- The unique identifier (UUID) of the collection to delete.
ValueError- Ifcollection_uuidis a badly formed UUID.AuthorisationError- If the user does not have access to it.
create_collection
top_level_folder_uuid- The unique identifier (UUID) of the folder that the collection is created in.name- The name of the collection.description- The description of the collection.
Collection- Newly created collection.
ValueError- Iftop_level_folder_uuidis a badly formed UUID.AuthorisationError- If the user does not have access to the folder.
create_label_set
name- Name of the label set.sources- The project branches a version captures. The platform accepts one source today and refuses more.mainholds the labels made in the project; any other branch holds labels written from outside, such as model predictions. Each source carries its ownlabel_selection: AllSelection, the default, is every label on the branch, and a WorkflowStageSelection captures the tasks at the given stages and applies to themainbranch only.description- Description of the label set.origin- Where the branch’s labels come from.IMPORTfor predictions and other labels written to the branch from outside; such a set has no scheduled versions.
LabelSet- The new label set.
ValueError-originisLabelSetOrigin.UNKNOWN, which only appears on a set read from a platform newer than this SDK and cannot be sent.ResourceNotFoundError- Label sets are not enabled for your organisation.AuthorisationError- You are not an admin or team manager on a source project.EncordException- More sources were given than the platform supports, or a stage selection was given for a branch other thanmain.
get_label_set
label_set_id- The label set.
LabelSet- The label set. See LabelSet.
ValueError-label_set_idis a badly formed UUID.ResourceNotFoundError- The label set does not exist, label sets are not enabled for your organisation, or you have no role on the project that feeds it.
list_label_sets
project_id- Only the sets this project feeds.page_size- Number of sets per page. Default 100, maximum 100.
Iterator[LabelSet]- The label sets with their source IDs, projects and branches. Call refetch_data() on a listed set and read its sources again before accessing a source’slabel_selection.
ValueError-project_idis a badly formed UUID.ResourceNotFoundError- Label sets are not enabled for your organisation.AuthorisationError- You have no role onproject_id.
get_filter_preset
preset_uuid- The unique identifier of the preset to retrieve.
ValueError- Ifpreset_uuidis a badly formed UUID.AuthorisationError- If the item with the given UUID does not exist or the user does not have access to it.
get_filter_presets
preset_uuids- The list of unique identifiers (UUIDs) to be retrieved.page_sizeint - Number of items to return per page. Default if not specified is 100. Maximum value is 1000.
ValueError- If any of the preset uuids is a badly formed UUID.AuthorisationError- If the user does not have access to it.
list_presets
top_level_folder_uuid- The unique identifier of the top level folder.page_sizeint - Number of items to return per page. Default if not specified is 100. Maximum value is 1000.
ValueError- Iftop_level_folder_uuidis a badly formed UUID.AuthorisationError- If the user does not have access to it.
create_preset
name- The name of the preset.description- The description of the preset.filter_preset_json- The filters for the preset in their raw json format.
FilterPreset- The newly created preset.
delete_preset
preset_uuid- The uuid/id of the preset to delete.
ValueError- Ifpreset_uuidis a badly formed UUID.AuthorisationError- If the user does not have access to it.
ListingFilter Objects
*_before and *_after should be datetime objects.
