Metadata Properties¶
Metadata properties are used to define metadata fields in a dataset. Metadata fields are used to store additional information about the records in the dataset. For example, the category of a record, the price of a product, or any other information that is relevant to the record.
Usage Examples¶
Defining Metadata Property for a dataset¶
We define metadata properties via type specific classes. The following example demonstrates how to define metadata properties as either a float, integer, or terms metadata property and pass them to the Settings
.
TermsMetadataProperty
is used to define a metadata field with a list of options. For example, a color field with options red, blue, and green. FloatMetadataProperty
and IntegerMetadataProperty
is used to define a metadata field with a float value. For example, a price field with a minimum value of 0.0 and a maximum value of 100.0.
metadata_field = rg.TermsMetadataProperty(
name="color",
options=["red", "blue", "green"],
title="Color",
)
float_metadata_field = rg.FloatMetadataProperty(
name="price",
min=0.0,
max=100.0,
title="Price",
)
int_metadata_field = rg.IntegerMetadataProperty(
name="quantity",
min=0,
max=100,
title="Quantity",
)
dataset = rg.Dataset(
name="my_dataset",
settings=rg.Settings(
fields=[
rg.TextField(name="text"),
],
questions=[
rg.TextQuestion(name="response"),
],
metadata=[
metadata_field,
float_metadata_field,
int_metadata_field,
],
),
)
dataset = rg.Dataset(
name="my_dataset",
settings=settings,
)
To add records with metadata, refer to the
rg.Metadata
class documentation.
FloatMetadataProperty
¶
Bases: MetadataPropertyBase
Source code in src/argilla/settings/_metadata.py
__init__(name, min=None, max=None, title=None, visible_for_annotators=True, client=None)
¶
Create a metadata field with float settings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the metadata field |
required |
min |
Optional[float]
|
The minimum valid value. If none is provided, it will be computed from the values provided in the records. |
None
|
max |
Optional[float]
|
The maximum valid value. If none is provided, it will be computed from the values provided in the records. |
None
|
title |
Optional[str]
|
The title of the metadata to be shown in the UI |
None
|
visible_for_annotators |
Optional[bool]
|
Whether the metadata field is visible for annotators. |
True
|
Raises:
Type | Description |
---|---|
MetadataError
|
If an error occurs while defining metadata settings. |
Source code in src/argilla/settings/_metadata.py
IntegerMetadataProperty
¶
Bases: MetadataPropertyBase
Source code in src/argilla/settings/_metadata.py
__init__(name, min=None, max=None, title=None, visible_for_annotators=True, client=None)
¶
Create a metadata field with integer settings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the metadata field |
required |
min |
Optional[int]
|
The minimum valid value. If none is provided, it will be computed from the values provided in the records. |
None
|
max |
Optional[int]
|
The maximum valid value. If none is provided, it will be computed from the values provided in the records. |
None
|
title |
Optional[str]
|
The title of the metadata to be shown in the UI |
None
|
visible_for_annotators |
Optional[bool]
|
Whether the metadata field is visible for annotators. |
True
|
Raises:
Type | Description |
---|---|
MetadataError
|
If an error occurs while defining metadata settings. |
Source code in src/argilla/settings/_metadata.py
TermsMetadataProperty
¶
Bases: MetadataPropertyBase
Source code in src/argilla/settings/_metadata.py
__init__(name, options=None, title=None, visible_for_annotators=True, client=None)
¶
Create a metadata field with terms settings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the metadata field |
required |
options |
Optional[List[Any]]
|
The list of options |
None
|
title |
Optional[str]
|
The title of the metadata to be shown in the UI |
None
|
visible_for_annotators |
Optional[bool]
|
Whether the metadata field is visible for annotators. |
True
|
Raises:
Type | Description |
---|---|
MetadataError
|
If an error occurs while defining metadata settings |