Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/source/code_examples/labels_v2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Working with the LabelRowV2
===========================

The :class:`encord.objects.LabelRowV2` class is a wrapper around the Encord label row data format. It
The :class:`encord.objects.ontology_labels_impl.LabelRowV2` class is a wrapper around the Encord label row data format. It
provides a convenient way to read, create, and manipulate labels.
"""

Expand Down Expand Up @@ -63,14 +63,14 @@
print(f"Annotation task status: {label_row.annotation_task_status}")

# %%
# Inspect the filters in :meth:`~encord.project.Project.list_label_rows_v2` to only get a subset of the label rows.
# Inspect the filters in :meth:`encord.project.Project.list_label_rows_v2` to only get a subset of the label rows.
#
# You can find more examples around all the available read properties by inspecting the properties of the
# :class:`~encord.objects.LabelRowV2` class.
# :class:`encord.objects.ontology_labels_impl.LabelRowV2` class.
#
# Exporting labels
# --------------------------------
# To export or download labels, or perform any other function that includes reading or writing labels, call the :meth:`~encord.objects.LabelRowV2.initialise_labels`
# To export or download labels, or perform any other function that includes reading or writing labels, call the :meth:`encord.objects.ontology_labels_impl.LabelRowV2.initialise_labels`
# method, which will download the state of the label from the Encord server and create a label hash if none exists.
#
# Once this method has been called, you can create your first label.
Expand All @@ -83,7 +83,7 @@
# %%
# Saving labels
# --------------------------------
# Once :meth:`~encord.objects.LabelRowV2.initialise_labels` has been called, you can create your first label.
# Once :meth:`encord.objects.ontology_labels_impl.LabelRowV2.initialise_labels` has been called, you can create your first label.

first_label_row: LabelRowV2 = label_rows[0]

Expand All @@ -99,7 +99,7 @@
# %%
# Creating/reading object instances
# ---------------------------------
# The :class:`encord.objects.LabelRowV2` class works with its corresponding ontology. If you add object instances
# The :class:`encord.objects.ontology_labels_impl.LabelRowV2` class works with its corresponding ontology. If you add object instances
# or classification instances, these will be created from the ontology. You can read more about object instances
# here: https://docs.encord.com/docs/annotate-working-with-ontologies#objects
#
Expand All @@ -109,7 +109,7 @@
# Finding the ontology object
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# The LabelRowV2 is designed to work with its corresponding ontology via the :class:`~encord.objects.ontology_labels_impl.OntologyStructure`.
# The LabelRowV2 is designed to work with its corresponding ontology via the :class:`encord.objects.ontology_labels_impl.OntologyStructure`.
# You will need to use the title or feature node hash to find the right objects, classifications, attributes, or
# attribute options. See the example below to find the ontology object for the demonstrative "Box of a human" object.
#
Expand Down
8 changes: 4 additions & 4 deletions encord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ def save_label_row(self, uid, label, validate_before_saving: bool = False):
return self._querier.basic_setter(LabelRow, uid, payload=label, retryable=True)

def save_label_rows(self, uids: List[str], payload: List[LabelRow], validate_before_saving: bool = False):
"""This function is meant for internal use, please consider using :class:`encord.objects.LabelRowV2` class instead
"""This function is meant for internal use, please consider using :class:`encord.objects.ontology_labels_impl.LabelRowV2` class instead

Saves multiple label rows. See :meth:`.save_label_row`

Expand All @@ -1020,7 +1020,7 @@ def create_label_row(self, uid, *, get_signed_url=False) -> LabelRow:
def create_label_rows(
self, uids: List[str], *, get_signed_url: bool = False, branch_name: Optional[str] = None
) -> List[LabelRow]:
"""This function is meant for internal use, please consider using :class:`encord.objects.LabelRowV2` class instead
"""This function is meant for internal use, please consider using :class:`encord.objects.ontology_labels_impl.LabelRowV2` class instead

Create multiple label rows. See :meth:`.create_label_row`

Expand Down Expand Up @@ -1174,15 +1174,15 @@ def __set_project_ontology(self, ontology: LegacyOntology) -> bool:
return self._querier.basic_setter(OrmProject, uid=None, payload=payload)

def workflow_reopen(self, label_hashes: List[str]) -> None:
"""This function is documented in :meth:`encord.objects.LabelRowV2.workflow_reopen`."""
"""This function is documented in :meth:`encord.objects.ontology_labels_impl.LabelRowV2.workflow_reopen()`."""
self._querier.basic_setter(
LabelWorkflowGraphNode,
label_hashes,
payload=LabelWorkflowGraphNodePayload(action=WorkflowAction.REOPEN),
)

def workflow_complete(self, label_hashes: List[str]) -> None:
"""This function is documented in :meth:`encord.objects.LabelRowV2.workflow_complete`."""
"""This function is documented in :meth:`encord.objects.ontology_labels_impl.LabelRowV2.workflow_complete()`."""
self._querier.basic_setter(
LabelWorkflowGraphNode,
label_hashes,
Expand Down
18 changes: 18 additions & 0 deletions encord/constants/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@


class DataType(StringEnum):
"""
Enumeration of supported data types for labeling and storage.

Values:
video
img_group
dicom
image
dicom_study
nifti
audio
plain_text
pdf
group
scene
_missing_data_type_
Comment thread
david-babuschkin-encord marked this conversation as resolved.
Outdated
"""

VIDEO = "video"
IMG_GROUP = "img_group"
DICOM = "dicom"
Expand Down
2 changes: 1 addition & 1 deletion encord/http/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_batches(iterable: List, n: int) -> List[List]:
List[List]: A list of lists where each sublist represents a batch.

Note:
This can be replaced with :func:`itertools.batched` in Python 3.12+.
This can be replaced with `itertools.batched <https://docs.python.org/3/library/itertools.html#itertools.batched>`_ in Python 3.12+.
"""
return [iterable[ndx : min(ndx + n, len(iterable))] for ndx in range(0, len(iterable), n)]

Expand Down
6 changes: 3 additions & 3 deletions encord/objects/classification_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ def set_answer(
Args:
answer: The answer to set.
attribute: The ontology attribute to set the answer for. If not set, this will be attempted to be
inferred. For answers to :class:`encord.objects.common.RadioAttribute` or
:class:`encord.objects.common.ChecklistAttribute`, this can be inferred automatically. For
:class:`encord.objects.common.TextAttribute`, this will only be inferred if there is only one possible
Comment thread
david-babuschkin-encord marked this conversation as resolved.
inferred. For answers to :class:`encord.objects.attributes.RadioAttribute` or
:class:`encord.objects.attributes.ChecklistAttribute`, this can be inferred automatically. For
:class:`encord.objects.attributes.TextAttribute`, this will only be inferred if there is only one possible
TextAttribute to set for the entire classification instance. Otherwise, a
:class:`encord.exceptions.LabelRowError` will be thrown.
overwrite: If `True`, the answer will be overwritten if it already exists. If `False`, this will throw
Expand Down
28 changes: 28 additions & 0 deletions encord/objects/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,41 @@


class PropertyType(StringEnum):
"""
Enumeration of supported classification and attribute types

Values:
radio
text
checklist
numeric
"""

RADIO = "radio"
TEXT = "text"
CHECKLIST = "checklist"
NUMERIC = "numeric"


class Shape(StringEnum):
"""
Enumeration of supported geometric and data shapes for labeling.

Values:
bounding_box
polygon
point
skeleton
polyline
rotatable_bounding_box
bitmask
audio
text
cuboid
cuboid_2d
segmentation
"""

BOUNDING_BOX = "bounding_box"
POLYGON = "polygon"
POINT = "point"
Expand Down
14 changes: 7 additions & 7 deletions encord/orm/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class DataClientMetadata:


class ImageData:
"""Information about individual images within a single :class:`~encord.orm.dataset.DataRow` of type
"""Information about individual images within a single :class:`encord.orm.dataset.DataRow` of type
:meth:`DataType.IMG_GROUP <encord.constants.enums.DataType.IMG_GROUP>`. Get this information
using the :meth:`DataRow.images <encord.orm.dataset.DataRow.images>` property.
"""
Expand Down Expand Up @@ -284,7 +284,7 @@ def title(self) -> str:
"""The data title.

The setter updates the custom client metadata. This queues a request for the backend which will be
executed on a call of :meth:`~encord.orm.dataset.DataRow.save()`.
executed on a call of :meth:`encord.orm.dataset.DataRow.save()`.
"""
return self["data_title"]

Expand Down Expand Up @@ -333,10 +333,10 @@ def duration(self) -> Optional[int]:
@property
def client_metadata(self) -> Optional[MappingProxyType]:
"""The currently cached client metadata. To cache the client metadata, use the
:meth:`~encord.orm.dataset.DataRow.refetch_data()` function.
:meth:`encord.orm.dataset.DataRow.refetch_data()` function.

The setter updates the custom client metadata. This queues a request for the backend which will
be executed on a call of :meth:`~encord.orm.dataset.DataRow.save()`.
be executed on a call of :meth:`encord.orm.dataset.DataRow.save()`.
"""
return MappingProxyType(self["client_metadata"]) if self["client_metadata"] is not None else None

Expand Down Expand Up @@ -382,7 +382,7 @@ def file_link(self) -> Optional[str]:
@property
def signed_url(self) -> Optional[str]:
"""The cached signed url of the given data asset. To cache the signed url, use the
:meth:`~encord.orm.dataset.DataRow.refetch_data()` function.
:meth:`encord.orm.dataset.DataRow.refetch_data()` function.
"""
return self["signed_url"]

Expand All @@ -402,8 +402,8 @@ def storage_location(self) -> StorageLocation:

@property
def images_data(self) -> Optional[List[ImageData]]:
"""A list of the cached :class:`~encord.orm.dataset.ImageData` objects for the given data asset.
Fetch the images with appropriate settings in the :meth:`~encord.orm.dataset.DataRow.refetch_data()` function.
"""A list of the cached :class:`encord.orm.dataset.ImageData` objects for the given data asset.
Fetch the images with appropriate settings in the :meth:`encord.orm.dataset.DataRow.refetch_data()` function.
If the data type is not :meth:`DataType.IMG_GROUP <encord.constants.enums.DataType.IMG_GROUP>`
then this returns None.
"""
Expand Down
6 changes: 3 additions & 3 deletions encord/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def list_label_rows_v2(
label_hashes: List of label hashes to filter by.
edited_before: Optionally filter to only rows last edited before the specified time.
edited_after: Optionally filter to only rows last edited after the specified time.
label_statuses: Optionally filter to only those label rows that have one of the specified :class:`~encord.orm.label_row.AnnotationTaskStatus`es.
shadow_data_state: Optionally filter by data type in Benchmark QA projects. See :class:`~encord.orm.label_row.ShadowDataState`.
label_statuses: Optionally filter to only those label rows that have one of the specified :class:`encord.orm.label_row.AnnotationTaskStatus`es.
shadow_data_state: Optionally filter by data type in Benchmark QA projects. See :class:`encord.orm.label_row.ShadowDataState`.
data_title_eq: Optionally filter by exact title match.
data_title_like: Optionally filter by fuzzy title match; SQL syntax.
workflow_graph_node_title_eq: Optionally filter by exact match with workflow node title.
Expand All @@ -252,7 +252,7 @@ def list_label_rows_v2(
branch_name: Optionally specify a branch name. A branch name cannot be specified if include_all_label_branches is set to True

Returns:
A list of :class:`~encord.objects.LabelRowV2` instances for all the matching label rows.
A list of :class:`encord.objects.ontology_labels_impl.LabelRowV2` instances for all the matching label rows.
"""
label_row_metadatas = self._client.list_label_rows(
edited_before,
Expand Down
2 changes: 1 addition & 1 deletion encord/project_ontology/ontology_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class OntologyClassification:
"""DEPRECATED: prefer using :class:`encord.ontology.Ontology`

A dataclass which holds classifications of the :class:`encord.project_ontology.Ontology`.
A dataclass which holds classifications of the :class:`encord.project_ontology.ontology.Ontology`.
"""

#: A unique (to the ontology) identifier of the classification.
Expand Down
4 changes: 2 additions & 2 deletions encord/project_ontology/ontology_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

@dataclass
class OntologyObject:
"""DEPRECATED: prefer using :class:`encord.ontology.Ontology`
"""This class is DEPRECATED. We recommend using :class:`encord.ontology.ontology`

A dataclass which holds an object for of the :class:`encord.project_ontology.Ontology`.
A dataclass which holds an object for the :class:`encord.project_ontology.ontology`.
"""

#: A unique (to the ontology) identifier of the classification.
Expand Down
7 changes: 4 additions & 3 deletions encord/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,8 +1166,8 @@ def update(
name (Optional[str]): New folder name.
description (Optional[str]): New folder description.
client_metadata (Optional[Dict[str, Any]]): New client metadata.
bundle (Optional[Bundle]): Optional :class:`encord.http.Bundle` to use for the operation. If provided, the operation
will be bundled into a single server call with other item updates using the same bundle.
bundle (Optional[Bundle]): Optional :class:`encord.http.bundle.Bundle` to use for the operation. If provided, the operation
is bundled into a single server call with other item updates using the same bundle.

Returns:
None
Expand Down Expand Up @@ -1916,7 +1916,8 @@ def update(
name: New item name.
description: New item description.
client_metadata: New client metadata.
bundle: Optional bundle to use for bundling operations.
bundle (Optional[Bundle]): Optional :class:`encord.http.bundle.Bundle` to use for the operation. If provided, the operation
is bundled into a single server call with other item updates using the same bundle.

Returns:
None
Expand Down
4 changes: 2 additions & 2 deletions encord/user_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def list_projects(
tags_anyof: optional tag names filter; matches projects having at least one of the tag names.

Returns:
list of Projects matching filter conditions, as :class:`~encord.project.Project` instances.
list of Projects matching filter conditions, as :class:`encord.project.Project` instances.
"""
properties_filter = ProjectFilterParams.from_dict(self.__validate_filter(locals()))
properties_filter.include_org_access = include_org_access
Expand Down Expand Up @@ -532,7 +532,7 @@ def create_project(
dataset_hashes: a list of the Dataset uids that the project will use
project_description: the optional description of the project
ontology_hash: the uid of an Ontology to be used. If omitted, a new empty Ontology will be created
workflow_settings: selects and configures the type of the quality control Workflow to use, See :class:`encord.orm.project.ProjectWorkflowSettings` for details. If omitted, :class:`~encord.orm.project.ManualReviewWorkflowSettings` is used.
workflow_settings: selects and configures the type of the quality control Workflow to use, See :class:`encord.orm.project.ProjectWorkflowSettings` for details. If omitted, :class:`encord.orm.project.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.

Returns:
Expand Down
Loading