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:
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.
import argilla_sdk as rg
# Define metadata properties as terms
metadata_field = rg.TermsMetadataProperty(
name="color",
options=["red", "blue", "green"],
title="Color",
)
# Define metadata properties as float
float_ metadata_field = rg.FloatMetadataProperty(
name="price",
min=0.0,
max=100.0,
title="Price",
)
# Define metadata properties as integer
int_metadata_field = rg.IntegerMetadataProperty(
name="quantity",
min=0,
max=100,
title="Quantity",
)
Metadata properties can be added to a dataset settings object:
dataset = rg.Dataset(
name="my_dataset",
settings=rg.Settings(
fields=[
rg.TextField(name="text"),
],
metadata=[
metadata_field,
float_metadata_field,
int_metadata_field,
],
),
)
To add records with metadata, refer to the
rg.Metadata
class documentation.
Class References¶
rg.FloatMetadataProperty
¶
Bases: MetadataPropertyBase
Source code in src/argilla_sdk/settings/_metadata.py
__init__(name, min=None, max=None, title=None, 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 value |
None
|
max |
Optional[float]
|
The maximum value |
None
|
title |
Optional[str]
|
The title of the metadata field |
None
|
client |
Optional[Argilla]
|
The client to use for API requests |
None
|
Raises: MetadataError: If an error occurs while defining metadata settings
Source code in src/argilla_sdk/settings/_metadata.py
rg.IntegerMetadataProperty
¶
Bases: MetadataPropertyBase
Source code in src/argilla_sdk/settings/_metadata.py
__init__(name, min=None, max=None, title=None, 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 value |
None
|
max |
Optional[int]
|
The maximum value |
None
|
title |
Optional[str]
|
The title of the metadata field |
None
|
Raises: MetadataError: If an error occurs while defining metadata settings
Source code in src/argilla_sdk/settings/_metadata.py
rg.TermsMetadataProperty
¶
Bases: MetadataPropertyBase
Source code in src/argilla_sdk/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[str]]
|
The list of options |
None
|
title |
Optional[str]
|
The title of the metadata field |
None
|
visible_for_annotators |
Optional[bool]
|
Whether the metadata field is visible for annotators |
True
|
Raises: MetadataError: If an error occurs while defining metadata settings