Base handler

Base handler

Module realize base class for all handlers.

class luna_handlers.app.handlers.base_handler.BaseHandler(request)[source]

Base handler for other handlers.

luna3Client

luna3 client

Type

luna3.client.Client

dbContext

db context

Type

DBContext

redisContext

redis context

Type

RedisContext

checkLivenessEstimationLicensing(estimate)[source]

Check liveness estimation licensing :param estimate: liveness estimation status

Raises

VLException(Error.LicenseProblem) if liveness estimation disabled

checkPolicyLicensing(policies)[source]

Check handler policies licensing :param policies: handler policies

convertDetectionTimeToCurrentFormat(detectTime, defaultDetectTime)[source]

Convert detection time from UTC or LOCAL to string, considering current STORAGE_TIME

Parameters
  • detectTime – detection time in ISO format

  • defaultDetectTime – default time in UTC or LOCAL time zones

Returns

detection time in current format

Return type

str

countLivenessEstimationsPerformed(count)[source]

Count liveness estimations performed :param count: estimation count

async downloadBodySample(sampleId)[source]

Download body sample by id

Parameters

sampleId – sample id

Returns

sdk body warp

Return type

HumanWarp

async downloadFaceSample(sampleId)[source]

Download face sample by id

Parameters

sampleId – sample id

Returns

sdk face warp

Return type

FaceWarp

handleMonitoringData(monitoringData)[source]

Handle monitoring data. :param monitoringData: monitoring data

static loadDataFromJson(data, model)[source]

Load data from json with pydantic :param data: input data :param model: pydantic model

Returns

initialized object

Return type

Any

property sdkLoop: sdk.sdk_loop.task_loop.SDKTaskLoop

Get current sdk loop. :returns: sdk loop from warp

Return type

SDKTaskLoop

class luna_handlers.app.handlers.base_handler.BaseHandlerWithMultipart(request)[source]

Base handler class for resource with multipart requests availability

abstract async getDataFromMultipart(imageType=ImageType.rawImage)[source]

Get data from multipart request :param imageType: image type

Returns

list of Images or list warps and optionally dict with policies (for multipart request with policies)

Return type

Union[Tuple[Union[List[SDKDetectableImage], List[FaceWarp]], Optional[dict]], List[SDKDetectableImage], List[FaceWarp]]

async getDataFromRequest(request, validationModel, imageType, allowRawDescriptors=False)[source]

Get images from request body to detect faces. :param request: request :param imageType: imageType :param validationModel: validation model :param allowRawDescriptors: whether raw descriptor mimetypes allowed or not

Returns

list of Images or list warps

Raises
  • VLException(Error.BadContentType, 400, isCriticalError=False) – if content type of request is wrong

  • VLException(Error.BadMultipartInput, 400, isCriticalError=False) – if failed to read multipart

Return type

List[Union[SDKDetectableImage, FaceWarp, HumanWarp, RawDescriptorData]]

async getInputEstimationData(request, validationModel, imageType=ImageType.rawImage, autoOrient=True, allowRawDescriptors=False)[source]

Get images from request body to detect faces. :param request: request :param imageType: imageType :param validationModel: validation model :param autoOrient: A bool, whether to use orientation from exif. This is a common name among different image tools. :param allowRawDescriptors: whether raw descriptor mimetypes allowed or not

Returns

list of Images or list warps.

Return type

List[Union[SDKDetectableImage, FaceWarp, HumanWarp, RawDescriptorData]]