Skip to content

Commit 9677435

Browse files
committed
Merge branch 'main' into develop
2 parents f41b643 + 1e54a48 commit 9677435

File tree

20 files changed

+482
-41
lines changed

20 files changed

+482
-41
lines changed

.github/workflows/argilla.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
build:
2222
services:
2323
argilla-server:
24-
image: argilladev/argilla-hf-spaces:pr-5422
24+
image: argilladev/argilla-hf-spaces:develop
2525
ports:
2626
- 6900:6900
2727
env:

argilla-frontend/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ These are the section headers that we use:
1616

1717
## [Unreleased]()
1818

19+
## [2.3.0](https://github.com/argilla-io/argilla/compare/v2.2.0...v2.3.0)
20+
1921
### Added
2022

2123
- Added new field `CustomField` [#5462](https://github.com/argilla-io/argilla/pull/5462)

argilla-server/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ These are the section headers that we use:
1616

1717
## [Unreleased]()
1818

19+
## [2.3.0](https://github.com/argilla-io/argilla/compare/v2.2.0...v2.3.0)
20+
1921
### Added
2022

23+
- Added support for `CustomField`. ([#5422](https://github.com/argilla-io/argilla/pull/5422))
2124
- Added helm chart for argilla. ([#5512](https://github.com/argilla-io/argilla/pull/5512))
2225

2326
### Fixed
2427

2528
- Fixed error when creating default user with existing default workspace. ([#5558](https://github.com/argilla-io/argilla/pull/5558))
29+
- Fixed the deployment yaml used to create a new Argilla server in K8s. Added `USERNAME` and `PASSWORD` to the environment variables of pod template. ([#5434](https://github.com/argilla-io/argilla/issues/5434))
2630

2731
## [2.2.0](https://github.com/argilla-io/argilla/compare/v2.1.0...v2.2.0)
2832

argilla-server/src/argilla_server/search_engine/commons.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ def es_mapping_for_field(field: Field) -> dict:
177177
elif field.is_custom:
178178
return {
179179
es_field_for_record_field(field.name): {
180-
"type": "object",
181-
"dynamic": True,
182-
"properties": {},
180+
"type": "text",
183181
}
184182
}
185183
elif field.is_image:
@@ -532,17 +530,19 @@ def _inverse_vector(vector_value: List[float]) -> List[float]:
532530
return [vector_value[i] * -1 for i in range(0, len(vector_value))]
533531

534532
def _map_record_to_es_document(self, record: Record) -> Dict[str, Any]:
533+
dataset = record.dataset
534+
535535
document = {
536536
"id": str(record.id),
537537
"external_id": record.external_id,
538-
"fields": record.fields,
538+
"fields": self._map_record_fields_to_es(record.fields, dataset.fields),
539539
"status": record.status,
540540
"inserted_at": record.inserted_at,
541541
"updated_at": record.updated_at,
542542
}
543543

544544
if record.metadata_:
545-
document["metadata"] = self._map_record_metadata_to_es(record.metadata_, record.dataset.metadata_properties)
545+
document["metadata"] = self._map_record_metadata_to_es(record.metadata_, dataset.metadata_properties)
546546
if record.responses:
547547
document["responses"] = self._map_record_responses_to_es(record.responses)
548548
if record.suggestions:
@@ -662,7 +662,7 @@ def _build_text_query(dataset: Dataset, text: Optional[Union[TextQuery, str]] =
662662
if field is None:
663663
raise Exception(f"Field {text.field} not found in dataset {dataset.id}")
664664

665-
if field.is_chat or field.is_custom:
665+
if field.is_chat:
666666
field_name = f"{text.field}.*"
667667
else:
668668
field_name = text.field
@@ -833,6 +833,18 @@ def _map_record_response_to_es(response: Response) -> Dict[str, Any]:
833833
},
834834
}
835835

836+
@classmethod
837+
def _map_record_fields_to_es(cls, fields: dict, dataset_fields: List[Field]) -> dict:
838+
for field in dataset_fields:
839+
if field.is_image:
840+
fields[field.name] = None
841+
elif field.is_custom:
842+
fields[field.name] = str(fields.get(field.name, ""))
843+
else:
844+
fields[field.name] = fields.get(field.name, "")
845+
846+
return fields
847+
836848
async def __terms_aggregation(self, index_name: str, field_name: str, query: dict, size: int) -> List[dict]:
837849
aggregation_name = "terms_agg"
838850

argilla-server/tests/unit/search_engine/test_commons.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
VectorSettingsFactory,
6868
ImageFieldFactory,
6969
ChatFieldFactory,
70+
CustomFieldFactory,
7071
)
7172

7273

@@ -623,6 +624,34 @@ async def test_search_for_chat_field(self, search_engine: BaseElasticAndOpenSear
623624
assert len(result.items) == 2
624625
assert result.total == 2
625626

627+
async def test_search_for_custom_field(self, search_engine: BaseElasticAndOpenSearchEngine, opensearch: OpenSearch):
628+
custom_field = await CustomFieldFactory.create(name="field")
629+
630+
dataset = await DatasetFactory.create(fields=[custom_field])
631+
632+
records = await RecordFactory.create_batch(
633+
size=2,
634+
dataset=dataset,
635+
fields={
636+
custom_field.name: {
637+
"a": "This is a value",
638+
"b": 100,
639+
}
640+
},
641+
)
642+
643+
await refresh_dataset(dataset)
644+
await refresh_records(records)
645+
646+
await search_engine.create_index(dataset)
647+
await search_engine.index_records(dataset, records)
648+
649+
for query in ["value", 100]:
650+
result = await search_engine.search(dataset, query=TextQuery(q=query, field=custom_field.name))
651+
652+
assert len(result.items) == 2
653+
assert result.total == 2
654+
626655
@pytest.mark.parametrize(
627656
"statuses, expected_items",
628657
[
@@ -1064,11 +1093,16 @@ async def test_index_records_with_metadata(
10641093
async def test_index_records_with_vectors(
10651094
self, search_engine: BaseElasticAndOpenSearchEngine, opensearch: OpenSearch
10661095
):
1067-
dataset = await DatasetFactory.create()
1068-
text_fields = await TextFieldFactory.create_batch(size=5, dataset=dataset)
1069-
vectors_settings = await VectorSettingsFactory.create_batch(size=5, dataset=dataset, dimensions=5)
1096+
text_fields = await TextFieldFactory.create_batch(size=5)
1097+
vectors_settings = await VectorSettingsFactory.create_batch(size=5, dimensions=5)
1098+
1099+
dataset = await DatasetFactory.create(fields=text_fields, vectors_settings=vectors_settings, questions=[])
1100+
10701101
records = await RecordFactory.create_batch(
1071-
size=5, fields={field.name: f"This is the value for {field.name}" for field in text_fields}, responses=[]
1102+
size=5,
1103+
fields={field.name: f"This is the value for {field.name}" for field in text_fields},
1104+
dataset=dataset,
1105+
responses=[],
10721106
)
10731107

10741108
for record in records:

argilla/CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,25 @@ These are the section headers that we use:
1616

1717
## [Unreleased]()
1818

19+
## [2.3.0](https://github.com/argilla-io/argilla/compare/v2.2.2...v2.3.0)
20+
1921
### Added
2022

23+
- Added support for `CustomField`. ([#5422](https://github.com/argilla-io/argilla/pull/5422))
2124
- Added `inserted_at` and `updated_at` to `Resource` model as properties. ([#5540](https://github.com/argilla-io/argilla/pull/5540))
2225
- Added `limit` argument when fetching records. ([#5525](https://github.com/argilla-io/argilla/pull/5525)
23-
- Added similarity search support. ((#5546)[https://github.com/argilla-io/argilla/pull/5546])
26+
- Added similarity search support. ([#5546](https://github.com/argilla-io/argilla/pull/5546))
2427
- Added filter support for `id`, `_server_id`, `inserted_at` and `updated_at` record attributes. ([#5545](https://github.com/argilla-io/argilla/pull/5545))
28+
- Added support to read argilla credentials from colab secrets. ([#5541](https://github.com/argilla-io/argilla/pull/5541)))
2529

2630
### Changed
2731

2832
- Changed the __repr__ method for `SettingsProperties` to display the details of all the properties in `Setting` object. ([#5380](https://github.com/argilla-io/argilla/issues/5380))
33+
- Changed error messages when creating datasets with insufficient permissions. ([#5540](https://github.com/argilla-io/argilla/pull/5554))
34+
2935
### Fixed
3036

31-
- Fixed the deployment yaml used to create a new Argilla server in K8s. Added `USERNAME` and `PASSWORD` to the environment variables of pod template. ([#5434](https://github.com/argilla-io/argilla/issues/5434))
37+
- Fixed serialization of `ChatField` when collecting records from the hub and exporting to `datasets`. ([#5554](https://github.com/argilla-io/argilla/pull/5553))
3238

3339
## [2.2.2](https://github.com/argilla-io/argilla/compare/v2.2.1...v2.2.2)
3440

621 KB
Loading
98 KB
Loading
84.8 KB
Loading

0 commit comments

Comments
 (0)