Annotators
zenml.annotators
special
Initialization of the ZenML annotator stack component.
base_annotator
Base class for ZenML annotator stack components.
BaseAnnotator (StackComponent, ABC)
Base class for all ZenML annotators.
Source code in zenml/annotators/base_annotator.py
class BaseAnnotator(StackComponent, ABC):
"""Base class for all ZenML annotators."""
@property
def config(self) -> BaseAnnotatorConfig:
"""Returns the `BaseAnnotatorConfig` config.
Returns:
The configuration.
"""
return cast(BaseAnnotatorConfig, self._config)
@abstractmethod
def get_url(self) -> str:
"""Gets the URL of the annotation interface.
Returns:
The URL of the annotation interface.
"""
@abstractmethod
def get_url_for_dataset(self, dataset_name: str) -> str:
"""Gets the URL of the annotation interface for a specific dataset.
Args:
dataset_name: name of the dataset.
Returns:
The URL of the dataset annotation interface.
"""
@abstractmethod
def get_datasets(self) -> List[Any]:
"""Gets the datasets currently available for annotation.
Returns:
The datasets currently available for annotation.
"""
@abstractmethod
def get_dataset_names(self) -> List[str]:
"""Gets the names of the datasets currently available for annotation.
Returns:
The names of the datasets currently available for annotation.
"""
@abstractmethod
def get_dataset_stats(self, dataset_name: str) -> Tuple[int, int]:
"""Gets the statistics of a dataset.
Args:
dataset_name: name of the dataset.
Returns:
A tuple containing (labeled_task_count, unlabeled_task_count) for
the dataset.
"""
@abstractmethod
def launch(self, **kwargs: Any) -> None:
"""Launches the annotation interface.
Args:
**kwargs: Additional keyword arguments to pass to the
annotation client.
"""
@abstractmethod
def add_dataset(self, **kwargs: Any) -> Any:
"""Registers a dataset for annotation.
Args:
**kwargs: keyword arguments.
Returns:
The dataset or confirmation object on adding the dataset.
"""
@abstractmethod
def get_dataset(self, **kwargs: Any) -> Any:
"""Gets the dataset with the given name.
Args:
**kwargs: keyword arguments.
Returns:
The dataset with the given name.
"""
@abstractmethod
def delete_dataset(self, **kwargs: Any) -> None:
"""Deletes a dataset.
Args:
**kwargs: keyword arguments.
"""
@abstractmethod
def get_labeled_data(self, **kwargs: Any) -> Any:
"""Gets the labeled data for the given dataset.
Args:
**kwargs: keyword arguments.
Returns:
The labeled data for the given dataset.
"""
@abstractmethod
def get_unlabeled_data(self, **kwargs: str) -> Any:
"""Gets the unlabeled data for the given dataset.
Args:
**kwargs: Additional keyword arguments to pass to the Label Studio client.
Returns:
The unlabeled data for the given dataset.
"""
config: BaseAnnotatorConfig
property
readonly
Returns the BaseAnnotatorConfig
config.
Returns:
Type | Description |
---|---|
BaseAnnotatorConfig |
The configuration. |
add_dataset(self, **kwargs)
Registers a dataset for annotation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any |
keyword arguments. |
{} |
Returns:
Type | Description |
---|---|
Any |
The dataset or confirmation object on adding the dataset. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def add_dataset(self, **kwargs: Any) -> Any:
"""Registers a dataset for annotation.
Args:
**kwargs: keyword arguments.
Returns:
The dataset or confirmation object on adding the dataset.
"""
delete_dataset(self, **kwargs)
Deletes a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any |
keyword arguments. |
{} |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def delete_dataset(self, **kwargs: Any) -> None:
"""Deletes a dataset.
Args:
**kwargs: keyword arguments.
"""
get_dataset(self, **kwargs)
Gets the dataset with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any |
keyword arguments. |
{} |
Returns:
Type | Description |
---|---|
Any |
The dataset with the given name. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def get_dataset(self, **kwargs: Any) -> Any:
"""Gets the dataset with the given name.
Args:
**kwargs: keyword arguments.
Returns:
The dataset with the given name.
"""
get_dataset_names(self)
Gets the names of the datasets currently available for annotation.
Returns:
Type | Description |
---|---|
List[str] |
The names of the datasets currently available for annotation. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def get_dataset_names(self) -> List[str]:
"""Gets the names of the datasets currently available for annotation.
Returns:
The names of the datasets currently available for annotation.
"""
get_dataset_stats(self, dataset_name)
Gets the statistics of a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name |
str |
name of the dataset. |
required |
Returns:
Type | Description |
---|---|
Tuple[int, int] |
A tuple containing (labeled_task_count, unlabeled_task_count) for the dataset. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def get_dataset_stats(self, dataset_name: str) -> Tuple[int, int]:
"""Gets the statistics of a dataset.
Args:
dataset_name: name of the dataset.
Returns:
A tuple containing (labeled_task_count, unlabeled_task_count) for
the dataset.
"""
get_datasets(self)
Gets the datasets currently available for annotation.
Returns:
Type | Description |
---|---|
List[Any] |
The datasets currently available for annotation. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def get_datasets(self) -> List[Any]:
"""Gets the datasets currently available for annotation.
Returns:
The datasets currently available for annotation.
"""
get_labeled_data(self, **kwargs)
Gets the labeled data for the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any |
keyword arguments. |
{} |
Returns:
Type | Description |
---|---|
Any |
The labeled data for the given dataset. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def get_labeled_data(self, **kwargs: Any) -> Any:
"""Gets the labeled data for the given dataset.
Args:
**kwargs: keyword arguments.
Returns:
The labeled data for the given dataset.
"""
get_unlabeled_data(self, **kwargs)
Gets the unlabeled data for the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
str |
Additional keyword arguments to pass to the Label Studio client. |
{} |
Returns:
Type | Description |
---|---|
Any |
The unlabeled data for the given dataset. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def get_unlabeled_data(self, **kwargs: str) -> Any:
"""Gets the unlabeled data for the given dataset.
Args:
**kwargs: Additional keyword arguments to pass to the Label Studio client.
Returns:
The unlabeled data for the given dataset.
"""
get_url(self)
Gets the URL of the annotation interface.
Returns:
Type | Description |
---|---|
str |
The URL of the annotation interface. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def get_url(self) -> str:
"""Gets the URL of the annotation interface.
Returns:
The URL of the annotation interface.
"""
get_url_for_dataset(self, dataset_name)
Gets the URL of the annotation interface for a specific dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name |
str |
name of the dataset. |
required |
Returns:
Type | Description |
---|---|
str |
The URL of the dataset annotation interface. |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def get_url_for_dataset(self, dataset_name: str) -> str:
"""Gets the URL of the annotation interface for a specific dataset.
Args:
dataset_name: name of the dataset.
Returns:
The URL of the dataset annotation interface.
"""
launch(self, **kwargs)
Launches the annotation interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any |
Additional keyword arguments to pass to the annotation client. |
{} |
Source code in zenml/annotators/base_annotator.py
@abstractmethod
def launch(self, **kwargs: Any) -> None:
"""Launches the annotation interface.
Args:
**kwargs: Additional keyword arguments to pass to the
annotation client.
"""
BaseAnnotatorConfig (StackComponentConfig)
Base config for annotators.
Attributes:
Name | Type | Description |
---|---|---|
notebook_only |
ClassVar[bool] |
if the annotator can only be used in a notebook. |
Source code in zenml/annotators/base_annotator.py
class BaseAnnotatorConfig(StackComponentConfig):
"""Base config for annotators.
Attributes:
notebook_only: if the annotator can only be used in a notebook.
"""
notebook_only: ClassVar[bool] = False
BaseAnnotatorFlavor (Flavor)
Base class for annotator flavors.
Source code in zenml/annotators/base_annotator.py
class BaseAnnotatorFlavor(Flavor):
"""Base class for annotator flavors."""
@property
def type(self) -> StackComponentType:
"""Returns the flavor type.
Returns:
The flavor type.
"""
return StackComponentType.ANNOTATOR
@property
def config_class(self) -> Type[BaseAnnotatorConfig]:
"""Config class for this flavor.
Returns:
The config class.
"""
return BaseAnnotatorConfig
@property
@abstractmethod
def implementation_class(self) -> Type[BaseAnnotator]:
"""Implementation class.
Returns:
The implementation class.
"""
return BaseAnnotator
config_class: Type[zenml.annotators.base_annotator.BaseAnnotatorConfig]
property
readonly
Config class for this flavor.
Returns:
Type | Description |
---|---|
Type[zenml.annotators.base_annotator.BaseAnnotatorConfig] |
The config class. |
implementation_class: Type[zenml.annotators.base_annotator.BaseAnnotator]
property
readonly
Implementation class.
Returns:
Type | Description |
---|---|
Type[zenml.annotators.base_annotator.BaseAnnotator] |
The implementation class. |
type: StackComponentType
property
readonly
Returns the flavor type.
Returns:
Type | Description |
---|---|
StackComponentType |
The flavor type. |