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

assertLicence(iso=False, liveness=False, bodyAttributes=False)[source]

Assert estimations in licences

Parameters:
  • iso – check or not iso feature

  • liveness – check or not liveness feature

  • bodyAttributes – check or not basic attributes feature

Raises:

VLException(Error.LicenseProblem)

checkLivenessEstimationLicensing()[source]

Check liveness estimation licensing

Raises:

VLException(Error.LicenseProblem) if liveness estimation disabled

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

getResponseContentType()[source]

Get response content type. :returns: response content type

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

loadDataFromQuery(model)[source]

Load data from query with pydantic :param model: pydantic model

Returns:

initialized object

Return type:

Any

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

Base handler class for resource with multipart requests availability

abstract async getDataFromMultipart(imageType=ImageType.IMAGE)[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:

Tuple[List[InputImageData], Optional[dict]]

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[InputImageData, RawDescriptorData]]

async getInputEstimationData(request, validationModel, imageType=ImageType.IMAGE, 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.

Return type:

List[Union[InputImageData, RawDescriptorData]]