Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Nov 29, 2024
2 parents 8cd6df8 + 2a58a30 commit 90f3c85
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 53 deletions.
2 changes: 2 additions & 0 deletions argilla-frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ These are the section headers that we use:

## [Unreleased]()

## [2.5.0](https://github.com/argilla-io/argilla/compare/v2.4.1...v2.5.0)

### Added

- Add new dataset list page ([#5684](https://github.com/argilla-io/argilla/pull/5684))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ export default {
.wrapper {
display: flex;
flex-direction: column;
gap: $base-space;
gap: $base-space * 1.5;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ export default {
.wrapper {
display: flex;
flex-direction: column;
gap: $base-space;
gap: $base-space * 1.5;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ export default {
.wrapper {
display: flex;
flex-direction: column;
gap: $base-space;
gap: $base-space * 1.5;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ export default {
.wrapper {
display: flex;
flex-direction: column;
gap: $base-space;
gap: $base-space * 1.5;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
.wrapper {
display: flex;
flex-direction: column;
gap: $base-space;
gap: $base-space * 1.5;
}
.question {
&__warning {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ export default {
.wrapper {
display: flex;
flex-direction: column;
gap: $base-space;
gap: $base-space * 1.5;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<MarkdownRenderer
class="--body3"
class="annotation-guidelines --body3"
:markdown="guidelines || $t('noAnnotationGuidelines')"
/>
</template>
Expand All @@ -13,3 +13,9 @@ export default {
},
};
</script>

<style lang="scss" scoped>
.annotation-guidelines {
padding-inline: $base-space * 2;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ label {
&:hover {
transition: color 0.3s ease;
color: var(--fg-primary);
cursor: pointer;
}
}
input:checked + label {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ label {
&:hover {
transition: color 0.3s ease;
color: var(--fg-primary);
cursor: pointer;
.svg-icon {
transition: fill 0.3s ease;
fill: var(--fg-primary);
Expand Down
4 changes: 4 additions & 0 deletions argilla-server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ These are the section headers that we use:

## [Unreleased]()

## [2.5.0](https://github.com/argilla-io/argilla/compare/v2.4.1...v2.5.0)

### Added

- Added new endpoints to create, update, ping and delete webhooks. ([#5453](https://github.com/argilla-io/argilla/pull/5453))
- Added new webhook events when responses are created, updated, deleted. ([#5468](https://github.com/argilla-io/argilla/pull/5468))
- Added new webhook events when datasets are created, updated, deleted or published. ([#5468](https://github.com/argilla-io/argilla/pull/5468))
- Added new webhook events when records are created, updated, deleted or completed. ([#5489](https://github.com/argilla-io/argilla/pull/5489))
- Added new `high` RQ queue to process high priority background jobs. ([#5467](https://github.com/argilla-io/argilla/pull/5467))
- Added `users` attribute to the response of the endpoint `GET /api/v1/datasets/:dataset_id/progress`. ([#5701](https://github.com/argilla-io/argilla/pull/5701))

### Changed

- Changed default python version to 3.13. ([#5649](https://github.com/argilla-io/argilla/pull/5649))
- Changed Pydantic version to v2. ([#5666](https://github.com/argilla-io/argilla/pull/5666))

### Fixed

Expand Down
3 changes: 1 addition & 2 deletions argilla-server/src/argilla_server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"1.28": "ca7293c38970",
"2.0": "237f7c674d74",
"2.4": "660d6c6b3360",
"2.5": "6ed1b8bf8e08",
"2.6": "580a6553186f",
"2.5": "580a6553186f",
}
)

Expand Down
14 changes: 13 additions & 1 deletion argilla/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@ These are the section headers that we use:

## [Unreleased]()

## [2.5.0](https://github.com/argilla-io/argilla/compare/v2.4.0...v2.5.0)

### Added

- Added support to remove/override datasets settings. ([#5584](https://github.com/argilla-io/argilla/pull/5584))
- Added support to update question attributes. ([#5680](https://github.com/argilla-io/argilla/pull/5680))
- Added support to webhook listeners. ([#5502](https://github.com/argilla-io/argilla/pull/5502))
- Added support to Python 3.13. ([#5652](https://github.com/argilla-io/argilla/pull/5652))

### Fixed

- Fixed error when update settings.distribution.min_submitted from defaults ([#5719](https://github.com/argilla-io/argilla/pull/5719))

## [2.4.0](https://github.com/argilla-io/argilla/compare/v2.3.0...v2.4.0)

### Added

- Added `Argilla.deploy_on_spaces` to deploy the Argilla server on Hugging Face Spaces. ([#5547](https://github.com/argilla-io/argilla/pull/5547))
- Add support to webhooks. ([#5467](https://github.com/argilla-io/argilla/pull/5467))

### Changed

Expand Down
4 changes: 3 additions & 1 deletion argilla/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ nav:
- Import and export datasets: how_to_guides/import_export.md
- Advanced:
- Custom fields with layout templates: how_to_guides/custom_fields.md
- Use webhooks to respond to server events: how_to_guides/webhooks.md
- Use webhooks to respond to server events:
- how_to_guides/webhooks.md
- Webhooks internals: how_to_guides/webhooks_internals.md
- Use Markdown to format rich content: how_to_guides/use_markdown_to_format_rich_content.md
- Migrate users, workspaces and datasets to Argilla V2: how_to_guides/migrate_from_legacy_datasets.md
- Tutorials:
Expand Down
4 changes: 2 additions & 2 deletions argilla/src/argilla/settings/_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
super().__init__(client=_dataset._client if _dataset else None)

self._dataset = _dataset
self._distribution = distribution
self._distribution = distribution or TaskDistribution.default()
self._mapping = mapping
self.__guidelines = self.__process_guidelines(guidelines)
self.__allow_extra_metadata = allow_extra_metadata
Expand Down Expand Up @@ -137,7 +137,7 @@ def allow_extra_metadata(self, value: bool):

@property
def distribution(self) -> TaskDistribution:
return self._distribution or TaskDistribution.default()
return self._distribution

@distribution.setter
def distribution(self, value: TaskDistribution) -> None:
Expand Down
8 changes: 8 additions & 0 deletions argilla/tests/unit/test_settings/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ def test_settings_with_modified_default_task_distribution(self):
other_settings = rg.Settings(fields=[rg.TextField(name="text", title="title")])
assert other_settings.distribution == TaskDistribution(min_submitted=1)

def test_settings_with_modified_task_distribution_value(self):
settings = rg.Settings(fields=[rg.TextField(name="text", title="title")])

assert settings.distribution == TaskDistribution(min_submitted=1)
settings.distribution.min_submitted = 10

assert settings.distribution == TaskDistribution(min_submitted=10)

def test_compare_equal_settings(self):
settings = rg.Settings(fields=[rg.TextField(name="text", title="title")])
assert settings == settings
Expand Down
36 changes: 30 additions & 6 deletions examples/webhooks/basic-webhooks/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
## Description

This is a basic webhook example to show how to setup webhook listeners using the argilla SDK
This is a basic webhook example to show how to configure webhook listeners using the argilla SDK

The application defines three webhook listeners for the following events:

- Record events: `record.deleted`, `record.completed`
- Dataset events: `dataset.created`, `dataset.updated`, `dataset.published`, `dataset.deleted`
- Response events: `response.created`, `response.updated`

You can visit the [Argilla documentation](https://docs.argilla.io/dev/how_to_guides/webhooks) for more information.

## Running the app

1. Start argilla server and argilla worker
This example is intended to be used locally. You can check [this space](https://huggingface.co/spaces/argilla/argilla-webhooks)
for a remote example.

First, you must start the argilla server. We recommend you to use the docker installation. You can run the following commands to start the argilla server:
```bash
pdm server start
pdm worker
mkdir argilla && cd argilla
curl https://raw.githubusercontent.com/argilla-io/argilla/main/examples/deployments/docker/docker-compose.yaml -o docker-compose.yaml
docker compose up -d
```

2. Start the app
For more information on how to install the argilla server, please refer to the [argilla documentation](https://docs.argilla.io/latest/getting_started).

Once the argilla server is up and running, start the webhook server by running the following command:

```bash
ARGILLA_API_KEY=argilla.apikey \
WEBHOOK_SERVER_URL=http://host.docker.internal:8000 \
uvicorn main:server
```

The `ARGILLA_API_KEY` environment variable should be set to the API key of the argilla server.
The `WEBHOOK_SERVER_URL` environment variable should be set to the URL where the webhook server is running.
In this case, we are using `http://host.docker.internal:8000` because the webhook calls will be done inside a docker container.

The application will remove all existing webhook listeners and create new ones for the events mentioned above.

## Testing the app

You can see in se server logs traces when working with dataset, records and responses in the argilla server
When you start working with the argilla server, you can see the logs in the webhook server.
You can test the webhook listeners by creating, updating, and deleting datasets, responses and records in the argilla server.
52 changes: 19 additions & 33 deletions examples/webhooks/basic-webhooks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

# Show the existing webhooks in the argilla server
for webhook in client.webhooks:
print(webhook.url)
print("Deleting webhook with url", webhook.url)
webhook.delete()


# Create a webhook listener using the decorator
Expand All @@ -31,46 +32,31 @@
# Related resources will be passed as keyword arguments to the decorated function
# (for example the dataset for a record-related event, or the record for a response-related event)
# When a resource is deleted
@rg.webhook_listener(events=["record.created", "record.completed"])
async def listen_record(
record: rg.Record, dataset: rg.Dataset, type: str, timestamp: datetime
):
print(f"Received record event of type {type} at {timestamp}")
@rg.webhook_listener(events=["record.deleted", "record.completed"])
async def records_listener(record: rg.Record, type: str, timestamp: datetime):
print(f"Received event of type {type} at {timestamp} for record {record}")

action = "completed" if type == "record.completed" else "created"
print(f"A record with id {record.id} has been {action} for dataset {dataset.name}!")

@rg.webhook_listener(events=["response.created", "response.updated"])
async def responses_listener(response: rg.UserResponse, type: str, timestamp: datetime):
print(f"Received event of type {type} at {timestamp} for response {response}")

@rg.webhook_listener(events="response.updated")
async def trigger_something_on_response_updated(response: rg.UserResponse, **kwargs):
print(
f"The user response {response.id} has been updated with the following responses:"
)
print([response.serialize() for response in response.responses])


@rg.webhook_listener(events=["dataset.created", "dataset.updated", "dataset.published"])
async def with_raw_payload(
type: str,
timestamp: datetime,
dataset: rg.Dataset,
**kwargs,
):
print(f"Event type {type} at {timestamp}")
print(dataset.settings)


@rg.webhook_listener(events="dataset.deleted")
async def on_dataset_deleted(
data: dict,
**kwargs,
):
print(f"Dataset {data} has been deleted!")
@rg.webhook_listener(
events=[
"dataset.created",
"dataset.updated",
"dataset.published",
"dataset.deleted",
]
)
async def datasets_listener(type: str, timestamp: datetime, dataset: rg.Dataset):
print(f"Received event of type {type} at {timestamp} for dataset {dataset}")


# Set the webhook server. The server is a FastAPI instance, so you need to expose it in order to run it using uvicorn:
# ```bash
# uvicorn main:webhook_server --reload
# uvicorn main:server --reload
# ```

server = rg.get_webhook_server()
2 changes: 1 addition & 1 deletion examples/webhooks/basic-webhooks/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
argilla @ git+https://github.com/argilla-io/argilla.git@feat/argilla/working-with-webhooks#subdirectory=argilla
fastapi
uvicorn[standard]
argilla ~= 2.5.0

0 comments on commit 90f3c85

Please sign in to comment.