Label Studio
zenml.integrations.label_studio
Initialization of the Label Studio integration.
Attributes
LABEL_STUDIO = 'label_studio'
module-attribute
LABEL_STUDIO_ANNOTATOR_FLAVOR = 'label_studio'
module-attribute
Classes
Flavor
Class for ZenML Flavors.
Attributes
config_class: Type[StackComponentConfig]
abstractmethod
property
Returns StackComponentConfig
config class.
Returns:
Type | Description |
---|---|
Type[StackComponentConfig]
|
The config class. |
config_schema: Dict[str, Any]
property
The config schema for a flavor.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The config schema. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[StackComponent]
abstractmethod
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[StackComponent]
|
The implementation class for this flavor. |
logo_url: Optional[str]
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
Optional[str]
|
The flavor logo. |
name: str
abstractmethod
property
The flavor name.
Returns:
Type | Description |
---|---|
str
|
The flavor name. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
Type | Description |
---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
type: StackComponentType
abstractmethod
property
Functions
from_model(flavor_model: FlavorResponse) -> Flavor
classmethod
Loads a flavor from a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flavor_model
|
FlavorResponse
|
The model to load from. |
required |
Raises:
Type | Description |
---|---|
CustomFlavorImportError
|
If the custom flavor can't be imported. |
ImportError
|
If the flavor can't be imported. |
Returns:
Type | Description |
---|---|
Flavor
|
The loaded flavor. |
Source code in src/zenml/stack/flavor.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
generate_default_docs_url() -> str
Generate the doc urls for all inbuilt and integration flavors.
Note that this method is not going to be useful for custom flavors, which do not have any docs in the main zenml docs.
Returns:
Type | Description |
---|---|
str
|
The complete url to the zenml documentation |
Source code in src/zenml/stack/flavor.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
generate_default_sdk_docs_url() -> str
Generate SDK docs url for a flavor.
Returns:
Type | Description |
---|---|
str
|
The complete url to the zenml SDK docs |
Source code in src/zenml/stack/flavor.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
to_model(integration: Optional[str] = None, is_custom: bool = True) -> FlavorRequest
Converts a flavor to a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
integration
|
Optional[str]
|
The integration to use for the model. |
None
|
is_custom
|
bool
|
Whether the flavor is a custom flavor. Custom flavors are then scoped by user and workspace |
True
|
Returns:
Type | Description |
---|---|
FlavorRequest
|
The model. |
Source code in src/zenml/stack/flavor.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
Integration
Base class for integration in ZenML.
Functions
activate() -> None
classmethod
Abstract method to activate the integration.
Source code in src/zenml/integrations/integration.py
170 171 172 |
|
check_installation() -> bool
classmethod
Method to check whether the required packages are installed.
Returns:
Type | Description |
---|---|
bool
|
True if all required packages are installed, False otherwise. |
Source code in src/zenml/integrations/integration.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
flavors() -> List[Type[Flavor]]
classmethod
Abstract method to declare new stack component flavors.
Returns:
Type | Description |
---|---|
List[Type[Flavor]]
|
A list of new stack component flavors. |
Source code in src/zenml/integrations/integration.py
174 175 176 177 178 179 180 181 |
|
get_requirements(target_os: Optional[str] = None) -> List[str]
classmethod
Method to get the requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
135 136 137 138 139 140 141 142 143 144 145 |
|
get_uninstall_requirements(target_os: Optional[str] = None) -> List[str]
classmethod
Method to get the uninstall requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
plugin_flavors() -> List[Type[BasePluginFlavor]]
classmethod
Abstract method to declare new plugin flavors.
Returns:
Type | Description |
---|---|
List[Type[BasePluginFlavor]]
|
A list of new plugin flavors. |
Source code in src/zenml/integrations/integration.py
183 184 185 186 187 188 189 190 |
|
LabelStudioIntegration
Bases: Integration
Definition of Label Studio integration for ZenML.
Functions
flavors() -> List[Type[Flavor]]
classmethod
Declare the stack component flavors for the Label Studio integration.
Returns:
Type | Description |
---|---|
List[Type[Flavor]]
|
List of stack component flavors for this integration. |
Source code in src/zenml/integrations/label_studio/__init__.py
32 33 34 35 36 37 38 39 40 41 42 43 |
|
Modules
annotators
Initialization of the Label Studio annotators submodule.
Classes
LabelStudioAnnotator(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], workspace: UUID, created: datetime, updated: datetime, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseAnnotator
, AuthenticationMixin
Class to interact with the Label Studio annotation interface.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
config: LabelStudioAnnotatorConfig
property
Returns the LabelStudioAnnotatorConfig
config.
Returns:
Type | Description |
---|---|
LabelStudioAnnotatorConfig
|
The configuration. |
settings_class: Type[LabelStudioAnnotatorSettings]
property
Settings class for the Label Studio annotator.
Returns:
Type | Description |
---|---|
Type[LabelStudioAnnotatorSettings]
|
The settings class. |
add_dataset(**kwargs: Any) -> Any
Registers a dataset for annotation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the Label Studio client. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
A Label Studio Project object. |
Raises:
Type | Description |
---|---|
ValueError
|
if 'dataset_name' and 'label_config' aren't provided. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
connect_and_sync_external_storage(uri: str, params: LabelStudioDatasetSyncParameters, dataset: Project) -> Optional[Dict[str, Any]]
Syncs the external storage for the given project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
str
|
URI of the storage source. |
required |
params
|
LabelStudioDatasetSyncParameters
|
Parameters for the dataset. |
required |
dataset
|
Project
|
Label Studio dataset. |
required |
Returns:
Type | Description |
---|---|
Optional[Dict[str, Any]]
|
A dictionary containing the sync result. |
Raises:
Type | Description |
---|---|
ValueError
|
If the storage type is not supported. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
|
delete_dataset(**kwargs: Any) -> None
Deletes a dataset from the annotation interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the Label Studio client. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset name is not provided or if the dataset does not exist. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
get_converted_dataset(dataset_name: str, output_format: str) -> Dict[Any, Any]
Extract annotated tasks in a specific converted format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
Id of the dataset. |
required |
output_format
|
str
|
Output format. |
required |
Returns:
Type | Description |
---|---|
Dict[Any, Any]
|
A dictionary containing the converted dataset. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
get_dataset(**kwargs: Any) -> Any
Gets the dataset with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the Label Studio client. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The LabelStudio Dataset object (a 'Project') for the given name. |
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset name is not provided or if the dataset does not exist. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
get_dataset_names() -> List[str]
Gets the names of the datasets.
Returns:
Type | Description |
---|---|
List[str]
|
A list of dataset names. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
113 114 115 116 117 118 119 120 121 |
|
get_dataset_stats(dataset_name: str) -> Tuple[int, int]
Gets the statistics of the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
Tuple[int, int]
|
A tuple containing (labeled_task_count, unlabeled_task_count) for the dataset. |
Raises:
Type | Description |
---|---|
IndexError
|
If the dataset does not exist. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
get_datasets() -> List[Any]
Gets the datasets currently available for annotation.
Returns:
Type | Description |
---|---|
List[Any]
|
A list of datasets. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
104 105 106 107 108 109 110 111 |
|
get_id_from_name(dataset_name: str) -> Optional[int]
Gets the ID of the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
Optional[int]
|
The ID of the dataset. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
get_labeled_data(**kwargs: Any) -> Any
Gets the labeled data for the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the Label Studio client. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The labeled data. |
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset name is not provided or if the dataset does not exist. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
get_parsed_label_config(dataset_id: int) -> Dict[str, Any]
Returns the parsed Label Studio label config for a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
int
|
Id of the dataset. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
A dictionary containing the parsed label config. |
Raises:
Type | Description |
---|---|
ValueError
|
If no dataset is found for the given id. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
|
get_unlabeled_data(**kwargs: str) -> Any
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. |
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset name is not provided. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
|
get_url() -> str
Gets the top-level URL of the annotation interface.
Returns:
Type | Description |
---|---|
str
|
The URL of the annotation interface. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
65 66 67 68 69 70 71 72 73 74 75 |
|
get_url_for_dataset(dataset_name: str) -> str
Gets the URL of the annotation interface for the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the annotation interface. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
77 78 79 80 81 82 83 84 85 86 87 |
|
launch(**kwargs: Any) -> None
Launches the annotation interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the annotation client. |
{}
|
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
populate_artifact_store_parameters(params: LabelStudioDatasetSyncParameters, artifact_store: BaseArtifactStore) -> None
Populate the dataset sync parameters with the artifact store credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
LabelStudioDatasetSyncParameters
|
The dataset sync parameters. |
required |
artifact_store
|
BaseArtifactStore
|
The active artifact store. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
if the artifact store credentials cannot be fetched. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 |
|
register_dataset_for_annotation(label_config: str, dataset_name: str) -> Any
Registers a dataset for annotation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label_config
|
str
|
The label config to use for the annotation interface. |
required |
dataset_name
|
str
|
Name of the dataset to register. |
required |
Returns:
Type | Description |
---|---|
Any
|
A Label Studio Project object. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
Modules
label_studio_annotator
Implementation of the Label Studio annotation integration.
LabelStudioAnnotator(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], workspace: UUID, created: datetime, updated: datetime, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseAnnotator
, AuthenticationMixin
Class to interact with the Label Studio annotation interface.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
config: LabelStudioAnnotatorConfig
property
Returns the LabelStudioAnnotatorConfig
config.
Returns:
Type | Description |
---|---|
LabelStudioAnnotatorConfig
|
The configuration. |
settings_class: Type[LabelStudioAnnotatorSettings]
property
Settings class for the Label Studio annotator.
Returns:
Type | Description |
---|---|
Type[LabelStudioAnnotatorSettings]
|
The settings class. |
add_dataset(**kwargs: Any) -> Any
Registers a dataset for annotation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the Label Studio client. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
A Label Studio Project object. |
Raises:
Type | Description |
---|---|
ValueError
|
if 'dataset_name' and 'label_config' aren't provided. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
connect_and_sync_external_storage(uri: str, params: LabelStudioDatasetSyncParameters, dataset: Project) -> Optional[Dict[str, Any]]
Syncs the external storage for the given project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
str
|
URI of the storage source. |
required |
params
|
LabelStudioDatasetSyncParameters
|
Parameters for the dataset. |
required |
dataset
|
Project
|
Label Studio dataset. |
required |
Returns:
Type | Description |
---|---|
Optional[Dict[str, Any]]
|
A dictionary containing the sync result. |
Raises:
Type | Description |
---|---|
ValueError
|
If the storage type is not supported. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
|
delete_dataset(**kwargs: Any) -> None
Deletes a dataset from the annotation interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the Label Studio client. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset name is not provided or if the dataset does not exist. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
get_converted_dataset(dataset_name: str, output_format: str) -> Dict[Any, Any]
Extract annotated tasks in a specific converted format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
Id of the dataset. |
required |
output_format
|
str
|
Output format. |
required |
Returns:
Type | Description |
---|---|
Dict[Any, Any]
|
A dictionary containing the converted dataset. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
get_dataset(**kwargs: Any) -> Any
Gets the dataset with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the Label Studio client. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The LabelStudio Dataset object (a 'Project') for the given name. |
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset name is not provided or if the dataset does not exist. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
get_dataset_names() -> List[str]
Gets the names of the datasets.
Returns:
Type | Description |
---|---|
List[str]
|
A list of dataset names. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
113 114 115 116 117 118 119 120 121 |
|
get_dataset_stats(dataset_name: str) -> Tuple[int, int]
Gets the statistics of the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
Tuple[int, int]
|
A tuple containing (labeled_task_count, unlabeled_task_count) for the dataset. |
Raises:
Type | Description |
---|---|
IndexError
|
If the dataset does not exist. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
get_datasets() -> List[Any]
Gets the datasets currently available for annotation.
Returns:
Type | Description |
---|---|
List[Any]
|
A list of datasets. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
104 105 106 107 108 109 110 111 |
|
get_id_from_name(dataset_name: str) -> Optional[int]
Gets the ID of the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
Optional[int]
|
The ID of the dataset. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
get_labeled_data(**kwargs: Any) -> Any
Gets the labeled data for the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the Label Studio client. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The labeled data. |
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset name is not provided or if the dataset does not exist. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
get_parsed_label_config(dataset_id: int) -> Dict[str, Any]
Returns the parsed Label Studio label config for a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
int
|
Id of the dataset. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
A dictionary containing the parsed label config. |
Raises:
Type | Description |
---|---|
ValueError
|
If no dataset is found for the given id. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
|
get_unlabeled_data(**kwargs: str) -> Any
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. |
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset name is not provided. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
|
get_url() -> str
Gets the top-level URL of the annotation interface.
Returns:
Type | Description |
---|---|
str
|
The URL of the annotation interface. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
65 66 67 68 69 70 71 72 73 74 75 |
|
get_url_for_dataset(dataset_name: str) -> str
Gets the URL of the annotation interface for the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL of the annotation interface. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
77 78 79 80 81 82 83 84 85 86 87 |
|
launch(**kwargs: Any) -> None
Launches the annotation interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments to pass to the annotation client. |
{}
|
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
populate_artifact_store_parameters(params: LabelStudioDatasetSyncParameters, artifact_store: BaseArtifactStore) -> None
Populate the dataset sync parameters with the artifact store credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
LabelStudioDatasetSyncParameters
|
The dataset sync parameters. |
required |
artifact_store
|
BaseArtifactStore
|
The active artifact store. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
if the artifact store credentials cannot be fetched. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 |
|
register_dataset_for_annotation(label_config: str, dataset_name: str) -> Any
Registers a dataset for annotation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label_config
|
str
|
The label config to use for the annotation interface. |
required |
dataset_name
|
str
|
Name of the dataset to register. |
required |
Returns:
Type | Description |
---|---|
Any
|
A Label Studio Project object. |
Source code in src/zenml/integrations/label_studio/annotators/label_studio_annotator.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
flavors
Label Studio integration flavors.
Classes
LabelStudioAnnotatorConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseAnnotatorConfig
, LabelStudioAnnotatorSettings
, AuthenticationConfigMixin
Config for the Label Studio annotator.
This class combines settings and authentication configurations for Label Studio into a single, usable configuration object without adding additional functionality.
Source code in src/zenml/config/secret_reference_mixin.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
LabelStudioAnnotatorFlavor
Bases: BaseAnnotatorFlavor
Label Studio annotator flavor.
config_class: Type[LabelStudioAnnotatorConfig]
property
Returns LabelStudioAnnotatorConfig
config class.
Returns:
Type | Description |
---|---|
Type[LabelStudioAnnotatorConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[LabelStudioAnnotator]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[LabelStudioAnnotator]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
LabelStudioAnnotatorSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Label studio annotator settings.
Attributes:
Name | Type | Description |
---|---|---|
instance_url |
str
|
URL of the Label Studio instance. |
port |
Optional[int]
|
The port to use for the annotation interface. |
api_key |
Optional[str]
|
The api_key for label studio. |
Source code in src/zenml/config/secret_reference_mixin.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
Modules
label_studio_annotator_flavor
Label Studio annotator flavor.
LabelStudioAnnotatorConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseAnnotatorConfig
, LabelStudioAnnotatorSettings
, AuthenticationConfigMixin
Config for the Label Studio annotator.
This class combines settings and authentication configurations for Label Studio into a single, usable configuration object without adding additional functionality.
Source code in src/zenml/config/secret_reference_mixin.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
LabelStudioAnnotatorFlavor
Bases: BaseAnnotatorFlavor
Label Studio annotator flavor.
config_class: Type[LabelStudioAnnotatorConfig]
property
Returns LabelStudioAnnotatorConfig
config class.
Returns:
Type | Description |
---|---|
Type[LabelStudioAnnotatorConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[LabelStudioAnnotator]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[LabelStudioAnnotator]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
LabelStudioAnnotatorSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Label studio annotator settings.
Attributes:
Name | Type | Description |
---|---|---|
instance_url |
str
|
URL of the Label Studio instance. |
port |
Optional[int]
|
The port to use for the annotation interface. |
api_key |
Optional[str]
|
The api_key for label studio. |
Source code in src/zenml/config/secret_reference_mixin.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
label_config_generators
Initialization of the Label Studio config generators submodule.
Functions
generate_image_classification_label_config(labels: List[str]) -> Tuple[str, str]
Generates a Label Studio label config for image classification.
This is based on the basic config example shown at https://labelstud.io/templates/image_classification.html.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels
|
List[str]
|
A list of labels to be used in the label config. |
required |
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
A tuple of the generated label config and the label config type. |
Raises:
Type | Description |
---|---|
ValueError
|
If no labels are provided. |
Source code in src/zenml/integrations/label_studio/label_config_generators/label_config_generators.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
generate_text_classification_label_config(labels: List[str]) -> Tuple[str, str]
Generates a Label Studio label config for text classification.
This is based on the basic config example shown at https://labelstud.io/templates/sentiment_analysis.html.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels
|
List[str]
|
A list of labels to be used in the label config. |
required |
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
A tuple of the generated label config and the label config type. |
Raises:
Type | Description |
---|---|
ValueError
|
If no labels are provided. |
Source code in src/zenml/integrations/label_studio/label_config_generators/label_config_generators.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
Modules
label_config_generators
Implementation of label config generators for Label Studio.
generate_basic_object_detection_bounding_boxes_label_config(labels: List[str]) -> Tuple[str, str]
Generates a Label Studio config for object detection with bounding boxes.
This is based on the basic config example shown at https://labelstud.io/templates/image_bbox.html.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels
|
List[str]
|
A list of labels to be used in the label config. |
required |
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
A tuple of the generated label config and the label config type. |
Raises:
Type | Description |
---|---|
ValueError
|
If no labels are provided. |
Source code in src/zenml/integrations/label_studio/label_config_generators/label_config_generators.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
generate_basic_ocr_label_config(labels: List[str]) -> Tuple[str, str]
Generates a Label Studio config for optical character recognition (OCR) labeling task.
This is based on the basic config example shown at https://labelstud.io/templates/optical_character_recognition.html
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels
|
List[str]
|
A list of labels to be used in the label config. |
required |
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
A tuple of the generated label config and the label config type. |
Raises:
Type | Description |
---|---|
ValueError
|
If no labels are provided. |
Source code in src/zenml/integrations/label_studio/label_config_generators/label_config_generators.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
generate_image_classification_label_config(labels: List[str]) -> Tuple[str, str]
Generates a Label Studio label config for image classification.
This is based on the basic config example shown at https://labelstud.io/templates/image_classification.html.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels
|
List[str]
|
A list of labels to be used in the label config. |
required |
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
A tuple of the generated label config and the label config type. |
Raises:
Type | Description |
---|---|
ValueError
|
If no labels are provided. |
Source code in src/zenml/integrations/label_studio/label_config_generators/label_config_generators.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
generate_text_classification_label_config(labels: List[str]) -> Tuple[str, str]
Generates a Label Studio label config for text classification.
This is based on the basic config example shown at https://labelstud.io/templates/sentiment_analysis.html.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels
|
List[str]
|
A list of labels to be used in the label config. |
required |
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
A tuple of the generated label config and the label config type. |
Raises:
Type | Description |
---|---|
ValueError
|
If no labels are provided. |
Source code in src/zenml/integrations/label_studio/label_config_generators/label_config_generators.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
label_studio_utils
Utility functions for the Label Studio annotator integration.
Functions
clean_url(url: str) -> str
Remove extraneous parts of the URL prior to mapping.
Removes the query and netloc parts of the URL, and strips the leading slash
from the path. For example, a string like
'gs%3A//label-studio/load_image_data/images/fdbcd451-0c80-495c-a9c5-6b51776f5019/1/0/image_file.JPEG'
would become
label-studio/load_image_data/images/fdbcd451-0c80-495c-a9c5-6b51776f5019/1/0/image_file.JPEG
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
A URL string. |
required |
Returns:
Type | Description |
---|---|
str
|
A cleaned URL string. |
Source code in src/zenml/integrations/label_studio/label_studio_utils.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
convert_pred_filenames_to_task_ids(preds: List[Dict[str, Any]], tasks: List[Dict[str, Any]]) -> List[Dict[str, Any]]
Converts a list of predictions from local file references to task id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
preds
|
List[Dict[str, Any]]
|
List of predictions. |
required |
tasks
|
List[Dict[str, Any]]
|
List of tasks. |
required |
Returns:
Type | Description |
---|---|
List[Dict[str, Any]]
|
List of predictions using task ids as reference. |
Source code in src/zenml/integrations/label_studio/label_studio_utils.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
get_file_extension(path_str: str) -> str
Return the file extension of the given filename.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_str
|
str
|
Path to the file. |
required |
Returns:
Type | Description |
---|---|
str
|
File extension. |
Source code in src/zenml/integrations/label_studio/label_studio_utils.py
111 112 113 114 115 116 117 118 119 120 |
|
is_azure_url(url: str) -> bool
Return whether the given URL is an Azure URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
URL to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the URL is an Azure URL, False otherwise. |
Source code in src/zenml/integrations/label_studio/label_studio_utils.py
87 88 89 90 91 92 93 94 95 96 |
|
is_gcs_url(url: str) -> bool
Return whether the given URL is an GCS URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
URL to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the URL is an GCS URL, False otherwise. |
Source code in src/zenml/integrations/label_studio/label_studio_utils.py
99 100 101 102 103 104 105 106 107 108 |
|
is_s3_url(url: str) -> bool
Return whether the given URL is an S3 URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
URL to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the URL is an S3 URL, False otherwise. |
Source code in src/zenml/integrations/label_studio/label_studio_utils.py
75 76 77 78 79 80 81 82 83 84 |
|
steps
Standard steps to be used with the Label Studio annotator integration.
Classes
Functions
Modules
label_studio_standard_steps
Implementation of standard steps for the Label Studio annotator integration.
LabelStudioDatasetSyncParameters
Bases: BaseModel
Step parameters when syncing data to Label Studio.
Attributes:
Name | Type | Description |
---|---|---|
storage_type |
str
|
The type of storage to sync to. Can be one of ["gcs", "s3", "azure", "local"]. Defaults to "local". |
label_config_type |
str
|
The type of label config to use. |
prefix |
Optional[str]
|
Specify the prefix within the cloud store to import your data from. For local storage, this is the full absolute path to the directory containing your data. |
regex_filter |
Optional[str]
|
Specify a regex filter to filter the files to import. |
use_blob_urls |
Optional[bool]
|
Specify whether your data is raw image or video data, or JSON tasks. |
presign |
Optional[bool]
|
Specify whether or not to create presigned URLs. |
presign_ttl |
Optional[int]
|
Specify how long to keep presigned URLs active. |
description |
Optional[str]
|
Specify a description for the dataset. |
azure_account_name |
Optional[str]
|
Specify the Azure account name to use for the storage. |
azure_account_key |
Optional[str]
|
Specify the Azure account key to use for the storage. |
google_application_credentials |
Optional[str]
|
Specify the file with Google application credentials to use for the storage. |
aws_access_key_id |
Optional[str]
|
Specify the AWS access key ID to use for the storage. |
aws_secret_access_key |
Optional[str]
|
Specify the AWS secret access key to use for the storage. |
aws_session_token |
Optional[str]
|
Specify the AWS session token to use for the storage. |
s3_region_name |
Optional[str]
|
Specify the S3 region name to use for the storage. |
s3_endpoint |
Optional[str]
|
Specify the S3 endpoint to use for the storage. |
get_labeled_data(dataset_name: str) -> List
Gets labeled data from the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
Name of the dataset. |
required |
Returns:
Type | Description |
---|---|
List
|
List of labeled data. |
Raises:
Type | Description |
---|---|
TypeError
|
If you are trying to use it with an annotator that is not Label Studio. |
StackComponentInterfaceError
|
If no active annotator could be found. |
Source code in src/zenml/integrations/label_studio/steps/label_studio_standard_steps.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
get_or_create_dataset(label_config: str, dataset_name: str) -> str
Gets preexisting dataset or creates a new one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label_config
|
str
|
The label config to use for the annotation interface. |
required |
dataset_name
|
str
|
Name of the dataset to register. |
required |
Returns:
Type | Description |
---|---|
str
|
The dataset name. |
Raises:
Type | Description |
---|---|
TypeError
|
If you are trying to use it with an annotator that is not Label Studio. |
StackComponentInterfaceError
|
If no active annotator could be found. |
Source code in src/zenml/integrations/label_studio/steps/label_studio_standard_steps.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
sync_new_data_to_label_studio(uri: str, dataset_name: str, predictions: List[Dict[str, Any]], params: LabelStudioDatasetSyncParameters) -> None
Syncs new data to Label Studio.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
str
|
The URI of the data to sync. |
required |
dataset_name
|
str
|
The name of the dataset to sync to. |
required |
predictions
|
List[Dict[str, Any]]
|
The predictions to sync. |
required |
params
|
LabelStudioDatasetSyncParameters
|
The parameters for the sync. |
required |
Raises:
Type | Description |
---|---|
TypeError
|
If you are trying to use it with an annotator that is not Label Studio. |
ValueError
|
if you are trying to sync from outside ZenML. |
StackComponentInterfaceError
|
If no active annotator could be found. |
Source code in src/zenml/integrations/label_studio/steps/label_studio_standard_steps.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|