Utility functions
- flame_hub.get_field_names(model: type[ResourceT]) tuple[str, ...]
Returns all optional field names for a given model.
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 theIsField
sentinel which marks an optional field. The names of all annotated attributes are returned as a tuple.
- 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.