Utility functions
- flame_hub._base_client._get_annotated_property_names(model: type[ResourceT], sentinel: object) tuple[str, ...]
Returns the names of all properties for a given model that are annotated with a specific sentinel.
This function traverses a given
model
and all of its bases using the method resolution order. While traversing, all attributes are checked if they are annotated with asentinel
object. The names of all annotated attributes are returned as a tuple.- Parameters:
- Returns:
- flame_hub.get_field_names(model: type[ResourceT]) tuple[str, ...]
This function is a wrapper which calls
_get_annotated_property_names()
withsentinel
set toIsOptionalField
.See also
_get_annotated_property_names()
,IsOptionalField
- flame_hub.get_includable_names(model: type[ResourceT]) tuple[str, ...]
This function is a wrapper which calls
_get_annotated_property_names()
withsentinel
set toIsIncludable
.See also
_get_annotated_property_names()
,IsIncludable
- flame_hub._base_client.obtain_uuid_from(uuid_identifiable: UuidModel | UUID | str) UUID
Extract a
UUID
from a model containing anid
property,UUID
object or a string.- Raises:
ValueError
If
uuid_identifiable
is neither an instance ofBaseModel
,str
norUUID
.
- flame_hub._base_client.uuid_validator(value: Any, handler: ValidatorFunctionWrapHandler) UUID
Callable for Pydantic’s wrap validator
WrapValidator
to cast resource type instances and strings toUUID
.This function tries to validate
value
withhandler
and if this raises a validation error, it tries to castvalue
to a UUID withobtain_from_uuid()
.- Raises:
ValidationError
If
obtain_from_uuid()
raises aValueError
, the originalValidationError
is raised.