Update Argilla integration for v2.x SDK
Describe changes
I updated the Argilla integration with the new version Argilla 2.0.
NOTES:
- I kept the convention using keyword arguments, but let me know if you prefer to specify the type hinting clearly.
- I didn't find tests for annotator integrations. I can add some. In a comment, I leave some basic workflow of how to use it.
cc @strickvl
Pre-requisites
Please ensure you have done the following:
- [x] I have read the CONTRIBUTING.md document.
- [x] If my change requires a change to docs, I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [x] I have based my new branch on
developand the open PR is targetingdevelop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop. - [ ] If my changes require changes to the dashboard, these changes are communicated/requested.
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Other (add details above)
Summary by CodeRabbit
-
Documentation Updates
- Enhanced clarity in the documentation for available annotators and the Argilla tool.
- Improved deployment instructions and updated the Argilla quickstart guide link.
- Modifications to the Argilla settings for better usability, including port defaults and header naming.
-
New Features
- Added workspace-specific operations for Argilla annotation integration.
- Introduced error handling and logging improvements during operations.
-
Dependency Updates
- Increased version requirement for the
argillapackage to>=2.0.0.
- Increased version requirement for the
[!IMPORTANT]
Review skipped
Auto reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
📝 Walkthrough
Walkthrough
The recent changes enhance the documentation and functionality of the ZenML framework, particularly around the Argilla integration. Documentation has been clarified to better represent tools and their usage, while code updates improve exception handling, workspace management, and usability. Key modifications include upgrading the Argilla package requirement and refining methods to support workspace-specific operations, streamlining dataset management, and improving user interaction with new client features.
Changes
| Files | Change Summary |
|---|---|
docs/book/component-guide/annotators/*.md |
Documentation updates for annotators, enhancing clarity around integrations and Argilla usage, including improved deployment details. |
docs/mocked_libs.json |
Removed specific Argilla SDK modules and added an exceptions API module, suggesting a restructuring of the library’s focus. |
src/zenml/integrations/argilla/__init__.py |
Updated Argilla version requirement from <2 to >=2.0.0, indicating a major dependency change. |
src/zenml/integrations/argilla/annotators/*.py |
Significant updates to support workspace-specific operations, improved error handling, and new methods for dataset management. |
src/zenml/integrations/argilla/flavors/*.py |
Modifications to settings attributes, including renaming and default values, indicating a shift in workspace handling. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant ArgillaAnnotator
participant ArgillaAPI
User->>ArgillaAnnotator: Launch Annotation Interface
ArgillaAnnotator->>ArgillaAPI: Initialize Client
ArgillaAnnotator->>ArgillaAPI: Get Datasets (with workspace)
ArgillaAPI-->>ArgillaAnnotator: Return Datasets
ArgillaAnnotator->>User: Display Datasets
🐰 In fields of green, I hop with glee,
New changes bloom, just wait and see!
With tools in hand and workspaces bright,
Data dances in the moonlight.
Let’s celebrate the joy we find,
With each update, we’re one of a kind! 🌼✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Generate unit testing code for this file. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and generate unit testing code. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
from typing import List
import argilla as rg
from zenml import step, pipeline
from zenml.client import Client
from zenml.logger import get_logger
logger = get_logger(__name__)
@step
def get_data() -> List[str]:
"""Random text data for annotation."""
texts = [
"The quick brown fox jumps over the lazy dog.",
"ZenML is an extensible, open-source MLOps framework.",
"Argilla helps in managing and annotating data.",
"Machine learning models require good quality data.",
"Annotation tools are essential for supervised learning.",
]
return texts
@step
def upload_to_argilla(
texts: List[str],
dataset_name: str = "default_dataset",
):
"""Creates a dataset and loads the data to Argilla.
Args:
texts: List of text data.
dataset_name: Name of the dataset in Argilla.
"""
annotator = Client().active_stack.annotator
from zenml.integrations.argilla.annotators.argilla_annotator import (
ArgillaAnnotator,
)
if not isinstance(annotator, ArgillaAnnotator):
raise TypeError(
"This step can only be used with the Argilla annotator."
)
argilla = annotator._get_client()
# Create or get the dataset in Argilla
try:
dataset = annotator.get_dataset(dataset_name=dataset_name)
if dataset is None:
settings = rg.Settings(
guidelines="These are some guidelines.",
fields=[
rg.TextField(
name="text",
),
],
questions=[
rg.LabelQuestion(
name="label",
labels=["label_1", "label_2", "label_3"]
),
],
metadata=[
rg.TermsMetadataProperty(
name="terms",
title="Annotation groups",
),
],
)
dataset = annotator.add_dataset(dataset_name=dataset_name, settings=settings)
records = [
rg.Record(
fields={"text": text}
)
for text in texts
]
annotator.add_records(dataset_name=dataset_name, records=records)
except Exception as e:
logger.error(f"Error: {e}")
raise e
print(dataset)
@pipeline
def data_pipeline():
data = get_data()
upload_to_argilla(data)
if __name__ == "__main__":
data_pipeline()
Also a few errors from CI: https://github.com/zenml-io/zenml/actions/runs/10290280476/job/28480088504?pr=2915#step:6:41 @sdiazlor
@strickvl Thank you! They should be fixed, I had missed those.
@coderabbitai review
Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
@schustmi we'll have to look into conditionally ignoring / not installing argilla on our Python 3.8 instances on slow CI.
:seal: - thanks so much @sdiazlor for your contribution, i tested this in action an everything works as expected.