Skip to content

Commit

Permalink
misc: define add_scalar alias
Browse files Browse the repository at this point in the history
  • Loading branch information
james-encord committed Dec 12, 2024
1 parent 39b4a9a commit ea384c3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions encord/metadata_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,35 @@ def add_scalar(
)
self._dirty = True

def set_scalar(
self,
k: str,
*,
data_type: Union[
Literal["boolean", "datetime", "number", "uuid", "varchar", "text", "string", "long_string"],
MetadataSchemaScalarType,
],
) -> None:
"""
Sets a simple metadata type for a given key in the schema.
Alias of add_scalar
**Parameters:**
- k : str: The key for which the metadata type is being set.
- data_type : Literal["boolean", "datetime", "number", "uuid", "varchar", "text", "string", "long_string"]
The type of metadata to be associated with the key. Must be a valid identifier.
"string" is an alias of "varchar"
"long_string" is an alias of "text"
**Raises:**
MetadataSchemaError: If the key `k` is already defined in the schema with a conflicting type.
ValueError: If `data_type` is not a valid type of metadata identifier.
"""
self.add_scalar(k, data_type=data_type)

def delete_key(self, k: str, *, hard: bool = False) -> None:
"""
Delete a metadata key from the schema.
Expand Down

0 comments on commit ea384c3

Please sign in to comment.