Luna services clients description
Here presented possibilities of luna-services clients.
Events client
The luna-events client which allows to create events, get events and get events statistics
Module contains luna-events client adapted for usage in lambda
- class luna_lambda_tools.public.clients.events.Events(eventsClient, accountId)[source]
Luna-events client
- checkGeneralEvent(eventId, **kwargs)[source]
Check general event existence by id.
- Parameters:
eventId (
str
) – event id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- deleteEvents(target=None, handlerId=None, createTimeGte=None, createTimeLt=None, insertTimeGte=None, insertTimeLt=None, raiseError=True, **kwargs)[source]
Delete events by filters.
- Parameters:
target (
list
[str
] |None
) – event deletion info targetshandlerId (
str
|None
) – event handler idcreateTimeGte (
str
|None
) – lower including create time boundarycreateTimeLt (
str
|None
) – upper excluding create time boundaryinsertTimeGte (
str
|None
) – lower including insert time boundaryinsertTimeLt (
str
|None
) – upper excluding insert time boundaryraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- deleteGeneralEvents(eventType=None, eventCreateTimeGte=None, eventCreateTimeLt=None, insertTimeGte=None, insertTimeLt=None, **kwargs)[source]
Delete general events by filters.
- Parameters:
eventType (
list
[str
] |None
) – general event typeseventCreateTimeGte (
str
|None
) – lower including create time boundaryeventCreateTimeLt (
str
|None
) – upper excluding create time boundaryinsertTimeGte (
str
|None
) – lower including insert time boundaryinsertTimeLt (
str
|None
) – upper excluding insert time boundary
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getDeletedGeneralEvents(deletionTimeGte=None, deletionTimeLt=None, eventIds=None, eventIdGte=None, eventIdLt=None, *, page=1, pageSize=10, order='desc', **kwargs)[source]
Get deleted general events.
- Parameters:
deletionTimeGte (
str
|None
) – lower including deletion time boundarydeletionTimeLt (
str
|None
) – upper excluding end time boundaryeventIds (
list
[str
] |None
) – event idseventIdGte (
str
|None
) – event id lower including boundeventIdLt (
str
|None
) – event id upper excluding boundpage (
int
|None
) – number of result pagepageSize (
int
|None
) – count of results in pageorder (
str
|None
) – result sort order (ask or desc)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getEvent(eventId, target=None, raiseError=True, **kwargs)[source]
Get event by id.
- Parameters:
eventId (
str
) – event idtarget (
list
[Literal
['account_id'
,'create_time'
,'end_time'
,'event_id'
,'handler_id'
,'external_id'
,'source'
,'stream_id'
,'top_match'
,'match_result'
,'face_detections'
,'face_id'
,'attach_result'
,'gender'
,'age'
,'emotion'
,'ethnic_group'
,'liveness'
,'deepfake'
,'body_detections'
,'body_basic_attributes'
,'upper_body'
,'lower_body'
,'accessories'
,'tags'
,'user_data'
,'location'
,'mask'
,'track_id'
,'meta'
]] |None
) – list of events’ fields to receive instead of full eventsraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getEventDescriptor(eventId=None, descriptorVersion=None, descriptorType=None, raiseError=True, **kwargs)[source]
Get event descriptor by filters.
- Parameters:
eventId (
str
|None
) – event iddescriptorVersion (
int
|None
) – descriptor versiondescriptorType (
str
|None
) – Kind of the descriptor (body or face)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with event descriptor will be returned.
- Return type:
class
- getEvents(target=None, createTimeGte=None, createTimeLt=None, endTimeGte=None, endTimeLt=None, eventIds=None, eventIdGte=None, eventIdLt=None, handlerIds=None, externalIds=None, topMatchingCandidatesLabel=None, topSimilarObjectIds=None, topSimilarExternalIds=None, topSimilarObjectSimilarityGte=None, topSimilarObjectSimilarityLt=None, ageLt=None, ageGte=None, gender=None, emotions=None, masks=None, ethnicGroups=None, liveness=None, apparentAgeGte=None, apparentAgeLt=None, apparentGender=None, headwearStates=None, headwearApparentColors=None, sleeveLengths=None, upperClothingColors=None, lowerGarmentTypes=None, lowerGarmentColors=None, shoesApparentColors=None, backpackStates=None, faceIds=None, userData=None, page=1, pageSize=10, order='desc', sources=None, tags=None, cities=None, areas=None, districts=None, streets=None, houseNumbers=None, originLongitude=None, originLatitude=None, longitudeDelta=None, latitudeDelta=None, trackIds=None, meta=None, raiseError=True, **kwargs)[source]
Get events by filters.
- Parameters:
target (
list
[Literal
['account_id'
,'create_time'
,'end_time'
,'event_id'
,'handler_id'
,'external_id'
,'source'
,'stream_id'
,'top_match'
,'match_result'
,'face_detections'
,'face_id'
,'attach_result'
,'gender'
,'age'
,'emotion'
,'ethnic_group'
,'liveness'
,'deepfake'
,'body_detections'
,'body_basic_attributes'
,'upper_body'
,'lower_body'
,'accessories'
,'tags'
,'user_data'
,'location'
,'mask'
,'track_id'
,'meta'
]] |None
) – list of events’ fields to receive instead of full eventscreateTimeGte (
str
|None
) – lower including create time boundarycreateTimeLt (
str
|None
) – upper excluding create time boundaryendTimeGte (
str
|None
) – lower including end time boundaryendTimeLt (
str
|None
) – upper excluding end time boundaryfaceIds (
list
[str
] |None
) – ids of faces linked with an eventeventIds (
list
[str
] |None
) – event idseventIdGte (
str
|None
) – event id lower including boundeventIdLt (
str
|None
) – event id upper excluding boundhandlerIds (
list
[str
] |None
) – handler idsexternalIds (
list
[str
] |None
) – external idsuserData (
str
|None
) – event user datasources (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of sourcetags (
list
[str
] |None
) – users tagstopMatchingCandidatesLabel (
str
|None
) – top matching candidates labeltopSimilarObjectIds (
list
[str
] |None
) – top similar object idstopSimilarExternalIds (
list
[str
] |None
) – top similar external idstopSimilarObjectSimilarityGte (
float
|None
) – lower including top similarity boundarytopSimilarObjectSimilarityLt (
float
|None
) – upper excluding top similarity boundaryageLt (
int
|None
) – upper excluding age boundaryageGte (
int
|None
) – lower including age boundarygender (
Union
[int
,Literal
['null'
],None
]) – gender of event (0 or 1)emotions (
list
[Union
[int
,Literal
['null'
]]] |None
) – dominant emotions in event (one of (1, 2, 3, 4, 5, 6, 7) - matches “anger”, “disgust”, “fear”, “happiness”, “neutral”, “sadness”, “surprise”)masks (
list
[Union
[int
,Literal
['null'
]]] |None
) – dominant masks in event (one of (1, 2, 3) - matches “missing”, “medical_mask”, “occluded”)ethnicGroups (
list
[Union
[int
,Literal
['null'
]]] |None
) – dominant ethnicity of the face ((1, 2, 3, 4) - means (indian, asian, african_american, caucasian)liveness (
list
[Union
[int
,Literal
['null'
]]] |None
) – dominant liveness of the face ((0, 1, 2) - means (“spoof”, “real”, “unknown”))apparentAgeLt (
int
|None
) – apparent age upper excluding boundaryapparentAgeGte (
int
|None
) – apparent age upper including boundaryapparentGender (
Union
[list
[Literal
[0
,1
,2
]],Literal
['null'
]]) – apparent gender estimation values (0 - female, 1 - male, 2 - undefined)headwearStates (
list
[Union
[Literal
[0
,1
,2
],Literal
['null'
]]] |None
) – headwear states (0 - absent, 1 - present, 2 - undefined)headwearApparentColors (
list
[Union
[Literal
['undefined'
,'black'
,'white'
,'other'
],Literal
['null'
]]] |None
) – headwear apparent colorssleeveLengths (
list
[Literal
['short'
,'long'
,'undefined'
,'null'
]] |None
) – sleeve lengthsupperClothingColors (
list
[Union
[Literal
['black'
,'blue'
,'green'
,'gray'
,'orange'
,'purple'
,'red'
,'white'
,'yellow'
,'pink'
,'brown'
,'beige'
,'khaki'
,'multicolored'
,'undefined'
],Literal
['null'
]]] |None
) – upper clothing colorslowerGarmentTypes (
list
[Literal
['undefined'
,'trousers'
,'shorts'
,'skirt'
,'null'
]] |None
) – lower garment typeslowerGarmentColors (
list
[Union
[Literal
['black'
,'blue'
,'green'
,'gray'
,'orange'
,'purple'
,'red'
,'white'
,'yellow'
,'pink'
,'brown'
,'beige'
,'khaki'
,'multicolored'
,'undefined'
],Literal
['null'
]]] |None
) – lower garment colorsshoesApparentColors (
list
[Union
[Literal
['undefined'
,'black'
,'white'
,'other'
],Literal
['null'
]]] |None
) – shoes apparent colorsbackpackStates (
list
[Union
[Literal
[0
,1
,2
],Literal
['null'
]]] |None
) – backpack states (0 - absent, 1 - present, 2 - undefined)areas (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of areasstreets (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of streetsdistricts (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of districtscities (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of citieshouseNumbers (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of house numbersoriginLongitude (
Union
[float
,Literal
['null'
],None
]) – origin longitude in degreesoriginLatitude (
Union
[float
,Literal
['null'
],None
]) – origin latitude in degreeslongitudeDelta (
float
|None
) – longitude delta in degreeslatitudeDelta (
float
|None
) – latitude delta in degreestrackIds (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of track idsmeta (
dict
|None
) – user-defined event meta’s filters in format {meta.<path.to.field>__<operator>:<type>: <value>}page (
int
|None
) – number of result pagepageSize (
int
|None
) – count of results in pageorder (
str
|None
) – result sort order (ask or desc)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getEventsStats(query=<luna3.common.http_objs.StatQuery object>, raiseError=True, **kwargs)[source]
Get events statistics by aggregation (<aggregator> and <groupBy> on <target>) and filters.
- Parameters:
query (
StatQuery
) – query object or query dict, contained in StatQuery objectraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with event statistics will be returned.
- Return type:
class
- getGeneralEvent(eventId, **kwargs)[source]
Get general event by id.
- Parameters:
eventId (
str
) – event id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getGeneralEvents(eventType=None, createTimeGte=None, createTimeLt=None, endTimeGte=None, endTimeLt=None, insertTimeGte=None, insertTimeLt=None, eventIds=None, eventIdGte=None, eventIdLt=None, sources=None, streamIds=None, trackIds=None, cities=None, areas=None, districts=None, streets=None, houseNumbers=None, originLongitude=None, originLatitude=None, longitudeDelta=None, latitudeDelta=None, eventContentFilters=None, *, page=1, pageSize=10, order='desc', **kwargs)[source]
Get general events by filters.
- Parameters:
eventType (
list
[str
] |None
) – general event typescreateTimeGte (
str
|None
) – lower including create time boundarycreateTimeLt (
str
|None
) – upper excluding create time boundaryendTimeGte (
str
|None
) – lower including end time boundaryendTimeLt (
str
|None
) – upper excluding end time boundaryinsertTimeGte (
str
|None
) – lower including insert time boundaryinsertTimeLt (
str
|None
) – upper excluding insert time boundaryeventIds (
list
[str
] |None
) – event idseventIdGte (
str
|None
) – event id lower including boundeventIdLt (
str
|None
) – event id upper excluding boundsources (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of sourcesstreamIds (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of stream idstrackIds (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of track idscities (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of citiesareas (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of areasdistricts (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of districtsstreets (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of streetshouseNumbers (
list
[Union
[str
,Literal
['null'
]]] |None
) – list of house numbersoriginLongitude (
Union
[float
,Literal
['null'
],None
]) – origin longitude in degreesoriginLatitude (
Union
[float
,Literal
['null'
],None
]) – origin latitude in degreeslongitudeDelta (
float
|None
) – longitude delta in degreeslatitudeDelta (
float
|None
) – latitude delta in degreeseventContentFilters (
dict
|None
) – event json content filterspage (
int
|None
) – number of result pagepageSize (
int
|None
) – count of results in pageorder (
str
|None
) – result sort order (ask or desc)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getGeneralEventsStats(query=<luna3.common.http_objs.GeneralStatQuery object>, **kwargs)[source]
Get general events statistics by aggregation (<aggregator> and <groupBy> on <target>) and filters.
- Parameters:
query (
StatQuery
|dict
) – query object or query dict, contained in GeneralStatQuery object- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with event statistics will be returned.
- Return type:
class
- headEvent(eventId, raiseError=True, **kwargs)[source]
Check event existence by id.
- Parameters:
eventId (
str
) – event idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- saveEvents(events, waitEventsSaving=None, raiseError=True, **kwargs)[source]
Save events to luna-events.
- Parameters:
events (
list
[Event
]) – list of eventswaitEventsSaving (
bool
|None
) – whether to wait events saving (response will be received only after events will be saved)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- saveGeneralEvents(events, waitEventsSaving=None, contentType='application/msgpack', **kwargs)[source]
Save general events to luna-events.
- Parameters:
events (
list
[GeneralEvent
|dict
]) – list of eventswaitEventsSaving (
bool
|None
) – whether to wait events saving (response will be received only after events will be saved)contentType (
str
) – content type to use (supported now: “application/json”, “application/msgpack” (default))
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
Faces client
The luna-faces client which allows to create/get/delete faces/attributes/lists
Module contains luna-faces client adapted for usage in lambda
- class luna_lambda_tools.public.clients.faces.Faces(facesClient, accountId)[source]
Luna-faces client
- createAttribute(basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, xpk=None, ttl=None, raiseError=True, **kwargs)[source]
Create new attributes. Notice that XPK argument overwrites basic attributes and descriptors above.
- Parameters:
descriptors (
list
[bytes
|RawDescriptor
] |None
) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
dict
|None
) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.xpk (
bytes
) – SDKObject bytes to load attributes fromttl (
int
|None
) – temporary attribute ttlraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with attribute id.
- Return type:
class
- createFace(attributeId=None, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, eventId=None, userData='', externalId=None, avatar=None, listIds=None, raiseError=True, **kwargs)[source]
Create new face in luna-faces
- Parameters:
attributeId (
str
|None
) – attribute iddescriptors (
list
[bytes
|RawDescriptor
] |None
) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
dict
|None
) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.eventId (
str
|None
) – reference to event which created faceuserData (
str
|None
) – face user dataexternalId (
str
|None
) – external id of the face, if it has its own mapping in the systemavatar (
str
|None
) – face avatar urllistIds (
list
[str
] |None
) – created face will be attach to these listsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created face id will be returned.
- Return type:
class
- createList(userData='', listId=None, raiseError=True, **kwargs)[source]
Create list.
- Parameters:
userData (
str
) – user datalistId (
str
|None
) – custom list id to create the listraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created list id will be returned.
- Return type:
class
- deleteAttribute(attributeId, raiseError=True, **kwargs)[source]
Delete attribute with specifeid id
- Parameters:
attributeId (
str
) – attribute idraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return response empty body.
- Return type:
class
- deleteFace(faceId, raiseError=True, **kwargs)[source]
Delete face. Optional you can set, that face must belong to account.
- Parameters:
faceId (
str
) – face idraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- deleteFaceAttributes(faceId, raiseError=True, **kwargs)[source]
Delete face attributes.
- Parameters:
faceId (
str
) – face idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse
- Return type:
class
- deleteFaces(faceIds, ignore=None, raiseError=True, **kwargs)[source]
Delete faces. Optional you can set, that faces must belong to account.
- Parameters:
faceIds (
list
[str
]) – face id listignore (
int
|None
) – ignore non-existing facesraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- deleteList(listId, withFaces=0, raiseError=True, **kwargs)[source]
Remove list. Optional you can set, that list must belong to account.
- Parameters:
listId (
str
) – list idwithFaces (
int
) – remove lists and all faces witch is contained in the listsraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- deleteLists(listIds, withFaces=None, raiseError=True, **kwargs)[source]
Delete lists. Optional you can set, that lists must belong to account.
- Parameters:
listIds (
list
[str
]) – ids of listswithFaces (
int
) – remove lists and all the faces contained in the listsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- getAttribute(attributeId, descriptorVersion=None, targets=None, raiseError=True, **kwargs)[source]
Retrieve a attribute by id.
- Parameters:
attributeId (
str
) – attribute idtargets (
list
[str
] |None
) – Available targets: descriptor, basic_attributes, basic_attributes_samples, face_descriptors_samples, account_id, create_timedescriptorVersion (
int
) – descriptor version to receiveraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with attribute.
- Return type:
class
- getAttributeIds(listId=None, timeLt=None, timeGte=None, page=1, pageSize=1000, raiseError=True, **kwargs)[source]
Get ids of attributes from list by period.
- Parameters:
listId (
str
|None
) – list idtimeLt (
str
|None
) – upper bound of face update timetimeGte (
str
|None
) – lower bound of face update timepage (
int
|None
) – page, default 1pageSize (
int
|None
) – page size, default 1000, max 100000raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes ids will be returned.
- Return type:
class
- getAttributeSamples(attributeId, raiseError=True, **kwargs)[source]
Retrieve a attribute by id.
- Parameters:
attributeId (
str
) – attribute idraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with samples.
- Return type:
class
- getAttributes(attributeIds, descriptorVersion=None, targets=None, raiseError=True, **kwargs)[source]
Get list of attributes
- Parameters:
attributeIds (
list
[str
]) – list of attributes of interesttargets (
list
[str
] |None
) – Available targets: descriptor, basic_attributes, basic_attributes_samples, face_descriptors_samples, account_id, create_timedescriptorVersion (
int
) – descriptor version to receiveraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- getAttributesFromList(listId, linkKeyLt=None, linkKeyGte=None, limit=1000, parity=None, raiseError=True, **kwargs)[source]
Get all attributes from list by period.
- Parameters:
listId (
str
) – list idlinkKeyLt (
str
|None
) – upper including link key boundarylinkKeyGte (
str
|None
) – lower including link key boundarylimit (
int
|None
) – limitparity (
int
|None
) – if 1 - get with even and odd max link keys else max link keyraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes will be returned.
- Return type:
class
- getFace(faceId, targets=None, raiseError=True, **kwargs)[source]
Get face by id. Optional you can set, that face must belong to account.
- Parameters:
faceId (
str
) – face idtargets (
list
[str
] |None
) – targets to get faceraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with face will be returned.
- Return type:
class
- getFaceAttributeSamples(faceId, raiseError=True, **kwargs)[source]
Get face attribute samples.
- Parameters:
faceId (
str
) – face idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attribute samples will be returned.
- Return type:
class
- getFaceAttributes(faceId, targets=None, descriptorVersion=None, raiseError=True, **kwargs)[source]
Get face attributes.
- Parameters:
faceId (
str
) – face idtargets (
list
[str
] |None
) – targets to get face attributes. Available targets: create_time, face_descriptor, basic_attributes, face_descriptor_samples, basic_attributes_samples.descriptorVersion (
int
|None
) – descriptor versionraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes will be returned.
- Return type:
class
- getFaces(userData=None, eventId=None, listId=None, faceIds=None, timeLt=None, timeGte=None, page=1, pageSize=10, attributeIds=None, externalIds=None, faceIdGte=None, faceIdLt=None, targets=None, raiseError=True, **kwargs)[source]
Get faces by filters. Optional you can set, that faces must belong to account.
- Parameters:
userData (
str
|None
) – user data, part of user data, case insensitiveeventId (
str
|None
) – event idlistId (
str
|None
) – list idfaceIds (
list
[str
] |None
) – face idstimeLt (
str
|None
) – upper bound of face create timetimeGte (
str
|None
) – lower bound of face create timepage (
int
|None
) – page count, default 1pageSize (
int
|None
) – page size, default 10, unlimited if -1attributeIds (
list
[str
] |None
) – attributes idsexternalIds (
list
[str
] |None
) – list of external identifiers of persons, if they have their own mapping in the systemfaceIdGte (
str
|None
) – lower face id including boundaryfaceIdLt (
str
|None
) – upper face id excluding boundarytargets (
list
[str
] |None
) – targets to get facesraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with faces will be returned.
- Return type:
class
- getFacesAttributes(faceIds, raiseError=True, **kwargs)[source]
Return attributeId of faces from faceIds list
- Parameters:
faceIds (
list
) – list of faceId for return their attributesraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes ids will be returned.
- Return type:
class
- getFacesCount(userData=None, eventId=None, listId=None, faceIds=None, timeLt=None, timeGte=None, attributeIds=None, externalIds=None, faceIdGte=None, faceIdLt=None, raiseError=True, **kwargs)[source]
Count faces by filters. Optional you can set, that faces must belong to account.
- Parameters:
userData (
str
|None
) – user data, part of user data, case insensitiveeventId (
str
|None
) – event idlistId (
str
|None
) – list idfaceIds (
list
[str
] |None
) – face idstimeLt (
str
|None
) – upper bound of face create timetimeGte (
str
|None
) – lower bound of face create timeattributeIds (
list
[str
] |None
) – attributes idsexternalIds (
list
[str
] |None
) – list of external identifiers of persons, if they have their own mapping in the systemfaceIdGte (
str
|None
) – lower face id including boundaryfaceIdLt (
str
|None
) – upper face id excluding boundaryraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with number of faces will be returned.
- Return type:
class
- getList(listId, page=1, pageSize=10, raiseError=True, **kwargs)[source]
Get list. Optional you can set, that list must belong to account.
- Parameters:
listId (
str
) – list idpage (
int
|None
) – page count, default 1pageSize (
int
|None
) – page size, default 10raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with list will be returned.
- Return type:
class
- getLists(userData=None, userDataEq=None, createTimeLt=None, createTimeGte=None, lastUpdateTimeLt=None, lastUpdateTimeGte=None, listIds=None, listIdLt=None, listIdGte=None, page=1, pageSize=10, raiseError=True, **kwargs)[source]
Get lists. Optional you can set, that lists must belong to account.
- Parameters:
userData (
str
|None
) – user data, part of user data, case sensitiveuserDataEq (
str
|None
) – user data, case sensitivecreateTimeLt (
str
|None
) – upper bound of list create timecreateTimeGte (
str
|None
) – lower bound of list create time including boundarylastUpdateTimeLt (
str
|None
) – upper bound of list last update timelastUpdateTimeGte (
str
|None
) – lower bound of list last update time including boundarylistIdLt (
str
|None
) – upper bound of list idlistIdGte (
str
|None
) – lower bound of list id including boundarylistIds (
list
[str
] |None
) – list idspage (
int
|None
) – page, default 1pageSize (
int
|None
) – page size, default 10raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lists will be returned.
- Return type:
class
- getListsCount(userData=None, userDataEq=None, createTimeLt=None, createTimeGte=None, lastUpdateTimeLt=None, lastUpdateTimeGte=None, listIds=None, listIdLt=None, listIdGte=None, raiseError=True, **kwargs)[source]
Get number of lists. Optional you can set, that lists must belong to account.
- Parameters:
userData (
str
|None
) – user data, part of user data, case sensitiveuserDataEq (
str
|None
) – user datacreateTimeLt (
str
|None
) – upper bound of list create timecreateTimeGte (
str
|None
) – lower bound of list create time including boundarylastUpdateTimeLt (
str
|None
) – upper bound of list last update timelastUpdateTimeGte (
str
|None
) – lower bound of list last update time including boundarylistIds (
list
[str
] |None
) – list idslistIdLt (
str
|None
) – upper bound of list idlistIdGte (
str
|None
) – lower bound of list id including boundaryraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with number of lists will be returned.
- Return type:
class
- headAttribute(attributeId, raiseError=True, **kwargs)[source]
Check attributes with attribute id exists.
- Parameters:
attributeId (
str
) – attribute idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- headFace(faceId, raiseError=True, **kwargs)[source]
Check face existence by id. Optional you can set, that face must belong to account.
- Parameters:
faceId (
str
) – face idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- headList(listId, raiseError=True, **kwargs)[source]
Check list existence. Optional you can set, that list must belong to account.
- Parameters:
listId (
str
) – list idraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- linkFacesToList(listId, faceIds, raiseError=True, **kwargs)[source]
Attach faces to list.
- Parameters:
listId (
str
) – list idfaceIds (
list
[str
]) – face idsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- patchFace(faceId, eventId=None, userData=None, externalId=None, avatar=None, raiseError=True, **kwargs)[source]
Update face. You can update event id, user data, attribute id. Optional you can set, that face must belong to account.
- Parameters:
faceId (
str
) – face ideventId (
str
|None
) – new event idexternalId (
str
|None
) – external id of the face, if it has its own mapping in the systemuserData (
str
|None
) – new user dataavatar (
str
|None
) – face avatar urlraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- patchList(listId, userData, raiseError=True, **kwargs)[source]
Update user data of list. Optional you can set, that list must belong to account.
- Parameters:
listId (
str
) – list iduserData (
str
) – new user dataraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- putAttribute(attributeId, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, xpk=None, ttl=None, force=None, raiseError=True, **kwargs)[source]
Put attribute by id. Notice that XPK argument overwrites basic attributes and descriptors above.
- Parameters:
attributeId (
str
) – attribute iddescriptors (
list
[bytes
|RawDescriptor
] |None
) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
dict
|None
) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.xpk (
bytes
) – SDKObject bytes to load attributes fromttl (
int
|None
) – temporary attribute ttlforce (
int
|None
) – replace or not existence attributeraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- putFace(faceId, externalId=None, attributeId=None, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, eventId=None, userData='', avatar=None, listIds=None, raiseError=True, **kwargs)[source]
Put face in luna-faces
- Parameters:
faceId (
str
) – external face idexternalId (
str
|None
) – external id of the face, if it has its own mapping in the systemattributeId (
str
|None
) – attribute iddescriptors (
list
[bytes
|RawDescriptor
] |None
) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
dict
|None
) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.eventId (
str
|None
) – reference to event which created faceuserData (
str
|None
) – face user dataavatar (
str
|None
) – face avatar urllistIds (
list
[str
] |None
) – created face will be attach to these listsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with face id will be returned.
- Return type:
class
- putFaceAttributes(faceId, attributeId=None, basicAttributes=None, descriptors=None, basicAttributesSamples=None, descriptorSamples=None, raiseError=True, **kwargs)[source]
Put face attributes.
- Parameters:
faceId (
str
) – face idattributeId (
str
|None
) – attribute iddescriptors (
list
[bytes
|RawDescriptor
] |None
) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
dict
|None
) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse
- Return type:
class
- unlinkFacesFromList(listId, faceIds, raiseError=True, **kwargs)[source]
Detach faces to list.
- Parameters:
listId (
str
) – list idfaceIds (
list
[str
]) – face idsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- updateFaceAttributes(faceId, attributeId=None, basicAttributes=None, descriptors=None, basicAttributesSamples=None, descriptorSamples=None, raiseError=True, **kwargs)[source]
Update face attributes.
- Parameters:
faceId (
str
) – face idattributeId (
str
|None
) – attribute iddescriptors (
list
[bytes
|RawDescriptor
] |None
) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
dict
|None
) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse
- Return type:
class
Luna Image Store client
The luna-image-store client which allows to create/get/delete images and objects
Module contains luna-image-store client adapted for usage in lambda
- class luna_lambda_tools.public.clients.lis.LIS(lisClient, accountId, bucket)[source]
Luna-image-store client
- deleteImage(imageId, raiseError=True, **kwargs)[source]
Delete image from bucket.
- Parameters:
imageId (
str
) – image id to deleteraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- deleteImages(imageIds, raiseError=True, **kwargs)[source]
Delete images from bucket.
- Parameters:
imageIds (
list
[str
]) – images ids to deleteraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- deleteObject(objectId, raiseError=True, **kwargs)[source]
Delete object from bucket.
- Parameters:
objectId (
str
) – object idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- deleteObjects(objectIds, raiseError=True, **kwargs)[source]
Delete objects from bucket.
- Parameters:
objectIds (
list
[str
]) – objects ids to deleteraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- getImage(imageId, withMeta=None, raiseError=True, **kwargs)[source]
Get image from bucket.
- Parameters:
imageId (
str
) – external image idwithMeta (
bool
) – whether to retrieve user-defined image metadataraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- getObject(objectId, raiseError=True, **kwargs)[source]
Get object from bucket.
- Parameters:
objectId (
str
) – object idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- headImage(imageId, withMeta=None, raiseError=True, **kwargs)[source]
Check image existence in bucket.
- Parameters:
imageId (
str
) – external image idwithMeta (
bool
) – whether to retrieve user-defined image metadataraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- headObject(objectId, raiseError=True, **kwargs)[source]
Check object existence in bucket.
- Parameters:
objectId (
str
) – object idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- postImage(imageInBytes, contentType='image/jpeg', raiseError=True, **kwargs)[source]
Post an image to bucket.
- Parameters:
imageInBytes (
bytes
|bytearray
) – byte’s array (image)contentType (
str
) – content-type of image or image/jpeg for defaultraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- postObject(objectBody, contentType='application/json', raiseError=True, **kwargs)[source]
Post object to bucket.
- Parameters:
objectBody (
str
) – object, available: text, jsoncontentType (
str
) – content-type of object or application/json for defaultraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- putImage(imageInBytes, imageId, contentType='image/jpeg', raiseError=True, **kwargs)[source]
Put an image to bucket.
- Parameters:
imageInBytes (
bytes
|bytearray
) – byte’s array (image)imageId (
str
) – image idcontentType (
str
) – content-type of image or image/jpeg for defaultraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- putObject(objectBody, objectId, contentType='application/json', raiseError=True, **kwargs)[source]
Put object to bucket.
- Parameters:
objectBody (
str
) – object, available: text, jsonobjectId (
str
) – object idcontentType (
str
|None
) – content-type of object or application/json for defaultraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
Luna Python Matcher client
The luna-python-matcher client which allows to match/crossmatch faces/bodies
Module contains luna-python-matcher client adapted for usage in lambda
- class luna_lambda_tools.public.clients.lpm.LPM(lpmClient, accountId)[source]
Luna-python-matcher client
- crossmatchBodies(candidateFilters, referenceFilters, limit=None, threshold=None, sorting=None, raiseError=True, **kwargs)[source]
Cross Matcher API allows to submit tasks to a service that searches for events by given filters and matches them with each other. Resource implements body descriptors matching.
- Parameters:
candidateFilters (
EventFilters
) – candidate events filtersreferenceFilters (
EventFilters
) – reference events filterslimit (
int
|None
) – matching limitthreshold (
int
|None
) – matching thresholdsorting (
int
|None
) – whether to sort match resultsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- crossmatchFaces(candidateFilters, referenceFilters, limit=None, threshold=None, sorting=None, raiseError=True, **kwargs)[source]
Cross Matcher API allows to submit tasks to a service that searches for faces/events by given filters and matches them with each other. Resource implements face descriptors matching.
- Parameters:
candidateFilters (
FaceFilters
|EventFilters
|AttributeFilters
) – candidate filtersreferenceFilters (
FaceFilters
|EventFilters
|AttributeFilters
) – reference filterslimit (
int
|None
) – matching limitthreshold (
int
|None
) – matching thresholdsorting (
int
|None
) – whether to sort match resultsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- matchBodies(candidates, references, raiseError=True, **kwargs)[source]
Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.
- Parameters:
candidates (
list
[Candidates
]) – Candidates object with info about candidates (possible type variants: events)references (
list
[Reference
|BinaryReference
]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, raw descriptors)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- matchFaces(candidates, references, raiseError=True, **kwargs)[source]
Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.
- Parameters:
candidates (
list
[Candidates
]) – Candidates object with info about candidatesreferences (
list
[Reference
|BinaryReference
]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, attributes, faces, raw descriptors)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- matchGeneralEvents(candidates, references, descriptorType, platCoef=None, descriptorVersion=None, accept='application/msgpack', **kwargs)[source]
Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.
- Parameters:
descriptorType (
str
) – base descriptor type for references and candidatesdescriptorVersion (
int
|None
) – descriptor version of matchingplatCoef (
list
[dict
|PlatCoef
] |None
) – plat coefs, for normalizing matching resultscandidates (
list
[Candidates
]) – Candidates object with info about candidatesreferences (
list
[Reference
|BinaryReference
]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, attributes, faces, raw descriptors)accept (
str
) – expected content type
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- matchRaw(candidates, references, raiseError=True, **kwargs)[source]
Matcher raw API allows to match each candidate with each reference descriptors.
- Parameters:
candidates (
list
[BinaryReference
]) – list of BinaryReference objects for candidatesreferences (
list
[BinaryReference
]) – list of BinaryReference objects for referencesraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching for each reference
- Return type:
class
Luna Remote SDK client
The luna-remote-sdk client which allows to detect faces/bodies on images, extract descriptors and estimate several parameters
Module contains luna-remote-sdk client adapted for usage in lambda
- class luna_lambda_tools.public.clients.lrs.LRS(lrsClient, accountId)[source]
Luna-remote-sdk client
- sdk(inputData, multifacePolicy=1, detectFace=None, detectBody=None, estimateHeadPose=None, estimateLandmarks68=None, estimateLandmarks5=None, estimateQuality=None, estimateGaze=None, estimateEyesAttributes=None, estimateEmotions=None, estimateMouthAttributes=None, estimateMask=None, estimateGlasses=None, estimateLiveness=None, estimateFaceWarp=None, estimateBodyWarp=None, aggregateAttributes=None, estimateBasicAttributes=None, estimateBodyDescriptor=None, estimateFaceDescriptor=None, estimateUpperBody=None, estimateLowerBody=None, estimateBodyBasicAttributes=None, estimateAccessories=None, pitchThreshold=None, rollThreshold=None, yawThreshold=None, scoreThreshold=None, maskStates=None, livenessStates=None, imageType=None, useExifInfo=None, extractExif=None, raiseError=True, **kwargs)[source]
Detect faces on input images.
- Parameters:
inputData (
BinaryImage
|list
[BinaryImage
] |list
[UrlForDetection
] |list
[str
]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idsmultifacePolicy (
int
) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the imagedetectFace (
int
|None
) – detect facesdetectBody (
int
|None
) – detect human bodiesestimateHeadPose (
int
|None
) – Available values : 0, 1estimateLandmarks5 (
int
|None
) – Available values : 0, 1estimateLandmarks68 (
int
|None
) – Available values : 0, 1estimateQuality (
int
|None
) – Available values : 0, 1estimateGaze (
int
|None
) – Available values : 0, 1estimateEyesAttributes (
int
|None
) – Available values : 0, 1estimateMouthAttributes (
int
|None
) – Available values : 0, 1estimateEmotions (
int
|None
) – Available values : 0, 1estimateMask (
int
|None
) – Available values: 0, 1estimateGlasses (
int
|None
) – Available values: 0, 1estimateLiveness (
int
|None
) – Available values: 0, 1estimateFaceDescriptor (
int
|None
) – Available values : 0, 1estimateBodyDescriptor (
int
|None
) – Available values : 0, 1estimateBasicAttributes (
int
|None
) – Available values : 0, 1estimateBodyWarp (
int
|None
) – Available values : 0, 1estimateFaceWarp (
int
|None
) – Available values : 0, 1estimateUpperBody (
int
|None
) – Available values : 0, 1estimateLowerBody (
int
|None
) – Available values : 0, 1estimateBodyBasicAttributes (
int
|None
) – Available values : 0, 1estimateAccessories (
int
|None
) – Available values : 0, 1pitchThreshold (
int
|None
) – maximum deviation pitch angle from 0rollThreshold (
int
|None
) – maximum deviation roll angle from 0yawThreshold (
int
|None
) – maximum deviation yaw angle from 0scoreThreshold (
float
) – descriptor garbage scoremaskStates (
list
[int
] |None
) – Array of integer (filter by mask state) (Items Enum:1 2 3)livenessStates (
list
[int
] |None
) – Array of integer (filter by liveness state) (Items Enum:0 1 2)aggregateAttributes (
int
|None
) – Available values : 0, 1imageType (
int
|None
) – image type (0 - raw image, 1 - face warped image, 2 - body warped image)useExifInfo (
int
|None
) – whether to use exif info for auto orientationextractExif (
int
|None
) – extract EXIF meta information from imagesraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with samples, exif, filename for succeeded images and errors for failed images will be returned.
- Return type:
class
Luna Sender client
The luna-sender client which allows to send custom events to luna-sender
Module contains luna-sender client adapted for usage in lambda
- class luna_lambda_tools.public.clients.sender.Sender(senderClient, accountId)[source]
Luna-sender client
- publish(events, *, handlerId, eventCreateTime, eventEndTime, raiseError=True, **kwargs)[source]
Publish user generated events. :type events:
list
[dict
] :param events: user generated events to be published :type handlerId:str
:param handlerId: event handler id :type eventCreateTime:str
:param eventCreateTime: event creation time :type eventEndTime:str
:param eventEndTime: event end time :type raiseError: :param raiseError: whether to raise LunaApiException in case of failure
Luna Handlers client
The luna-handlers client which allows to send custom events to luna-handlers
Module contains luna-handlers client adapted for usage in lambda
- class luna_lambda_tools.public.clients.handlers.Handlers(handlersClient, accountId)[source]
Luna-handlers client
- checkHandlerById(handlerId, **kwargs)[source]
Check whether handler exists by its id
- Parameters:
handlerId (
str
) – handler id (uuid4)- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
class
- checkVerifier(verifierId, **kwargs)[source]
Check verifier existence
- Parameters:
verifierId (
str
) – verifier id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
class
- createHandler(policies=None, handlerType=None, lambdaId=None, description=None, **kwargs)[source]
Create new handler. Handler determinate a list of rules for proccessing input images. You can set parameters for detecting faces, extracting attributes. You can set rules for matching attributes and creating faces from them.
- Parameters:
policies (
Policies
|None
) – object with policies informationhandlerType (
int
|None
) – handler type (0 - static, 1 - dynamic, 2 - lambda)lambdaId (
str
|None
) – lambda iddescription (
str
|None
) – user description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url
- Return type:
class
- createVerifier(policies=None, description=None, **kwargs)[source]
Create new verifier. Verifier determinate a list of rules for processing & verification of input images. You can set parameters for detecting faces, extracting attributes. You can set rules for matching attributes and creating faces from them.
- Parameters:
policies (
VerifierPolicies
|None
) – object with policies informationdescription (
str
|None
) – user description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new verifier id and url
- Return type:
class
- deleteHandlerById(handlerId, **kwargs)[source]
Remove handler by id
- Parameters:
handlerId (
str
) – handler id (uuid4)- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
class
- deleteVerifier(verifierId, **kwargs)[source]
Remove verifier :rtype:
Union
[Awaitable
[LunaResponse
],LunaResponse
]- Args:
verifierId: verifier id
- Returns:
class:~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- detectFaces(inputData, multifacePolicy=1, estimateHeadPose=0, detectLandmarks68=0, extractExif=0, estimateQuality=0, estimateGaze=0, estimateEyesAttributes=0, estimateEmotions=0, estimateMask=0, estimateMouthAttributes=0, pitchThreshold=None, rollThreshold=None, yawThreshold=None, warpedImage=0, useExifInfo=None, estimateFaceQuality=0, **kwargs)[source]
Detect faces on input images.
- Parameters:
inputData (
BinaryImage
|list
[BinaryImage
] |list
[UrlForDetection
] |list
[str
]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idsmultifacePolicy (
int
) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the imageestimateHeadPose (
int
) – Available values : 0, 1detectLandmarks68 (
int
) – Available values : 0, 1extractExif (
int
) – Available values : 0, 1estimateQuality (
int
) – Available values : 0, 1estimateGaze (
int
) – Available values : 0, 1estimateEyesAttributes (
int
) – Available values : 0, 1estimateMouthAttributes (
int
) – Available values : 0, 1estimateEmotions (
int
) – Available values : 0, 1estimateMask (
int
) – Available values : 0, 1pitchThreshold (
int
|None
) – maximum deviation pitch angle from 0rollThreshold (
int
|None
) – maximum deviation roll angle from 0yawThreshold (
int
|None
) – maximum deviation yaw angle from 0warpedImage (
int
) – Whether input image is a warped or arbitrary image.useExifInfo (
int
|None
) – whether to use exif info for auto orientationestimateFaceQuality (
int
) – whether to estimate face quality
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with samples, exif, filename for succeeded images and errors for failed images will be returned.
- Return type:
class
- emitEvents(handlerId, inputData, policies=None, externalId=None, userData=None, aggregateAttributes=None, source=None, streamId=None, city=None, street=None, district=None, area=None, houseNumber=None, tags=None, latitude=None, longitude=None, imageType=None, lunaEventTime=None, lunaEventEndTime=None, trackId=None, useExifInfo=None, meta=None, **kwargs)[source]
Emit input events.
- Parameters:
handlerId (
str
) – handler idinputData (
BinaryImage
|list
[BinaryImage
] |list
[UrlForDetection
] |list
[str
] |list
[SampleForDetection
]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idspolicies (
Policies
|dict
|None
) – object with policies information for dynamic handlerexternalId (
str
|None
) – external iduserData (
str
|None
) – user dataaggregateAttributes (
int
|None
) – aggregate all attributes (descriptot, age, gender) or not (0 or 1)source (
str
|None
) – sourcestreamId (
str
|None
) – stream idcity (
str
|None
) – event citystreet (
str
|None
) – event streetarea (
str
|None
) – event areadistrict (
str
|None
) – event districthouseNumber (
str
|None
) – event house numbertags (
str
|None
) – tagslatitude (
float
|None
) – event latitude in degreeslongitude (
float
|None
) – event longitude in degreesimageType (
int
) – image type (0 - raw image, 1 - face warped image, 2 - body warped image)lunaEventTime (
str
|None
) – user defined event create timelunaEventEndTime (
str
|None
) – user defined event end timetrackId (
str
|None
) – (str) event track iduseExifInfo (
int
|None
) – whether to use exif info for auto orientationmeta (
dict
|None
) – user-defined event metadata
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url
- Return type:
class
- emitStreamEvents(handlerId, inputData, **kwargs)[source]
Emit stream events.
- Parameters:
handlerId (
str
) – handler idinputData (
StreamEventsSource
) – structure with stream event(s) source
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url
- Return type:
class
- extractAttrFromSample(sampleIds, scoreThreshold=0, extractDescriptor=1, extractBasicAttributes=0, aggregateAttributes=0, ttl=None, **kwargs)[source]
Extract attributes from samples.
- Parameters:
sampleIds (
list
[str
]) – list of samplesscoreThreshold (
float
) – number [ 0 .. 1 ]; example: 0.99; descriptor quality score threshold. All the attributes with quality score below the threshold will be ignored (and not stored in the DB). The function will proceed as usual with all the remaining descriptors (if left).extractDescriptor (
int
) – Available values : 0, 1; whether to extract face descriptor(s)extractBasicAttributes (
int
) – Available values : 0, 1; whether to extract basic attributes (gender, age, ethnicity)aggregateAttributes (
int
) – Available values : 0, 1; whether to aggregate face descriptor(s); If true, all extracted attributes will be aggregated and stored in as a single attribute. Otherwise, all attributes will be stored for every sample.ttl (
int
|None
) – temporary attribute ttl
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with attributes info
- Return type:
class
- getHandlerById(handlerId, **kwargs)[source]
Get handler by its id
- Parameters:
handlerId (
str
) – handler id (uuid4)- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with handler info
- Return type:
class
- getHandlers(description=None, handlerType=None, page=1, pageSize=10, **kwargs)[source]
Get handlers by filters
- Parameters:
description (
str
|None
) – Find all handlers with description which “like” of this parameterhandlerType (
int
|None
) – handler type (0 - static, 1 - dynamic, 2 - lambda)page (
int
) – The number of pagepageSize (
int
) – The numbers of items on page
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with handlers info
- Return type:
class
- getHandlersCount(description=None, handlerType=None, **kwargs)[source]
Get handlers count by filters
- Parameters:
description (
str
|None
) – Find all handlers with description which “like” of this parameterhandlerType (
int
|None
) – handler type (0 - static, 1 - dynamic, 2 - lambda)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: handlers count
- Return type:
class
- getVerifier(verifierId, **kwargs)[source]
Get verifier
- Parameters:
verifierId (
str
) – verifier id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifier info
- Return type:
class
- getVerifiers(description=None, page=1, pageSize=10, **kwargs)[source]
Get verifiers by filters
- Parameters:
description (
str
|None
) – verifier description (“like” parameter)page (
int
) – The number of pagepageSize (
int
) – The numbers of items on page
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifiers info
- Return type:
class
- getVerifiersCount(description=None, **kwargs)[source]
Count verifiers that satisfy the filters
- Parameters:
description (
str
|None
) – verifier description (“like” parameter)- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: verifier count
- Return type:
class
- putVerifier(verifierId, policies=None, description=None, **kwargs)[source]
Replace verifier
- Parameters:
verifierId (
str
) – verifier idpolicies (
VerifierPolicies
|None
) – object with policies informationdescription (
str
|None
) – user description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
class
- saveEvent(handlerId, event, waitSaving=None, **kwargs)[source]
Save raw event.
- Parameters:
handlerId (
str
) – handler idevent (
RawEvent
|dict
[str
,Any
]) – raw eventwaitSaving (
int
|None
) – whether to wait for event saving
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- updateHandler(handlerId, policies=None, handlerType=None, lambdaId=None, description=None, **kwargs)[source]
Update a handler. You can not update a part of handler.
- Parameters:
handlerId (
str
) – handler idpolicies (
Policies
|None
) – object with policies informationhandlerType (
int
|None
) – handler type (0 - static, 1 - dynamic, 2 - lambda)lambdaId (
str
|None
) – lambda iddescription (
str
|None
) – user description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return nothing in text field
- Return type:
class
- upgradeObjectFromSample(data, **kwargs)[source]
Upgrade basic attributes and/or descriptor in a object using samples.
- Parameters:
data (
FaceAttributeUpgrade
|EventAttributeUpgrade
) – face or attribute upgrade object- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with attributes info
- Return type:
class
- validateHandler(policies, **kwargs)[source]
Validate handler policies.
- Parameters:
policies (
Policies
|dict
) – object with policies information- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- verifyData(verifierId, inputData, eventIds=None, externalIds=None, faceIds=None, attributeIds=None, imageType=None, useExifInfo=None, **kwargs)[source]
Perform data verification against specified objects. Only one objects set is allowed.
- Parameters:
verifierId (
str
) – verifier idinputData (
BinaryImage
|BinaryDescriptorData
|list
[BinaryImage
|BinaryDescriptorData
]) – one of: - Single image - Single descriptor - List of images and descriptorsfaceIds (
list
[str
] |None
) – faces ids to verify againsteventIds (
list
[str
] |None
) – event ids to verify againstexternalIds (
list
[str
] |None
) – external ids to verify againstattributeIds (
list
[str
] |None
) – temporary attribute ids to verify againstimageType (
int
|None
) – image type (0 - raw image, 1 - face warped image)useExifInfo (
int
|None
) – whether to use exif info for auto orientation
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifications info
- Return type:
class
- verifyRaw(candidates, references, verifierId, **kwargs)[source]
Verify raw API allows to match each candidate with each reference descriptors.
- Parameters:
verifierId (
str
) – verifier idcandidates (
list
[BinaryReference
]) – list of BinaryReference objects for candidatesreferences (
list
[BinaryReference
]) – list of BinaryReference objects for references verifierId: verifier id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching
- Return type:
class
Luna Api client
The luna-api client which implements complete REST API of luna-api service
*Available only for external lambda agent
Bases:
LunaHttpClient
Luna Api client
Get luna-api address
- Return type:
str
Bases:
BaseLunaHttpClient
,SamplesMixin
,AttributesMixin
,FacesMixin
,ListsMixin
,EventsMixin
,HandlersMixin
,MatcherMixin
,TasksMixin
,LivenessMixin
,ImagesMixin
,ObjectsMixin
,WSMixin
,AccountsMixin
,LRSMixin
,LambdasMixin
,VideoManagerMixin
,LVAMixin
Luna-api client
Property get base part of url.
>>> self.baseUri "http://127.0.0.1:5030/1"
Calculate intervals using provided data
- Parameters:
toCalculate (
IntervalCalculation
) – structure for request with cron, duration and so on- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.video_manager.http_objs import IntervalCalculation >>> response = client.calculateIntervals( ... toCalculate=IntervalCalculation( ... startTime="2025-05-01T00:00:00.000000+00:00", ... endTime="2025-05-16T00:00:00.000000+00:00", ... cron="5 4 * * 4", ... duration=11, ... durationType="minute", ... ), ... raiseError=True, ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "intervals": [ { "end_time": ..., "start_time": ... }, { "end_time": ..., "start_time": ... }, { "end_time": ..., "start_time": ... } ] }
Cancel a task by the task id. Optional you can set, that task must belong to account.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/cancelTask
- Parameters:
taskId (
int
) – task id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import EventFilters >>> >>> eventFilters = EventFilters(accountId=client.accountId) >>> taskId = client.createClusteringTask(filters=eventFilters, raiseError=True).json["task_id"] >>> response = client.cancelTask(taskId=taskId) >>> status = client.getTask(taskId).json["task_status"] >>> status in (2, 5) # task done or cancel True
Check to exist an attributes with id=attribute_id
- Parameters:
attributeId (
str
) – attribute IdaccountIdFilter (
Optional
[str
]) – account id to check attribute
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample(sampleIds=[sampleId], raiseError=True).json[0]["attribute_id"] >>> response = client.checkBasicAttributesById(attributeId=attributeId) >>> print(response.statusCode) 200
Check to exist a body sample with id=sample_id
- Parameters:
sampleId (
str
) – sample IdaccountIdFilter (
Optional
[str
]) – account id to check sample
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import BODY_WARP as image >>> >>> sampleId = client.saveBodySample(image=image, raiseError=True).json["sample_id"] >>> response = client.checkBodySample(sampleId=sampleId) >>> print(response.statusCode) 200
Check event with id=eventId existence.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/checkEvent
- Parameters:
eventId (
str
) – event idaccountIdFilter (
Optional
[str
]) – account id to check event
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.common.http_objs import Policies, DetectPolicy >>> from testData.resources import FACE_WARP >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> policies = Policies(detectPolicy=DetectPolicy(detectFace=1)) >>> handlerId = client.createHandler( ... description="test_handler_events", policies=policies, raiseError=True ... ).json["handler_id"] >>> eventId = client.emitEvents( ... handlerId=handlerId, ... inputData=[FACE_WARP], ... city="Kazan", ... street="Saban", ... houseNumber="5", ... imageType=1, ... useExifInfo=1, ... raiseError=True, ... ).json["events"][0]["event_id"] >>> response = client.checkEvent(eventId=eventId) >>> print(response.statusCode) 200
Check a face with id=face_id existence
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/checkFace
- Parameters:
faceId (
str
) – face idaccountIdFilter (
Optional
[str
]) – account id to check face
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json['face_id'] >>> response = client.checkFace(faceId=faceId) >>> print(response.statusCode) 200
Check to exist a face sample with id=sample_id
- Parameters:
sampleId (
str
) – sample IdaccountIdFilter (
Optional
[str
]) – account id to check sample
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP as image >>> >>> sampleId = client.saveFaceSample(image=image, raiseError=True).json["sample_id"] >>> response = client.checkFaceSample(sampleId=sampleId) >>> print(response.statusCode) 200
Check general event existence.
- Parameters:
eventId (
str
) – event idaccountIdFilter (
Optional
[str
]) – event account id filter
- Returns:
not contains response body.
- Return type:
LunaResponse
Check whether handler exists by its id
- Parameters:
handlerId (
str
) – handler idaccountIdFilter (
Optional
[str
]) – account id to check handler
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> handlerId = client.createHandler(handlerType=1, description="dynamic", raiseError=True).json["handler_id"] >>> response = client.checkHandlerById(handlerId=handlerId) >>> print(response.statusCode) 200
Check health of luna service
- Parameters:
includeLunaServices (
Optional
[bool
]) – whether to perform checks for dependencies of the servicelunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$asyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultraiseError (
Optional
[bool
]) – if request fails, LunaApiException is raisedtotalTimeout (
Optional
[Real
]) – request processing timeout in seconds.connectTimeout (
Optional
[Real
]) – connection timeout seconds.sockReadTimeout (
Optional
[Real
]) – socket read timeoutsockConnectTimeout (
Optional
[Real
]) – socket connect timeout
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with healthcheck result.
- Return type:
class
Estimate and check input images by ISO.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#tag/iso
- Parameters:
inputData (
Union
[BinaryImage
,List
[BinaryImage
],List
[UrlForDetection
],List
[str
]]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idsmultifacePolicy (
int
) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed 2 - get best detection from the imageextractExif (
int
) – Available values : 0, 1imageType (
Optional
[int
]) – image type (0 - raw image, 1 - face warped image)accept (
str
) – expected content type
- Returns:
body contains json with filename, exif, error and estimations for images
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import BODY_IMAGE as image >>> >>> response = client.checkISO( ... inputData=image, multifacePolicy=1, extractExif=1, accept="application/json" ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "images": [ { "error": { "desc": "Success", "detail": "Success", "error_code": 0, "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0" }, "estimations": [ { "face": { "detection": { "iso": { "checks": [ { "name": "image_format", "object_value": "JPEG", "result": 1, "threshold_value": [ "JPEG", "JPEG2000", "PNG" ] }, { "name": "illumination_quality", "object_value": ..., "result": ..., "threshold_value": { "max": 1, "min": 0.3 } }, { "name": "specularity_quality", "object_value": ..., "result": ..., "threshold_value": { "max": 1, "min": 0.3 } }, { "name": "blurriness_quality", "object_value": ..., "result": ..., "threshold_value": { "max": 1, "min": 0.61 } }, { "name": "dark_quality", "object_value": ..., "result": ..., "threshold_value": { "max": 1, "min": 0.5 } }, { "name": "light_quality", "object_value": ..., "result": ..., "threshold_value": { "max": 1, "min": 0.57 } }, { "name": "head_yaw", "object_value": ..., "result": ..., "threshold_value": { "max": 5.0, "min": -5.0 } }, { "name": "head_pitch", "object_value": ..., "result": ..., "threshold_value": { "max": 5.0, "min": -5.0 } }, { "name": "head_roll", "object_value": ..., "result": ..., "threshold_value": { "max": 8.0, "min": -8.0 } }, { "name": "gaze_yaw", "object_value": ..., "result": ..., "threshold_value": { "max": 5.0, "min": -5.0 } }, { "name": "gaze_pitch", "object_value": ..., "result": ..., "threshold_value": { "max": 5.0, "min": -5.0 } }, { "name": "mouth_smiling", "object_value": ..., "result": ..., "threshold_value": { "max": 0.5, "min": 0 } }, { "name": "mouth_occluded", "object_value": ..., "result": ..., "threshold_value": { "max": 0.5, "min": 0 } }, { "name": "mouth_open", "object_value": ..., "result": ..., "threshold_value": { "max": 0.5, "min": 0 } }, { "name": "glasses", "object_value": "no_glasses", "result": 1, "threshold_value": [ "no_glasses", "eyeglasses" ] }, { "name": "left_eye", "object_value": "open", "result": 1, "threshold_value": [ "open" ] }, { "name": "right_eye", "object_value": "open", "result": 1, "threshold_value": [ "open" ] }, { "name": "head_horizontal_center", "object_value": ..., "result": ..., "threshold_value": { "max": 0.55, "min": 0.45 } }, { "name": "head_vertical_center", "object_value": ..., "result": ..., "threshold_value": { "max": 0.5, "min": 0.3 } }, { "name": "head_width", "object_value": ..., "result": ..., "threshold_value": { "max": 0.75, "min": 0.5 } }, { "name": "head_height", "object_value": ..., "result": ..., "threshold_value": { "max": 0.9, "min": 0.6 } }, { "name": "eye_distance", "object_value": ..., "result": ..., "threshold_value": { "max": null, "min": 90.0 } }, { "name": "eyebrows_state", "object_value": ..., "result": ..., "threshold_value": [ "neutral" ] }, { "name": "shoulders_position", "object_value": "parallel", "result": 1, "threshold_value": [ "parallel" ] }, { "name": "smile_properties", "object_value": ..., "result": ..., "threshold_value": [ "none" ] }, { "name": "headwear_type", "object_value": "none", "result": 1, "threshold_value": [ "none" ] }, { "name": "natural_light", "object_value": ..., "result": ..., "threshold_value": 1 }, { "name": "radial_distortion", "object_value": ..., "result": ..., "threshold_value": 0 }, { "name": "red_eyes", "object_value": 0, "result": 1, "threshold_value": 0 }, { "name": "face_color_type", "object_value": "color", "result": 1, "threshold_value": [ "grayscale", "color" ] }, { "name": "background_uniformity", "object_value": ..., "result": ..., "threshold_value": { "max": 1, "min": 0.5 } }, { "name": "background_lightness", "object_value": ..., "result": ..., "threshold_value": { "max": 1, "min": 0.2 } } ], "status": 0 }, "rect": { "height": ..., "width": ..., "x": ..., "y": ... } } } } ], "exif": {}, "filename": "raw image", "status": 1 } ] }
Check to exist an image with id=image_id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/checkImage
- Parameters:
imageId (
str
) – image idaccountIdFilter (
Optional
[str
]) – account id to check imagewithMeta (
bool
) – whether to retrieve user-defined image metadata
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP as image >>> >>> imageId = client.saveImage(image=image, raiseError=True).json["image_id"] >>> response = client.checkImage(imageId=imageId) >>> print(response.statusCode) 200
Check lambda existence by id.
- Parameters:
lambdaId (
str
) – lambda idaccountIdFilter (
Optional
[str
]) – account id filter for check lambda
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> response = client.checkLambda(lambdaId=lambdaId) >>> print(response.statusCode) 200
Check list existence
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/checkList
- Parameters:
listId (
str
) – list idaccountIdFilter (
Optional
[str
]) – account id to check face
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> response = client.checkList(listId=listId) >>> print(response.statusCode) 200
Check to exist an object with id=object_id
- Parameters:
objectId (
str
) – object idaccountIdFilter (
Optional
[str
]) – account id to check object
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> objectBody = "1,2,3" >>> contentType = "text/plain" >>> objectId = client.saveObject(objectBody=objectBody, contentType=contentType, raiseError=True).json[ ... "object_id" ... ] >>> response = client.checkObject(objectId=objectId) >>> print(response.statusCode) 200
Check stream by id.
- Parameters:
streamId (
str
) – stream idaccountId (
Optional
[str
]) – account idtargets (
Optional
[str
]) – targets to get streams
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with stream will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> response = client.checkStream(streamId=streamId) >>> print(response.statusCode) 200
Check verifier existence
- Parameters:
verifierId (
str
) – verifier idaccountIdFilter (
Optional
[str
]) – account id to check verifier
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> verifierId = client.createVerifier( ... description="Happy_persons", policies=policies, raiseError=True ... ).json["verifier_id"] >>> response = client.checkVerifier(verifierId=verifierId) >>> print(response.statusCode) 200
Close current client.
- Return type:
None
Getting count of faces which satisfy filters
- Parameters:
timeLt (
Optional
[str
]) – Upper bound for object create_timetimeGte (
Optional
[str
]) – Lower bound for object create_timefaceIds (
Optional
[List
[str
]]) – list of coma separated faces idsexternalIds (
Optional
[List
[str
]]) – external id of the face, if it has its own mapping in the systemfaceIdGte (
Optional
[str
]) – lower face id including boundaryfaceIdLt (
Optional
[str
]) – upper face id excluding boundaryuserData (
Optional
[str
]) – Find all objects with user_data which “like” of this parameterlistId (
Optional
[str
]) – id of list that contains faceseventId (
Optional
[str
]) – event idaccountIdFilter (
Optional
[str
]) – account id to count faces
- Returns:
body contains json with number.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> response = client.countFaces(timeGte="2018-08-10", userData="fox1991") >>> print(response.statusCode) 200 >>> print(response.json) {'faces_count': ...}
Get count of groups by filter.
- Parameters:
accountId (
Optional
[str
]) – account idgroupNames (
Optional
[List
[str
]]) – group namesgroupIds (
Optional
[List
[str
]]) – group ids
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with count of groups will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> groupIds = [] >>> for _ in range(3): ... groupId = client.createGroup( ... groupName=str(uuid4()), ... description="test group description", ... raiseError=True, ... ).json["group_id"] ... groupIds.append(groupId) >>> response = client.countGroups(groupIds=groupIds) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "groups_count": 3 }
Get stream by filters.
- Parameters:
accountId (
Optional
[str
]) – account idstreamIds (
Optional
[List
[str
]]) – stream idsstreamNames (
Optional
[List
[str
]]) – stream namesreference (
Optional
[str
]) – stream referencestatuses (
Optional
[List
[int
]]) – stream current status valuescreateTimeGte (
Optional
[str
]) – stream create time lower including boundcreateTimeLt (
Optional
[str
]) – stream create time upper excluding boundsources (
Optional
[List
[str
]]) – additional stream informationsplittable (
Optional
[int
]) – whether stream is splittable
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with streams will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamIds = [] >>> for _ in range(3): ... streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name=str(uuid4()), ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] ... streamIds.append(streamId) >>> response = client.countStreams( ... streamIds=streamIds, ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "streams_count": 3 }
Create new account
- Parameters:
login (
str
) – account loginpassword (
str
) – account passwordaccountType (
Literal
['advanced_user'
,'user'
]) – account typedescription (
Optional
[str
]) – account descriptionaccountId (
Optional
[str
]) – account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created account id will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from uuid import uuid4 >>> >>> response = client.createAccount( ... accountId=str(uuid4()), login=f"{uuid4()}@visionlabs.ru", password="pwd", accountType="user" ... ) >>> print(response.statusCode) 201 >>> print(response.json) {'account_id': ..., 'url': ...}
Create new agent.
- Parameters:
agent (
Agent
) – agent structure- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created group name and id will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME, ANALYTIC_NAME >>> from luna3.video_manager.http_objs import Agent >>> agent = Agent( ... name="doctest_crate_agent", ... maxStreamCount=2, ... port=123, ... apiVersion=1, ... analyticNames=[ANALYTIC_NAME], ... description="Test agent" ... ) >>> response = client.createAgent( ... agent=agent ... ) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "agent_id": ..., "alive_period": ..., "refresh_period": ... }
Create new analytic.
- Parameters:
accountId – account id
analytic (
Analytic
) – analytic structure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created group name and id will be returned.
- Return type:
class
>>> import json >>> from time import sleep >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from uuid import uuid4 >>> response = client.createAnalytic( ... analytic=Analytic(analyticName=str(uuid4())), raiseError=True ... ) >>> >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "analytic_id": ... }
Create new attributes. Notice that XPK argument overwrites basic attributes and descriptors above.
- Parameters:
descriptors (
Optional
[list
[Union
[bytes
,RawDescriptor
]]]) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
Optional
[dict
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.xpk (
bytes
) – SDKObject bytes to load attributes fromttl (
Optional
[int
]) – temporary attribute ttl
- Returns:
body contains json with sample_id and url.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP, DESCRIPTOR >>> >>> sampleId = client.detectFaces( ... inputData=FACE_WARP, raiseError=True ... ).json["images"][0]["detections"]["samples"][0]["face"]["sample_id"] >>> basicAttributes = {'ethnicity': 3, 'age': 26, 'gender': 0} >>> response = client.createAttribute( ... basicAttributes = basicAttributes, basicAttributesSamples=[sampleId], descriptorSamples=[sampleId], ... descriptors=[DESCRIPTOR], ... ) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"attribute_id": ..., "url": ...}
Create and start clustering task
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/createClusteringTask # pylint: disable=line-too-long
- Parameters:
descriptorTypeFilter (
Optional
[str
]) – descriptor type filter, one of: face or bodythreshold (
Optional
[float
]) – thresholdfilters (
Union
[FaceFilters
,EventFilters
]) – Either FaceFilters or EventFiltersuseTrackInfo (
Optional
[int
]) – whether to use track info during the taskdescription (
Optional
[str
]) – descriptionlimit (
Optional
[int
]) – candidate limit for each clutsernotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> from testData.resources import FACE_WARP >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample( ... sampleIds=[sampleId], extractBasicAttributes=1, raiseError=True ... ).json[0]["attribute_id"] >>> faceId = client.createFace(attributeId=attributeId, raiseError=True).json["face_id"] >>> faceFilters = FaceFilters(faceIds=[faceId]) >>> response = client.createClusteringTask(filters=faceFilters, descriptorTypeFilter="face") >>> print(response.statusCode) 202 >>> print(response.json) {'task_id': ...}
Create and start clustering task
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/createCrossMatchTask # pylint: disable=line-too-long
- Parameters:
threshold (
Optional
[float
]) – thresholdlimit (
Optional
[int
]) – maximum candidates count per referencereferenceFilters (
Union
[FaceFilters
,EventFilters
]) – filters for getting references from either faces or eventscandidateFilters (
Union
[FaceFilters
,EventFilters
]) – filters for getting candidates from either faces or eventsdescriptorTypeFilter (
Optional
[str
]) – descriptor type filter, one of: face or bodydescription (
Optional
[str
]) – descriptionaccountIdFilter (
Optional
[str
]) – account id filternotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters, EventFilters >>> from luna3.common.http_objs import Policies, DetectPolicy, ExtractPolicy >>> from testData.resources import FACE_WARP as image >>> >>> sampleId = client.saveFaceSample(image=image, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample( ... sampleIds=[sampleId], extractBasicAttributes=1, raiseError=True ... ).json[0]["attribute_id"] >>> faceId = client.createFace(attributeId=attributeId, raiseError=True).json["face_id"] >>> faceFilters = FaceFilters(faceIds=[faceId]) >>> policies = Policies(detectPolicy=DetectPolicy(detectFace=1), extractPolicy=ExtractPolicy()) >>> handlerId = client.createHandler( ... description="test_handler_tasks", policies=policies, raiseError=True ... ).json["handler_id"] >>> eventId = client.emitEvents(handlerId, inputData=image, raiseError=True).json["events"][0]["event_id"] >>> eventFilters = EventFilters(eventIds=[eventId]) >>> response = client.createCrossMatchTask( ... referenceFilters=faceFilters, ... candidateFilters=eventFilters, ... descriptorTypeFilter="face", ... threshold=0.5, ... limit=1, ... description="matching_visitors" ... ) >>> print(response.statusCode) 202 >>> print(response.json) {'task_id': ...}
Create and start estimator task
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/createEstimatorTask # pylint: disable=line-too-long
- Parameters:
source (
Union
[EstimatorZipSource
,EstimatorS3Source
,EstimatorNetworkDiskSource
,EstimatorFTPSource
,EstimatorSambaSource
]) – estimator task sourcedescription (
Optional
[str
]) – task descriptionhandler (
Union
[EstimatorHandler
,EstimatorHandlerExtant
,str
]) – handler for image processing, handler id or description + policiesnotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import Policies, DetectPolicy, ExtractPolicy, StoragePolicy, EventPolicy >>> from luna3.common.http_objs import NotificationPolicy, FacePolicy, LinkToListPolicy, EstimatorHandler >>> from luna3.tasks.http_objs import EstimatorZipSource >>> >>> listId = client.createList(raiseError=True).json["list_id"] >>> policies = Policies( ... detectPolicy=DetectPolicy(estimateEmotions=1, estimateMask=1), ... extractPolicy=ExtractPolicy(extractBasicAttributes=1, extractFaceDescriptor=1, fdScoreThreshold=0.0), ... storagePolicy=StoragePolicy( ... eventPolicy=EventPolicy(storeEvent=0), ... notificationPolicy=NotificationPolicy(sendNotification=0), ... facePolicy=FacePolicy(storeFace=1, linkToListsPolicy=[LinkToListPolicy(listId=listId)]), ... ), ... ) >>> response = client.createEstimatorTask( ... handler=EstimatorHandler(policies, "luna3_estimator_task_example"), ... source=EstimatorZipSource(url="http://127.0.0.1:5000/archive") ... ) >>> print(response.statusCode) 202 >>> print(response.json) {'task_id': ...}
Create and start exporter task.
- Parameters:
filters (
Union
[FaceFilters
,EventFilters
]) – face/event filterscolumns (
Optional
[List
[str
]]) –columns in csv report. For faces [“face_id”, “user_data”, “create_time”, “lists”, “external_id”, “attribute_id”,
”avatar”, “event_id”]
- For Events: [“event_id”, “create_time”, “end_time” “external_id”, “handler_id”, “attribute_id”,
”source”, “stream_id”, “top_match”, “match_result”, “extract_result”, “face_id”, “attach_result”, “gender”, “age”, “emotion”, “mask”, “ethnic_group”, “tags”, “user_data”]
csvDelimiter (
str
) – csv delimitersaveImages (
Optional
[int
]) – whether to save images in a reportdescription (
Optional
[str
]) – descriptiondescriptorTypeFilter (
Optional
[str
]) – descriptor type filter, one of: face or bodynotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> response = client.createExporterTask( ... description="report_task_one", ... csvDelimiter="$", ... filters=FaceFilters(accountId=client.accountId), ... columns=["face_id", "user_data", "create_time", "external_id", "lists", "avatar", "event_id"] ... ) >>> print(response.statusCode) 202 >>> print(response.json) {'task_id': ...}
Create new face tests!
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/createFace
- Parameters:
externalId (
Optional
[str
]) – user-defined external id for faceattributeId (
Optional
[str
]) – an attribute id associated with the facedescriptors (
Optional
[List
[Union
[bytes
,RawDescriptor
]]]) – list of descriptors different versionsdescriptorSamples (
List
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
Optional
[dict
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
List
[str
]) – list of warp image id from which the basic attribute was extracted.userData (
Optional
[str
]) – user dataavatar (
Optional
[str
]) – avatar for face, references to a sample or a user-defined referencelists (
Optional
[List
[str
]]) – luna lists for linking face with themeventId (
Optional
[str
]) – event id associated with creating the facecontentType (
str
) – content type to use (supported now: “application/json” (default), “application/msgpack”)
- Returns:
body contains json with info about created face.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> response = client.createFace( ... externalId="2xQ2gprbMePw1s9gw9fvA==", ... userData="test_data05", ... avatar="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Abbey_Lee.jpg/400px-Abbey_Lee.jpg", ... raiseError=True, ... ) >>> print(response.statusCode) 201 >>> print(response.json) {'face_id': ..., 'url': ...}
Create and start gc task
- Parameters:
target (
str
) – garbage collection target: “events” to delete events, “general_events” to delete general eventshandlerId (
Optional
[str
]) – handler iduserData (
Optional
[str
]) – user data for faces filteringlistId (
Optional
[str
]) – list id for faces filteringgeneralEventType (
Optional
[List
[str
]]) – general event typeeventCreateTimeLt (
Optional
[str
]) – general event create time upper excluding boundcreateTimeLt (
Optional
[str
]) – event create time upper excluding boundcreateTimeGte (
Optional
[str
]) – face create time bottom excluding boundinsertTimeLt (
Optional
[str
]) – event insert time upper excluding boundstoreResults (
Optional
[bool
]) – whether to store task resultsremoveSamples (
Optional
[bool
]) – whether to remove samples along with the event or faceremoveImageOrigins (
Optional
[bool
]) – whether to remove image origins along with the eventdescription (
Optional
[str
]) – task descriptionnotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> from luna3.common.http_objs import DetectPolicy, Policies, ExtractPolicy >>> from testData.resources import FACE_WARP as image >>> >>> sampleId = client.saveFaceSample(image=image, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample( ... sampleIds=[sampleId], extractBasicAttributes=1, raiseError=True ... ).json[0]["attribute_id"] >>> faceId = client.createFace(attributeId=attributeId, raiseError=True).json["face_id"] >>> faceFilters = FaceFilters(faceIds=[faceId]) >>> policies = Policies(detectPolicy=DetectPolicy(detectFace=1), extractPolicy=ExtractPolicy()) >>> handlerId = client.createHandler( ... description="create_Gc_task", policies=policies, raiseError=True ... ).json["handler_id"] >>> event = client.emitEvents(handlerId, inputData=image, raiseError=True) >>> response = client.createGcTask( ... target="events", ... handlerId=handlerId, ... storeResults=True, ... removeSamples=True, ... removeImageOrigins=True, ... description="my_GcTask" ... ) >>> print(response.statusCode) 202 >>> print(response.json) {'task_id': ...}
Create new stream group.
- Parameters:
groupName (
str
) – group namedescription (
Optional
[str
]) – group description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created group name and id will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> response = client.createGroup( ... groupName="test_group", ... description="test group description", ... raiseError=True, ... ) >>> print(response.statusCode) 201 >>> groupId = response.json["group_id"] >>> response = client.getGroup(groupId=groupId, raiseError=True) >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "description": "test group description", "group_id": ..., "group_name": "test_group" }
Create new handler. Handler determinate a list of rules for proccessing input images. You can set parameters for detecting faces, extracting attributes. You can set rules for matching attributes and creating faces from them.
- Parameters:
policies (
Optional
[Policies
]) – object with policies informationhandlerType (
Optional
[int
]) – handler type (0 - static, 1 - dynamic, 2 - lambda)description (
Optional
[str
]) – user description
- Returns:
body contains json with new handler id and url.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import DetectPolicy, ExtractPolicy, StoragePolicy, LinkToListPolicy >>> from luna3.common.http_objs import MatchPolicy, Filters, Policies, FacePolicy >>> from luna3.common.http_objs import MatchPolicyCandidates, ConditionalTagPolicy >>> >>> response = client.createHandler(handlerType=1, description="dynamic") >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"external_url": "http://127.0.0.1:5000/6/handlers/...", "handler_id": ..., "url": ...} >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> policies = Policies( ... detectPolicy=DetectPolicy( ... estimateHeadPose=1, ... estimateEmotions=1, ... estimateGaze=1, ... extractExif=1, ... estimateLiveness=DetectPolicy.LivenessEstimationPolicy(1, 0.5, 0.5), ... estimateDeepfake=DetectPolicy.DeepfakeEstimationPolicy(1, 0.5, 2), ... rollThreshold=20, ... ), ... extractPolicy=ExtractPolicy(extractBasicAttributes=1, extractFaceDescriptor=1, fdScoreThreshold=0.7772), ... matchPolicy=[ ... MatchPolicy( ... candidates=MatchPolicyCandidates(origin="faces", listId=listId), ... label="test_faces", ... gender=1, ... ethnicities=[1, 2], ... limit=3, ... ) ... ], ... storagePolicy=StoragePolicy( ... facePolicy=FacePolicy( ... storeFace=1, ... filters=Filters(ageGte=18, ageLt=40), ... setSampleAsAvatar=1, ... linkToListsPolicy=[LinkToListPolicy(listId=listId)], ... ) ... ), ... conditionalTagsPolicy=[ConditionalTagPolicy(tag="test_tag")] ... ) >>> response = client.createHandler(description="persons", policies=policies) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"external_url": "http://127.0.0.1:5000/6/handlers/...", "handler_id": ..., "url": ...}
Create lambda
- Parameters:
archive (
bytes
) – archive file byteslambdaName (
str
) – name of lambdadescription (
Optional
[str
]) – lambda descriptionlambdaType (
Optional
[Literal
['standalone'
,'handlers'
,'tasks'
,'agent'
]]) – lambda typeimageBuilder (
Optional
[Literal
['kaniko'
,'buildah'
]]) – image builder typeadditionalUserDockerCommands (
Optional
[List
[str
]]) – additional user docker commandsbaseImageName (
Optional
[str
]) – base lambda image namebaseImageTag (
Optional
[str
]) – base lambda image tag (for custom image)archiveTtl (
Optional
[Literal
[-1
,1
,2
,3
,4
,5
,6
,7
,14
,30
,60
,90
,180
,365
]]) – ttl for lambda archiveworkers (
Optional
[int
]) – count of lambda workersenableGPU (
Optional
[bool
]) – whether to enable GPUpodCount (
Optional
[int
]) – count of lambda podscpuLimit (
Optional
[int
]) – cpu limit for lambda in cpu unitsramLimit (
Optional
[int
]) – ram limit for lambda in GBcpuRequest (
Optional
[int
]) – cpu request for lambda in cpu unitsramRequest (
Optional
[int
]) – ram request for lambda in GBnamespace (
Optional
[str
]) – k8s namespaceselector (
Optional
[dict
]) – kubernetes pod node selectorimageName (
Optional
[str
]) – lambda imageimageTag (
Optional
[str
]) – lambda image tagagentParameters (
Optional
[AgentParameters
]) – lambda agent parameters
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> response = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())) >>> print(response.statusCode) 202 >>> print(json.dumps(response.json, sort_keys=True)) {"lambda_id": ...} >>> _ = client.deleteLambda(lambdaId=response.json["lambda_id"])
Create and start lambda task
- Parameters:
content (
dict
) – task contentdescription (
Optional
[str
]) – task descriptionnotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
Create and start linker task
- Parameters:
filters (
Union
[FaceFilters
,EventFilters
]) – required one of: face or event filterslistId (
Optional
[str
]) – list id to link faces to | WARNING required one of: listId or createList(1)createList (
Optional
[int
]) – if 1 create list to link faces to or 0 to link them to list with id equals listId | WARNING required one of: listId or createList(1)listUserData (
Optional
[str
]) – user data of list to be created when ‘createList’ is set to 1description (
Optional
[str
]) – descriptionnotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> faceId = client.createFace(userData="link_faces", raiseError=True).json["face_id"] >>> faceFilters = FaceFilters(faceIds=[faceId], userData="link_faces") >>> response = client.createLinkerTask( ... listId=listId, ... filters=faceFilters, ... listUserData="my_awesome_list", ... description="my_LinkerTask" ... ) >>> print(response.statusCode) 202 >>> print(response.json) {'task_id': ...}
Create new list
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/createList
- Parameters:
userData (
Optional
[str
]) – user data associated with the list (<= 128 characters)- Returns:
body contains json with information about created list.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> response = client.createList("strange_persons") >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"external_url": "http://127.0.0.1:5000/6/lists/...", "list_id":..., "url":...}
Create and start ROC task
- Parameters:
markup (
List
[dict
]) – markup list of dicts with face id and label (group id)accountIdFilter (
Optional
[str
]) – account id filterthresholdHitTop (
Optional
[float
]) – similarity threshold to calculate hit into the top-Nlimit (
Optional
[int
]) – maximum candidates count per referencekeyFPRs (
Optional
[List
[float
]]) – roc-curve key FRP value listdescription (
Optional
[str
]) – descriptionnotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample( ... sampleIds=[sampleId], extractBasicAttributes=1, raiseError=True ... ).json[0]["attribute_id"] >>> faceId = client.createFace(attributeId=attributeId).json["face_id"] >>> faceId_2 = client.createFace(attributeId=attributeId).json["face_id"] >>> response = client.createROCTask( ... markup=[{"face_id": faceId, "label": 0}, {"face_id": faceId_2, "label": 1}], ... description="matching_people", ... thresholdHitTop=0.95, ... limit=2, ... keyFPRs=[0.000001, 0.001] ... ) >>> print(response.statusCode) 202 >>> print(response.json) {'task_id': ...}
Create and start clustering task
- Parameters:
taskId (
int
) – source task idcolumns (
Optional
[List
[str
]]) –columns in csv report. For faces [“user_data”, “create_time”, “lists”, “external_id”, “attribute_id”,
”avatar”, “event_id”]
- For Events: [“create_time”, “external_id”, “handler_id”, “attribute_id”, “source”, “stream_id,
”top_match”, “end_time”, “match_result”, “extract_result”, “face_id”, “attach_result”, “gender”, “age”, “emotion”, “mask”, “ethnic_group”, “tags”, “user_data”]
csvDelimiter (
str
) – csv delimitersaveImages (
Optional
[int
]) – whether to save images in a reportdescription (
Optional
[str
]) – descriptionnotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
body contains json with task id.
- Return type:
LunaResponse
>>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> faceFilters = FaceFilters(accountId=client.accountId, userData="task_clustering_faces") >>> taskId = client.createClusteringTask( ... filters=faceFilters, descriptorTypeFilter="face", raiseError=True ... ).json["task_id"] >>> time.sleep(1) >>> response = client.createReportTask( ... taskId=taskId, ... columns=["user_data", "create_time"], ... description="report_task", ... csvDelimiter="$" ... ) >>> print(response.statusCode) 202 >>> print(response.json) {'task_id': ...}
Create schedule
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/createSchedule # pylint: disable=line-too-long
- Parameters:
taskType (
Literal
[1
,2
,3
,4
,6
,7
,8
,9
,10
]) – type of taskcontentKwargs (
dict
) – kwargs for create contentcron (
str
) – cron stringcronTz (
Optional
[str
]) – cron timezonestartImmediately (
Optional
[bool
]) – start task immediatelycreateStopped (
Optional
[bool
]) – create task stopped schedule tasktaskNotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policyresultStoragePolicy (
Optional
[ResultStoragePolicy
]) – task result storage policy
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with schedule id.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> response = client.createSchedule( ... accountId=client.accountId, ... taskType=1, ... contentKwargs=dict( ... filters=FaceFilters(accountId=client.accountId), createList=1 ... ), ... cron="5 4 * * *", ... cronTz="utc", ... startImmediately=False, ... ) >>> print(response.statusCode) 201 >>> print(response.json) {'schedule_id': ...}
Create schedule template
- Parameters:
scheduleTemplate (
ScheduleTemplate
) – schedule template object- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.video_manager.http_objs import ScheduleTemplate >>> response = client.createScheduleTemplate( ... scheduleTemplate=ScheduleTemplate( ... startTime="2025-05-01T00:00:00.000000+00:00", ... endTime="2025-05-16T00:00:00.000000+00:00", ... cron="5 4 * * 4", ... duration=11, ... durationType="minute", ... ), ... raiseError=True, ... ) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "intervals": [ { "end_time": ..., "start_time": ... }, { "end_time": ..., "start_time": ... }, { "end_time": ..., "start_time": ... } ], "schedule_id": ... }
Create new stream in luna-streams :type analytics:
List
[StreamAnalytic
] :param analytics: stream analytics :type name:Optional
[str
] :param name: stream name :type description:Optional
[str
] :param description: stream description :type streamType:Literal
['stream'
,'videofile'
] :param streamType: stream type :type downloadable:bool
:param downloadable: whether reference is downloadable :type timestampSource:Literal
['pts'
,'server'
,'frame_rate'
,'auto'
] :param timestampSource: timestamp source where pts - video labels, server - server time, frame_rate - video fileauto logic described in openapi
- Parameters:
reference (
str
) – stream URLorientationStrategy (
Literal
['static'
,'video_info'
]) – orientation strategyrotation (
Optional
[Literal
[0
,90
,180
,270
]]) – angle of camera frame rotation (0, 90, 180 or 270)pts (
Optional
[VideoPTS
]) – video pts settingsfps (
Optional
[Real
]) – video decoder fpslocation (
Optional
[Location
]) – location that stream belongssource (
Optional
[str
]) – additional stream informationrestart (
Optional
[Restart
]) – auto-restart configurationgroupName (
Optional
[str
]) – group namegroupId (
Optional
[str
]) – group identifiertimeout (
Optional
[int
]) – stream/videofile read timeoutnotificationPolicy (
Optional
[StreamNotificationPolicy
]) – stream notification policysplittable (
Optional
[int
]) – whether stream is splittableffmpegKwargs (
Optional
[dict
]) – additional ffmpeg kwargsbehaviorParameters (
Optional
[BehaviorParameters
]) – behavior parameters for stream
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created stream id & version will be returned
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> response = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ) >>> print(response.statusCode) 201 >>> streamId = response.json["stream_id"] >>> response = client.getStream(streamId=streamId, raiseError=True) >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "analytics": [ { "analytic_name": "doctests_analytic", "autorestart": { "attempt_count": 10, "current_attempt": 0, "delay": 60, "last_attempt_time": null, "restart": 0, "status": "disabled" }, "parameters": {}, "status": ... } ], "create_time": ..., "data": { "behavior_parameters": ..., "downloadable": false, "ffmpeg_kwargs": ..., "fps": ..., "orientation_strategy": "static", "pts": { "start_time": 0.0 }, "reference": "http://reference", "rotation": 0, "timeout": ..., "timestamp_source": "auto", "type": "videofile" }, "description": "test stream description", "groups": [], "last_error": null, "location": { "area": null, "city": null, "district": null, "geo_position": null, "house_number": null, "street": null }, "name": "test_stream", "notification_policy": { "enable": 0, "stream_callbacks": [] }, "source": null, "splittable": 0, "status": 0, "stream_id": ..., "version": 1 }
Create new token.
- Parameters:
grantAllPermissions (
int
) – grant all permissions to tokentokenPermissions (
Optional
[TokenPermissions
]) – token permissionsexpirationTime (
Optional
[str
]) – token expiration timevisibilityArea (
Optional
[Literal
['all'
,'account'
]]) – token visibility areadescription (
Optional
[str
]) – account description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created token id and token will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.accounts.http_objs import TokenPermissions >>> from uuid import uuid4 >>> >>> response = client.createToken(tokenPermissions=TokenPermissions()) >>> print(response.statusCode) 201 >>> print(response.json) {'token_id': ..., 'token': ..., 'url': ...}
Create new verifier. Verifier determinate a list of rules for processing & verification of input images. You can set parameters for detecting faces, extracting attributes. You can set rules for matching attributes and creating faces from them.
- Parameters:
policies (
Optional
[VerifierPolicies
]) – object with policies informationdescription (
Optional
[str
]) – user description
- Returns:
body contains json with new verifier id and url
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> response = client.createVerifier(description="Happy_persons", policies=policies) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"external_url": "http://127.0.0.1:5000/6/verifiers/...", "url": ..., "verifier_id": ...}
Delete agent.
- Parameters:
agentId (
str
) – agent idaccountId (
Optional
[str
]) – account_id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME, ACCOUNT_ID, ANALYTIC_NAME >>> from luna3.video_manager.http_objs import Agent >>> agent = Agent( ... name="doctest_delete_agent", ... maxStreamCount=2, ... port=123, ... apiVersion=1, ... analyticNames=[ANALYTIC_NAME], ... description="Test agent" ... ) >>> agentId = client.createAgent(agent=agent).json["agent_id"] >>> >>> response = client.deleteAgent(agentId=agentId, accountId=ACCOUNT_ID) >>> print(response.statusCode) 204
Delete analytics.
- Parameters:
analyticIds (
list
[str
]) – analytic idsaccountId (
Optional
[str
]) – account_id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> from time import sleep >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ACCOUNT_ID >>> from uuid import uuid4 >>> analyticId = client.createAnalytic( ... analytic=Analytic(analyticName=str(uuid4())), raiseError=True ... ).json["analytic_id"] >>> >>> response = client.deleteAnalytics( ... analyticIds=[analyticId], accountId=ACCOUNT_ID ... ) >>> >>> print(response.statusCode) 204
Delete attributes by id. Associated face (if it exists) also will be deleted.
- Parameters:
attributeId (
str
) – attribute Id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample(sampleIds=[sampleId], raiseError=True).json[0]["attribute_id"] >>> response = client.deleteAttributeById(attributeId=attributeId) >>> print(response.statusCode) 204
Delete body sample with id=sample_id
- Parameters:
sampleId (
str
) – sample Id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import BODY_WARP as image >>> >>> sampleId = client.saveBodySample(image=image, raiseError=True).json["sample_id"] >>> response = client.deleteBodySample(sampleId=sampleId) >>> print(response.statusCode) 204
Delete event by event_id and optional account_id.
- Parameters:
eventId (
str
) – event idaccountId (str | None) – optional account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
Delete face by id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/deleteFace
- Parameters:
faceId (
str
) – face id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json['face_id'] >>> response = client.deleteFace(faceId=faceId) >>> print(response.statusCode) 204
Delete face attributes.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/deleteFaceAttributes # pylint: disable=line-too-long
- Parameters:
faceId (
str
) – face id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json['face_id'] >>> response = client.deleteFaceAttributes(faceId=faceId) >>> print(response.statusCode) 204
Delete face sample with id=sample_id
- Parameters:
sampleId (
str
) – sample Id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP as image >>> >>> sampleId = client.saveFaceSample(image=image, raiseError=True).json["sample_id"] >>> response = client.deleteFaceSample(sampleId=sampleId) >>> print(response.statusCode) 204
Delete faces. Optional you can set, that faces must belong to account.
- Parameters:
faceIds (
List
[str
]) – face id listignore (
Optional
[int
]) – ignore non-existing faces
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json['face_id'] >>> response = client.deleteFaces(faceIds=[faceId]) >>> print(response.statusCode) 204
Delete general event by event_id and optional account_id.
- Parameters:
eventId (
str
) – event idaccountId (str | None) – optional account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
Delete group.
- Parameters:
groupId (
str
) – group idwithStreams (
Optional
[bool
]) – whether to delete the group will all its streamsaccountId (
Optional
[str
]) – account_id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> groupId = client.createGroup( ... groupName="delete_group", ... description="test group description", ... raiseError=True, ... ).json["group_id"] >>> response = client.deleteGroup(groupId=groupId, withStreams=True) >>> print(response.statusCode) 204 >>> response = client.getGroup(groupId=groupId) >>> print(response.statusCode) 404
Remove all streams of a group.
- Parameters:
groupId (
str
) – group idaccountId (
Optional
[str
]) – account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> groupId = client.createGroup( ... groupName="delete_group", ... description="test group description", ... raiseError=True, ... ).json["group_id"] >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... groupId=groupId, ... raiseError=True, ... ).json["stream_id"] >>> response = client.deleteGroupStreams(groupId=groupId) >>> print(response.statusCode) 204 >>> response = client.getStream(streamId=streamId) >>> print(response.statusCode) 404
Remove handler by id :rtype:
Union
[Awaitable
[LunaResponse
],LunaResponse
]- Args:
handlerId: handler id
- Returns:
LunaResponse: not contains response body.
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> handlerId = client.createHandler(handlerType=1, description="dynamic", raiseError=True).json["handler_id"] >>> response = client.deleteHandlerById(handlerId=handlerId) >>> print(response.statusCode) 204
Delete image with id=image_id
- Parameters:
imageId (
str
) – image id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP as image >>> >>> imageId = client.saveImage(image=image, raiseError=True).json["image_id"] >>> response = client.deleteImage(imageId=imageId) >>> print(response.statusCode) 204
Delete lambda by id.
- Parameters:
lambdaId (
str
) – lambda idaccountIdFilter (
Optional
[str
]) – account id filter for delete lambda
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> response = client.deleteLambda(lambdaId=lambdaId) >>> print(response.statusCode) 204
Remove list by id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/deleteList
- Parameters:
listId (
str
) – list idwithFaces (
int
) – remove lists and all the faces contained in the lists
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> response = client.deleteList(listId=listId) >>> print(response.statusCode) 204 >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> response = client.deleteList(listId=listId, withFaces = 1) >>> print(response.statusCode) 202
Delete lists. Optional you can set, that lists must belong to account.
- Parameters:
listIds (
List
[str
]) – list idswithFaces (
int
) – remove lists and all the faces contained in the lists
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> response = client.deleteLists(listIds=[listId]) >>> print(response.statusCode) 204 >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> response = client.deleteLists(listIds=[listId], withFaces = 1) >>> print(response.statusCode) 202
Delete object with id=object_id
- Parameters:
objectId (
str
) – object id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> objectBody = "1,2,3" >>> contentType = "text/plain" >>> objectId = client.saveObject( ... objectBody=objectBody, contentType=contentType, raiseError=True ... ).json["object_id"] >>> response = client.deleteObject(objectId=objectId) >>> print(response.statusCode) 204
Delete schedule by id
- Parameters:
scheduleId (
int
) – schedule idaccountIdFilter (
Optional
[str
]) – account id to delete schedules
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with response.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> contentKwargs=dict( ... filters=FaceFilters(accountId=client.accountId), createList=1 ... ) >>> response = client.createSchedule( ... accountId=client.accountId, ... taskType=1, ... contentKwargs=contentKwargs, ... cron="5 4 * * *", ... cronTz="utc", ... startImmediately=False, ... raiseError=True ... ) >>> scheduleId = response.json["schedule_id"] >>> response = client.deleteSchedule( ... scheduleId=scheduleId ... ) >>> print(response.statusCode) 204
Create schedule template
- Parameters:
accountId (
Optional
[str
]) – account idscheduleId (
str
) – schedule id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.video_manager.http_objs import ScheduleTemplate >>> scheduleId = client.createScheduleTemplate( ... scheduleTemplate=ScheduleTemplate( ... startTime="2025-05-01T00:00:00.000000+00:00", ... endTime="2025-05-16T00:00:00.000000+00:00", ... cron="5 4 * * 4", ... duration=11, ... durationType="minute", ... ), ... raiseError=True, ... ).json["schedule_id"] >>> response = client.deleteScheduleTemplate(scheduleId=scheduleId) >>> print(response.statusCode) 204
Delete stream by id.
- Parameters:
streamId (
str
) – stream idaccountId (
Optional
[str
]) – account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> response = client.deleteStream(streamId=streamId) >>> print(response.statusCode) 204 >>> response = client.checkStream(streamId=streamId) >>> print(response.statusCode) 404
Delete stream analytics working intervals
- Parameters:
accountId (
Optional
[str
]) – account idstreamId (
str
) – stream idanalyticIdx (
int
) – index of analytics of interestintervalsIdx (
int
) – index of intervals of interest
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic, Schedule, Interval >>> streamId = client.createStream( ... streamType="stream", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic( ... name=ANALYTIC_NAME, ... schedules=[Schedule(intervals=[ ... Interval(startTime="2025-05-01T01:16:00Z", endTime="2026-05-01T01:16:00Z")]) ... ])], ... raiseError=True, ... ).json["stream_id"] >>> response = client.deleteStreamAnalyticsWorkingIntervals( ... streamId=streamId, analyticIdx=0, intervalsIdx=0, raiseError=True ... ) >>> print(response.statusCode) 204
Delete streams by filters (OR).
- Parameters:
streamIds (
List
[str
]) – stream idsaccountId (
Optional
[str
]) – account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> response = client.deleteStreams(streamIds=[streamId]) >>> print(response.statusCode) 204 >>> response = client.checkStream(streamId=streamId) >>> print(response.statusCode) 404
Delete streams logs
- Parameters:
logTimeLt (
Optional
[str
]) – log time lower excluded boundary- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> response = client.deleteStreamsLogs() >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "deleted_count": ... }
Delete a task by the task id. Optional you can set, that task must belong to account.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/deleteTask
- Parameters:
taskId (
int
) – task id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> taskId = client.createGcTask(target="events", raiseError=True).json["task_id"] >>> response = client.deleteTask(taskId=taskId) >>> print(response.statusCode) 204
Delete token.
- Parameters:
tokenId (
str
) – token id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return nothing in text field
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.accounts.http_objs import TokenPermissions >>> from uuid import uuid4 >>> import json >>> >>> tokenId = client.createToken(tokenPermissions=TokenPermissions(), raiseError=True).json["token_id"] >>> response = client.deleteToken(tokenId=tokenId) >>> print(response.statusCode) 204
Remove verifier
- Parameters:
verifierId (
str
) – verifier id- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> verifierId = client.createVerifier( ... description="Happy_persons", policies=policies, raiseError=True ... ).json["verifier_id"] >>> response = client.deleteVerifier(verifierId=verifierId) >>> print(response.statusCode) 204
Detect faces on input images.
- Parameters:
inputData (
Union
[BinaryImage
,List
[BinaryImage
],List
[UrlForDetection
],List
[str
]]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idsmultifacePolicy (
int
) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the imageestimateHeadPose (
int
) – Available values : 0, 1detectLandmarks68 (
int
) – Available values : 0, 1estimateQuality (
int
) – Available values : 0, 1estimateGaze (
int
) – Available values : 0, 1estimateEyesAttributes (
int
) – Available values : 0, 1estimateMouthAttributes (
int
) – Available values : 0, 1estimateEmotions (
int
) – Available values : 0, 1estimateMask (
int
) – Available values : 0, 1pitchThreshold (
Optional
[int
]) – maximum deviation pitch angle from 0rollThreshold (
Optional
[int
]) – maximum deviation roll angle from 0yawThreshold (
Optional
[int
]) – maximum deviation yaw angle from 0warpedImage (
int
) – Whether input image is a warped or arbitrary image.extractExif (
Optional
[int
]) – Whether to extract exif from the imageuseExifInfo (
Optional
[int
]) – whether to use exif info for auto orientationestimateFaceQuality (
int
) – whether to estimate face quality
- Returns:
body contains json with samples, exif, filename for succeeded images and errors for failed images.
- Return type:
LunaResponse
- Raises:
ValueError – if no images were found
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_IMAGE >>> >>> response = client.detectFaces( ... inputData=FACE_IMAGE, ... multifacePolicy=1, ... estimateHeadPose=1, ... estimateEmotions=1, ... estimateQuality=1, ... estimateGaze=1, ... estimateMask=1, ... extractExif=1, ... estimateEyesAttributes=1, ... estimateMouthAttributes=1, ... pitchThreshold=20, ... rollThreshold=20, ... yawThreshold=20, ... useExifInfo=1, ... estimateFaceQuality=1, ... ) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "images": [ { "detections": { "filtered_detections": { "face_detections": [ { "detection": { "attributes": { "emotions": { "estimations": { "anger": ..., "disgust": ..., "fear": ..., "happiness": ..., "neutral": ..., "sadness": ..., "surprise": ... }, "predominant_emotion": "neutral" }, "eyes_attributes": { "left_eye": { "iris_landmarks": [...], "state": "open" }, "right_eye": { "iris_landmarks": [...], "state": "open" } }, "gaze": { "pitch": ..., "yaw": ... }, "head_pose": { "pitch": ..., "roll": ..., "yaw": ... }, "mask": { "estimations": { "medical_mask": ..., "missing": ..., "occluded": ... }, "face_occlusion": { "estimations": { "chin": ..., "clear": ..., "correct": ..., "full": ..., "mouth": ..., "partially": ... }, "predominant_occlusion": "clear" }, "predominant_mask": "missing" }, "mouth_attributes": { "occluded": ..., "opened": ..., "score": ..., "smile": ... } }, "face_quality": { "checks": [...], "status": 0 }, "landmarks5": [...], "quality": { "blurriness": ..., "dark": ..., "illumination": ..., "light": ..., "specularity": ... }, "rect": { "height": ..., "width": ..., "x": ..., "y": ... } }, "filter_reasons": [...] } ] }, "samples": [] }, "error": { "desc": "Success", "detail": "Success", "error_code": 0, "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0" }, "exif": {}, "filename": "raw_image", "status": 1 } ] }
Emit input events.
- Parameters:
handlerId (
str
) – handler idinputData (
Union
[BinaryImage
,List
[BinaryImage
],List
[UrlForDetection
],List
[str
],List
[SampleForDetection
]]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idspolicies (
Optional
[Policies
]) – object with policies information for dynamic handlerexternalId (
Optional
[str
]) – external iduserData (
Optional
[str
]) – user dataaggregateAttributes (
Optional
[int
]) – aggregate all attributes (descriptot, age, gender) or not (0 or 1)source (
Optional
[str
]) – sourcestreamId (
Optional
[str
]) – stream idcity (
Optional
[str
]) – event citystreet (
Optional
[str
]) – event streetarea (
Optional
[str
]) – event areadistrict (
Optional
[str
]) – event districthouseNumber (
Optional
[str
]) – event house numberlatitude (
Optional
[float
]) – event latitude in degreeslongitude (
Optional
[float
]) – event longitude in degreestags (
Optional
[str
]) – tagstrackId (
Optional
[str
]) – event track idimageType (
int
) – Image type (0 - raw image, 1 - face warped image, 2 - body warped image).lunaEventTime (
Optional
[str
]) – user defined event create timelunaEventEndTime (
Optional
[str
]) – user defined event end timeuseExifInfo (
Optional
[int
]) – whether to use exif info for auto orientationmeta (
Optional
[dict
]) – user-defined event json metadata
- Returns:
body contains json with created event info.
- Return type:
LunaResponse
>>> import json >>> from luna3.common.http_objs import DetectPolicy, ExtractPolicy >>> from luna3.common.http_objs import MatchPolicy, Policies >>> from luna3.common.http_objs import MatchPolicyCandidates >>> from testData.resources import FACE_WARP as image >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList(userData="happy_persons", raiseError=True).json["list_id"] >>> policies = Policies( ... detectPolicy=DetectPolicy(estimateEmotions=1, estimateMask=1), ... extractPolicy=ExtractPolicy(extractBasicAttributes=1, extractFaceDescriptor=1, fdScoreThreshold=0.0,), ... matchPolicy=[ ... MatchPolicy( ... candidates=MatchPolicyCandidates(origin="faces", listId=listId), ... label="happy", ... limit=3, ... threshold=0.5, ... gender=0, ... ) ... ], ... ) >>> handlerId = client.createHandler( ... description="test_handler", policies=policies, raiseError=True ... ).json["handler_id"] >>> response = client.emitEvents( ... handlerId, ... inputData=[image], ... city="Kazan", ... street="Saban", ... houseNumber="5", ... tags="test_tag", ... imageType=1, ... useExifInfo=1, ... meta={"foo": "bar"}, ... ) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "events": [ { "aggregate_estimations": { "body": { "attributes": {} }, "face": { "attributes": { "emotions": { "estimations": { "anger": ..., "disgust": ..., "fear": ..., "happiness": ..., "neutral": ..., "sadness": ..., "surprise": ... }, "predominant_emotion": "neutral" }, "mask": { "estimations": { "medical_mask": ..., "missing": ..., "occluded": ... }, "face_occlusion": { "estimations": { "chin": ..., "clear": ..., "correct": ..., "full": ..., "mouth": ..., "partially": ... }, "predominant_occlusion": "clear" }, "predominant_mask": "missing" } } } }, "body_attributes": null, "detections": [ { "detect_time": ..., "detect_ts": null, "filename": "Claudia_Schiffer_warp.jpg", "image_origin": null, "samples": { "body": null, "face": { "detection": { "attributes": { "emotions": { "estimations": { "anger": ..., "disgust": ..., "fear": ..., "happiness": ..., "neutral": ..., "sadness": ..., "surprise": ... }, "predominant_emotion": "neutral" }, "mask": { "estimations": { "medical_mask": ..., "missing": ..., "occluded": ... }, "face_occlusion": { "estimations": { "chin": ..., "clear": ..., "correct": ..., "full": ..., "mouth": ..., "partially": ... }, "predominant_occlusion": "clear" }, "predominant_mask": "missing" } } }, "sample_id": ..., "url": "/6/samples/faces/..." } } } ], "event_id": ..., "external_id": "", "face": null, "face_attributes": { "attribute_id": null, "basic_attributes": { "age": ..., "ethnicities": { "estimations": { "african_american": ..., "asian": ..., "caucasian": ..., "indian": ... }, "predominant_ethnicity": "caucasian" }, "gender": 0 }, "samples": [...], "score": ..., "url": null }, "location": { "city": "Kazan", "house_number": "5", "street": "Saban" }, "matches": [ { "candidates": [], "label": "happy" } ], "meta": { "foo": "bar" }, "source": null, "stream_id": null, "tags": [ "test_tag" ], "track_id": null, "url": "/6/events/...", "user_data": "" } ], "filtered_detections": { "face_detections": [] }, "images": [ { "error": { "desc": "Success", "detail": "Success", "error_code": 0, "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0" }, "filename": "Claudia_Schiffer_warp.jpg", "image_estimations": {}, "status": 1 } ] }
Emit beta events.
- Parameters:
handlerId (
str
) – handler idinputData (
StreamEventsSource
) – structure with stream event(s) source
- Returns:
body contains json with created event info.
- Return type:
LunaResponse
>>> import json >>> from luna3.common.http_objs import DetectPolicy, ExtractPolicy >>> from luna3.common.http_objs import MatchPolicy, Policies >>> from luna3.common.http_objs import MatchPolicyCandidates >>> from luna3.handlers.http_objs import ( ... NonAggregatedRawImage, ... StreamEventSourceNonAggregated, ... StreamEventsSource, ... StreamEventSourceData, ... ) >>> from testData.resources import FACE_IMAGE >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList(userData="happy_persons", raiseError=True).json["list_id"] >>> policies = Policies( ... detectPolicy=DetectPolicy(estimateEmotions=1, estimateMask=1), ... extractPolicy=ExtractPolicy(extractBasicAttributes=1, extractFaceDescriptor=1, fdScoreThreshold=0.0,), ... matchPolicy=[ ... MatchPolicy( ... candidates=MatchPolicyCandidates(origin="faces", listId=listId), ... label="happy", ... limit=3, ... threshold=0.5, ... gender=0, ... ) ... ], ... ) >>> handlerId = client.createHandler( ... description="test_handler", policies=policies, raiseError=True ... ).json["handler_id"] >>> response = client.emitStreamEvents( ... handlerId, ... inputData=StreamEventsSource( ... aggregateAttributes=0, ... sources=[ ... StreamEventSourceNonAggregated( ... sourceType="raw_image", source=NonAggregatedRawImage(body=FACE_IMAGE.body) ... ) ... ], ... ) ... ) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "events": [ { "aggregate_estimations": { "body": { "attributes": {} }, "face": { "attributes": { "emotions": { "estimations": { "anger": ..., "disgust": ..., "fear": ..., "happiness": ..., "neutral": ..., "sadness": ..., "surprise": ... }, "predominant_emotion": "neutral" }, "mask": { "estimations": { "medical_mask": ..., "missing": ..., "occluded": ... }, "face_occlusion": { "estimations": { "chin": ..., "clear": ..., "correct": ..., "full": ..., "mouth": ..., "partially": ... }, "predominant_occlusion": "clear" }, "predominant_mask": "missing" } } } }, "body_attributes": null, "detections": [ { "detect_time": ..., "detect_ts": null, "filename": "raw_image", "image_origin": null, "samples": { "body": null, "face": { "detection": { "attributes": { "emotions": { "estimations": { "anger": ..., "disgust": ..., "fear": ..., "happiness": ..., "neutral": ..., "sadness": ..., "surprise": ... }, "predominant_emotion": "neutral" }, "mask": { "estimations": { "medical_mask": ..., "missing": ..., "occluded": ... }, "face_occlusion": { "estimations": { "chin": ..., "clear": ..., "correct": ..., "full": ..., "mouth": ..., "partially": ... }, "predominant_occlusion": "clear" }, "predominant_mask": "missing" } }, "landmarks5": [ [ ..., ... ], [ ..., ... ], [ ..., ... ], [ ..., ... ], [ ..., ... ] ], "rect": { "height": ..., "width": ..., "x": ..., "y": ... } }, "sample_id": ..., "url": ... } } } ], "event_id": ..., "external_id": ..., "face": null, "face_attributes": { "attribute_id": null, "basic_attributes": { "age": ..., "ethnicities": { "estimations": { "african_american": ..., "asian": ..., "caucasian": ..., "indian": ... }, "predominant_ethnicity": "caucasian" }, "gender": ... }, "samples": [ ... ], "score": ..., "url": null }, "location": {}, "matches": [ { "candidates": [], "label": "happy" } ], "meta": null, "source": null, "stream_id": null, "tags": [], "track_id": null, "url": ..., "user_data": ... } ], "filtered_detections": { "face_detections": [] }, "images": [ { "error": { "desc": "Success", "detail": "Success", "error_code": 0, "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0" }, "filename": "raw_image", "image_estimations": {}, "status": 1 } ] }
Export lambda
- Parameters:
lambdaId (
str
) – lambda id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from time import sleep >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> def wait4start(lambdaId_: str): ... for _ in range(150): ... reply = client.getLambdaStatus(lambdaId_).json ... if reply["status"] == "running": ... break ... if reply["status"] == "terminated": ... raise Exception(f"Expected successfully lambda running. Lambda id: {lambdaId_}") ... sleep(1) ... else: ... raise Exception(f"Lambda execution took more than 150 seconds. Lambda id: {lambdaId_}") ... >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> wait4start(lambdaId) >>> response = client.exportLambda(lambdaId=lambdaId) >>> >>> print(response.statusCode) 200
Extract attributes from samples.
- Parameters:
sampleIds (
list
) – list of samplesscoreThreshold (
float
) – number [ 0 .. 1 ]; example: 0.99; descriptor quality score threshold. All the attributes with quality score below the threshold will be ignored (and not stored in the DB). The function will proceed as usual with all the remaining descriptors (if left).extractDescriptor (
int
) – Available values : 0, 1; whether to extract face descriptor(s)extractBasicAttributes (
int
) – Available values : 0, 1; whether to extract basic attributes (gender, age, ethnicity)aggregateAttributes (
int
) – Available values : 0, 1; whether to aggregate face descriptor(s); If true, all extracted attributes will be aggregated and stored in as a single attribute. Otherwise, all attributes will be stored for every sample.ttl (
Optional
[int
]) – temporary attribute ttl
- Returns:
body contains json with attributes info.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> response = client.extractAttrFromSample( ... sampleIds=[sampleId], extractBasicAttributes=1, extractDescriptor=1, ... ) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) [ { "attribute_id": ..., "basic_attributes": { "age": 30, "ethnicities": { "estimations": { "african_american": ..., "asian": ..., "caucasian": ..., "indian": ... }, "predominant_ethnicity": "caucasian" }, "gender": 0 }, "external_url": "http://127.0.0.1:5000/6/attributes/...", "samples": [...], "score": ..., "url": "/6/attributes/..." } ]
Create general ws-connection to luna-sender
- Parameters:
eventType (
Optional
[List
[str
]]) – list of general event typeseventAccount (
Optional
[str
]) – general event accountudFilters (
Optional
[dict
]) – user-defined general event filtersaccountId (
Optional
[str
]) – request account idlogin (
Optional
[str
]) – account loginpassword (
Optional
[str
]) – account passwordtoken (
Optional
[str
]) – tokenasyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultmessageReceiveTimeout (
Optional
[Real
]) – message receive timeout (time between start waiting message and message appearance)
- Return type:
Union
[_BaseRequestContextManager
[ClientWebSocketResponse
],contextmanager
]- Returns:
context manager with connection to luna-sender
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> >>> with client.generalConnect(["event_type1", "event_type2"], messageReceiveTimeout=1) as ws: ... pass # receive event: ws.recv() >>> print(ws.status) 101
Publish user generated event. :type event:
dict
:param event: user generated single event to be published>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> response = client.generalPublishOne( ... event={ ... "event": {"data":"value"}, ... "event_type": "crowd", ... "account_id": "string", ... "event_create_time": "string", ... "event_end_time": "string" ... } ... ) >>> print(response.statusCode) 204
Get account.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getAccount
- Parameters:
targets (
Optional
[list
[str
]]) – targets to get- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with account will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from uuid import uuid4 >>> >>> response = client.getAccount() >>> print(response.statusCode) 200 >>> print(response.json) {'account_id': ..., 'login': ..., 'account_type': 'advanced_user', 'description': ..., 'create_time': ..., 'last_update_time': ...}
Get account.
- Parameters:
page (
int
) – page, default 1pageSize (
int
) – page size, default 10login (
Optional
[str
]) – account loginaccountType (
Optional
[Literal
['admin'
,'advanced_user'
,'user'
]]) – account typecreateTimeLt (
Optional
[str
]) – upper bound for account create_timecreateTimeGte (
Optional
[str
]) – lower bound for account create_timetargets (
Optional
[list
[str
]]) – targets to get
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with account will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> accountLogin = f"{uuid4()}@visionlabs.ru" >>> _ = client.createAccount( ... accountId=str(uuid4()), login=accountLogin, password="pwd", accountType="user" ... ) >>> response = client.getAccounts( ... login=accountLogin, targets=["account_id", "login"], raiseError=True ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "accounts": [ { "account_id": ..., "login": ... } ], "total_count": ... }
Get all stream analytics working intervals
- Parameters:
accountId (
Optional
[str
]) – account idstreamId (
str
) – stream idanalyticIdx (
int
) – index of analytics of interestmerged (
bool
) – whether to return merged intervals or not
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic, Schedule, Interval >>> streamId = client.createStream( ... streamType="stream", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic( ... name=ANALYTIC_NAME, ... schedules=[Schedule(intervals=[ ... Interval(startTime="2025-05-01T01:16:00Z", endTime="2026-05-01T01:16:00Z")]) ... ])], ... raiseError=True, ... ).json["stream_id"] >>> response = client.getAllStreamAnalyticsWorkingIntervals(streamId=streamId, analyticIdx=0, raiseError=True) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "intervals": [ { "intervals": [ { "end_time": ..., "start_time": ... } ], "intervals_idx": 0 } ] }
Get analytic.
- Parameters:
analyticId (
str
) – analytic idaccountId (
Optional
[str
]) – account_id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with group will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_ID >>> response = client.getAnalytic(analyticId=ANALYTIC_ID) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "analytic_id": ...", "analytic_name": "doctests_analytic", "analytic_version": 1, "create_time": ..., "default_parameters": {}, "description": "", "last_update_time": ..., "validation_schema": {} }
Get analytic’s documentation.
- Parameters:
analyticId (
str
) – analytic idaccountId (
Optional
[str
]) – account_id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with group will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_ID >>> response = client.getAnalyticDocumentation(analyticId=ANALYTIC_ID) >>> print(response.statusCode) 200
Get analytics by filters.
- Parameters:
accountId (
Optional
[str
]) – account idanalyticNames (
Optional
[List
[str
]]) – analytic namesanalyticIds (
Optional
[List
[str
]]) – analytic idsorder (
Optional
[Literal
['asc'
,'desc'
]]) – orderanalyticIdGte (
Optional
[str
]) – analytic id upper included boundaryanalyticIdLt (
Optional
[str
]) – analytic id lower excluded boundarycreateTimeGte (
Optional
[str
]) – agent create time upper included boundarycreateTimeLt (
Optional
[str
]) – agent create time lower excluded boundarypage (
Optional
[int
]) – page numberpageSize (
Optional
[int
]) – page size
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with groups will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> response = client.getAnalytics(analyticNames=[ANALYTIC_NAME]) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "analytics": [ { "account_id": ..., "analytic_id": ..., "analytic_name": "doctests_analytic", "analytic_version": 1, "create_time": ..., "default_parameters": {}, "description": "", "last_update_time": ..., "validation_schema": {} } ] }
Get final async mode.
- Parameters:
asyncRequest (
Optional
[bool
]) – async mode as function argument.- Return type:
bool
- Returns:
If async is None, return self.asyncRequest else async
Retrieve a attribute by id.
- Parameters:
attributeId (
str
) – attribute idaccountIdFilter (
Optional
[str
]) – account id to get attribute samples
- Returns:
body contains json with samples.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample(sampleIds=[sampleId], raiseError=True).json[0]["attribute_id"] >>> response = client.getAttributeSamples(attributeId=attributeId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"samples": [...]}
Get attributes ids by filters
- Parameters:
attributeIds (
list
[str
]) – list of attributes of interesttargets (
Optional
[list
[str
]]) – Available targets: descriptor, basic_attributes, basic_attributes_samples, face_descriptors_samples, account_id, create_timedescriptorVersion (
int
) – descriptor version to receiveaccountIdFilter (
Optional
[str
]) – account id to get attributes
- Returns:
body contains json with attributes info.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP, DESCRIPTOR >>> >>> sampleId = client.detectFaces( ... inputData=FACE_WARP, raiseError=True ... ).json["images"][0]["detections"]["samples"][0]["face"]["sample_id"] >>> basicAttributes = {'ethnicity': 3, 'age': 26, 'gender': 0} >>> attributeId = client.createAttribute( ... basicAttributes = basicAttributes, basicAttributesSamples=[sampleId], descriptorSamples=[sampleId], ... descriptors=[DESCRIPTOR], raiseError=True ... ).json["attribute_id"] >>> response = client.getAttributes( ... attributeIds=[attributeId], targets=["basic_attributes_samples", "account_id"] ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"attributes": [{"account_id": ..., "basic_attributes_samples": [...]}]}
Get authorization header by token or login and password
- Parameters:
login (
Optional
[str
]) – loginpassword (
Optional
[str
]) – passwordtoken (
Optional
[str
]) – tokenaccountId (
Optional
[str
]) – account id
- Return type:
dict
- Returns:
dict with Authorization header if applicable or empty dict
Get basic attributes (gender, age, ethnicity) by attrribute id.
- Parameters:
attributeId (
str
) – attribute IddescriptorVersion (
int
) – descriptor version to receivetargets (
Optional
[list
[str
]]) – Available targets: descriptor, basic_attributes, basic_attributes_samples, face_descriptors_samples, account_id, create_timeaccountIdFilter (
Optional
[str
]) – account id to get attribute
- Returns:
body contains json with basic attributes.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample( ... sampleIds=[sampleId], extractBasicAttributes=1, extractDescriptor=1, raiseError=True, ... ).json[0]["attribute_id"] >>> response = client.getBasicAttributesById( ... attributeId, targets=["create_time", "attribute_id", "account_id", "face_descriptor_samples", ... "basic_attributes_samples", "face_descriptor", "basic_attributes"] ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "attribute_id": ..., "basic_attributes": { "age": ..., "ethnicity": ..., "gender": ... }, "basic_attributes_samples": [...], "create_time": ..., "face_descriptor": ..., "face_descriptor_samples": [...] }
Return aiohttp request body or body_producer.
- Parameters:
images (
Union
[BinaryImage
,Iterable
[BinaryImage
]]) – image or list of images- Return type:
Union
[MultipartWriter
,bytes
]- Returns:
request body
Function prepare body and content type for request, depends on incoming image(s).
- Parameters:
headers (
dict
) – request’s headers to updateimages (
Union
[BinaryImage
,List
[BinaryImage
]]) – Single image or images list for extraction or None
- Return type:
Union
[MultipartWriter
,bytes
,None
]- Returns:
list of image(s) and list of url(s)
Get body sample by id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getSample
- Parameters:
sampleId (
str
) – sample IdaccountIdFilter (
Optional
[str
]) – account id to get sample
- Returns:
body contains image as bytes.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import BODY_WARP as image >>> >>> sampleId = client.saveBodySample(image=image, raiseError=True).json["sample_id"] >>> response = client.getBodySample(sampleId=sampleId) >>> print(response.statusCode) 200 >>> print(response.contentType) image/jpeg >>> assert image.body == response.body
Get config of luna service
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getConfig
- Parameters:
acceptHeaders (
Optional
[dict
]) – Accept request header. By default Accept-Type is application/json.lunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$asyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultraiseError (
Optional
[bool
]) – if request fails, LunaApiException is raisedtotalTimeout (
Optional
[Real
]) – request processing timeout in seconds.connectTimeout (
Optional
[Real
]) – connection timeout seconds.sockReadTimeout (
Optional
[Real
]) – socket read timeoutsockConnectTimeout (
Optional
[Real
]) – socket connect timeout
- Returns:
body contains json with HTML or YAML as bytes.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> response= client.getConfig() >>> print(response.statusCode) 200 >>> print(json.dumps(response.json["LUNA_MONITORING"], sort_keys=True, indent=4)) { "BUCKET": "luna_monitoring", "FLUSHING_PERIOD": 1, "HOST": ..., "ORGANIZATION": "luna", "PORT": 8086, "SEND_DATA_FOR_MONITORING": 1, "STORAGE_TYPE": "influx", "TOKEN": "********", "USE_SSL": 0 }
Get deleted events.
- Parameters:
deletionTimeGte (
Optional
[str
]) – lower including deletion time boundarydeletionTimeLt (
Optional
[str
]) – upper excluding end time boundaryeventIds (
Optional
[list
[str
]]) – event idseventIdGte (
Optional
[str
]) – event id lower including boundeventIdLt (
Optional
[str
]) – event id upper excluding boundpage (
Optional
[int
]) – number of result pagepageSize (
Optional
[int
]) – count of results in pageorder (
Optional
[str
]) – result sort order (ask or desc)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
Get deleted general events.
- Parameters:
deletionTimeGte (
Optional
[str
]) – lower including deletion time boundarydeletionTimeLt (
Optional
[str
]) – upper excluding end time boundaryeventIds (
Optional
[list
[str
]]) – event idseventIdGte (
Optional
[str
]) – event id lower including boundeventIdLt (
Optional
[str
]) – event id upper excluding boundpage (
Optional
[int
]) – number of result pagepageSize (
Optional
[int
]) – count of results in pageorder (
Optional
[str
]) – result sort order (ask or desc)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
Get Development Manual of luna service
- Parameters:
lunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$asyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultraiseError (
Optional
[bool
]) – if request fails, LunaApiException is raisedtotalTimeout (
Optional
[Real
]) – request processing timeout in seconds.connectTimeout (
Optional
[Real
]) – connection timeout seconds.sockReadTimeout (
Optional
[Real
]) – socket read timeoutsockConnectTimeout (
Optional
[Real
]) – socket connect timeout
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return HTML as bytes.
- Return type:
class
Get error by id.
- Parameters:
errorId (
int
) – error idaccountIdFilter (
Optional
[str
]) – account id to get error
- Returns:
body contains json with info about errors of a task.
- Return type:
LunaResponse
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> unknownFaceId = "668ea250-9341-484f-a103-8dda6994a654" >>> faceFilters = FaceFilters(faceIds=[unknownFaceId]) >>> taskId = client.createClusteringTask( ... filters=faceFilters, descriptorTypeFilter="face", raiseError=True ... ).json["task_id"] >>> time.sleep(1) >>> errorId = client.getTaskErrors(taskId=taskId, raiseError=True).json["errors"][0]["error_id"] >>> response = client.getError(errorId=errorId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "additional_info": ..., "description": "Objects not found", "detail": "Objects for clustering not found (empty set)", "error_code": 28010, "error_id": ..., "error_time": ..., "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-28010", "subtask_id": ..., "task_id": ... }
Get errors with filters.
- Parameters:
errorIds (
Optional
[List
[int
]]) – error idstaskIds (
Optional
[List
[int
]]) – task idserrorTimeLt (
Optional
[str
]) – error time upper excluding bounderrorTimeGte (
Optional
[str
]) – error time lower including boundtaskType (
Optional
[int
]) – task type filtererrorCode (
Optional
[int
]) – task status filterpage (
Optional
[int
]) – pagepageSize (
Optional
[int
]) – page sizeaccountIdFilter (
Optional
[str
]) – account id to get errors
- Returns:
body contains json with info about errors of a task.
- Return type:
LunaResponse
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> unknownFaceId = "668ea250-9341-484f-a103-8dda6994a654" >>> faceFilters = FaceFilters(faceIds=[unknownFaceId]) >>> taskId = client.createClusteringTask( ... filters=faceFilters, descriptorTypeFilter="face", raiseError=True ... ).json["task_id"] >>> time.sleep(1) >>> errorCode = client.getTaskErrors(taskId=taskId, raiseError=True).json["errors"][0]["error_code"] >>> response = client.getErrors(errorCode=errorCode) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json["errors"][0], sort_keys=True, indent=4)) { "additional_info": ..., "description": "Objects not found", "detail": "Objects for clustering not found (empty set)", "error_code": 28010, "error_id": ..., "error_time": ..., "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-28010", "subtask_id": ..., "task_id": ... }
Get errors count with filters.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getTasksErrorsCount # pylint: disable=line-too-long
- Parameters:
errorIds (
Optional
[List
[int
]]) – error idstaskIds (
Optional
[List
[int
]]) – task idserrorTimeLt (
Optional
[str
]) – error time upper excluding bounderrorTimeGte (
Optional
[str
]) – error time lower including boundtaskType (
Optional
[int
]) – task type filtererrorCode (
Optional
[int
]) – task status filteraccountIdFilter (
Optional
[str
]) – account id to get errors count
- Returns:
body contains json with errors count.
- Return type:
LunaResponse
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> unknownFaceId = "668ea250-9341-484f-a103-8dda6994a654" >>> faceFilters = FaceFilters(faceIds=[unknownFaceId]) >>> taskId = client.createClusteringTask( ... filters=faceFilters, descriptorTypeFilter="face", raiseError=True ... ).json["task_id"] >>> time.sleep(1) >>> errorCode = client.getTaskErrors(taskId=taskId, raiseError=True).json["errors"][0]["error_code"] >>> response = client.getErrorsCount(errorCode=errorCode) >>> print(response.statusCode) 200 >>> print(response.json) {'count': ...}
Get event by id.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getEvent
- Parameters:
eventId (
str
) – event idtarget (
Optional
[List
[Literal
['account_id'
,'create_time'
,'end_time'
,'event_id'
,'handler_id'
,'external_id'
,'source'
,'stream_id'
,'top_match'
,'match_result'
,'face_detections'
,'face_id'
,'attach_result'
,'gender'
,'age'
,'emotion'
,'ethnic_group'
,'liveness'
,'deepfake'
,'body_detections'
,'body_basic_attributes'
,'upper_body'
,'lower_body'
,'accessories'
,'tags'
,'user_data'
,'location'
,'mask'
,'track_id'
,'meta'
]]]) – list of events’ fields to receive instead of full eventsaccountIdFilter (
Optional
[str
]) – account id to get event
- Returns:
body contains json with event info.
- Return type:
LunaResponse
>>> import json >>> from luna3.common.http_objs import Policies, DetectPolicy >>> from testData.resources import FACE_WARP >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> policies = Policies(detectPolicy=DetectPolicy(detectFace=1)) >>> handlerId = client.createHandler( ... description="test_handler_events", policies=policies, raiseError=True ... ).json["handler_id"] >>> eventId = client.emitEvents( ... handlerId=handlerId, ... inputData=[FACE_WARP], ... city="Kazan", ... street="Saban", ... houseNumber="5", ... imageType=1, ... useExifInfo=1, ... meta={"foo": "bar"}, ... raiseError=True, ... ).json["events"][0]["event_id"] >>> response = client.getEvent(eventId=eventId) >>> print(response.statusCode) 200
>>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "accessories": null, "account_id": ..., "age": null, "attach_result": [], "body_basic_attributes": null, "body_detections": null, "create_time": ..., "deepfake": null, "emotion": null, "end_time": ..., "ethnic_group": null, "event_id": ..., "external_id": "", "face_detections": [ { "detect_time": ..., "detect_ts": null, "image_origin": null, "sample_id": ... } ], "face_id": null, "gender": null, "handler_id": ..., "liveness": null, "location": { "area": null, "city": "Kazan", "district": null, "geo_position": null, "house_number": "5", "street": "Saban" }, "lower_body": null, "mask": null, "match_result": null, "meta": { "foo": "bar" }, "source": null, "stream_id": null, "tags": null, "top_match": null, "track_id": null, "upper_body": null, "user_data": "" }
Get events by filters.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getEvents
- Parameters:
target (
Optional
[List
[Literal
['account_id'
,'create_time'
,'end_time'
,'event_id'
,'handler_id'
,'external_id'
,'source'
,'stream_id'
,'top_match'
,'match_result'
,'face_detections'
,'face_id'
,'attach_result'
,'gender'
,'age'
,'emotion'
,'ethnic_group'
,'liveness'
,'deepfake'
,'body_detections'
,'body_basic_attributes'
,'upper_body'
,'lower_body'
,'accessories'
,'tags'
,'user_data'
,'location'
,'mask'
,'track_id'
,'meta'
]]]) – list of events’ fields to receive instead of full eventscreateTimeGte (
Optional
[str
]) – lower including create time boundarycreateTimeLt (
Optional
[str
]) – upper excluding create time boundaryendTimeGte (
Optional
[str
]) – lower including end time boundaryendTimeLt (
Optional
[str
]) – upper excluding end time boundaryinsertTimeGte (
Optional
[str
]) – lower including insert time boundaryinsertTimeLt (
Optional
[str
]) – upper excluding insert time boundaryfaceIds (
Optional
[List
[str
]]) – ids of faces linked with an eventeventIds (
Optional
[List
[str
]]) – event idseventIdGte (
Optional
[str
]) – event id lower including boundeventIdLt (
Optional
[str
]) – event id upper excluding boundhandlerIds (
Optional
[List
[str
]]) – handler idsexternalIds (
Optional
[List
[str
]]) – external idsuserData (
Optional
[str
]) – event user datasources (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of sourcestreamIds (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of stream idsareas (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of areasstreets (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of streetsdistricts (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of districtscities (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of citieshouseNumbers (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of house numbersoriginLongitude (
Union
[float
,Literal
['null'
],None
]) – origin longitude in degreesoriginLatitude (
Union
[float
,Literal
['null'
],None
]) – origin latitude in degreeslongitudeDelta (
Optional
[float
]) – longitude delta in degreeslatitudeDelta (
Optional
[float
]) – latitude delta in degreestags (
Optional
[List
[str
]]) – users tagstopMatchingCandidatesLabel (
Optional
[List
[str
]]) – top matching candidate labeltopSimilarObjectIds (
Optional
[List
[str
]]) – top similar object idstopSimilarExternalIds (
Optional
[List
[str
]]) – top similar external idstopSimilarObjectSimilarityGte (
Optional
[float
]) – lower including top similarity boundarytopSimilarObjectSimilarityLt (
Optional
[float
]) – upper excluding top similarity boundaryageLt (
Optional
[int
]) – upper excluding age boundaryageGte (
Optional
[int
]) – lower including age boundarygender (
Union
[int
,Literal
['null'
],None
]) – gender of event (0 or 1)emotions (
Optional
[List
[Union
[int
,Literal
['null'
]]]]) – dominant emotions in event (one of (1, 2, 3, 4, 5, 6, 7) - matches “anger”, “disgust”, “fear”, “happiness”, “neutral”, “sadness”, “surprise”)masks (
Optional
[List
[Union
[int
,Literal
['null'
]]]]) – dominant masks in event (one of (1, 2, 3)) - matches “missing”, “medical mask”, “occluded”)ethnicGroups (
Union
[List
[int
],Literal
['null'
],None
]) – dominant ethnicity of the face ((1, 2, 3, 4) - means (indian, asian, african_american, caucasian)trackIds (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of event track idsliveness (
Union
[List
[int
],Literal
['null'
],None
]) – liveness in event (0 - spoof, 1 - real, 2 - unknown)deepfake (
Union
[List
[int
],Literal
['null'
],None
]) – deepfake in event (0 - fake, 1 - real)apparentAgeLt (
Optional
[int
]) – apparent age upper excluding boundaryapparentAgeGte (
Optional
[int
]) – apparent age upper including boundaryapparentGender (
Optional
[List
[Union
[Literal
[0
,1
,2
],Literal
['null'
]]]]) – apparent gender estimation values (0 - female, 1 - male, 2 - undefined)headwearStates (
Optional
[List
[Union
[Literal
[0
,1
,2
],Literal
['null'
]]]]) – headwear states (0 - absent, 1 - present, 2 - undefined)sleeveLengths (
Optional
[List
[Union
[Literal
['short'
,'long'
,'undefined'
],Literal
['null'
]]]]) – sleeve lengthsupperClothingColors (
Optional
[List
[Union
[Literal
['black'
,'blue'
,'green'
,'gray'
,'orange'
,'purple'
,'red'
,'white'
,'yellow'
,'pink'
,'brown'
,'beige'
,'khaki'
,'multicolored'
,'undefined'
],Literal
['null'
]]]]) – upper clothing color setbackpackStates (
Optional
[List
[Union
[Literal
[0
,1
,2
],Literal
['null'
]]]]) – backpack states (0 - absent, 1 - present, 2 - undefined)meta (
Optional
[dict
]) – user-defined event meta’s filters in format {meta.<path.to.field>__<operator>:<type>: <value>}page (
Optional
[int
]) – number of result pagepageSize (
Optional
[int
]) – count of results in pageorder (
Optional
[str
]) – result sort order (ask or desc)accountIdFilter (
Optional
[str
]) – account id to get events
- Returns:
body contains json with info about events.
- Return type:
LunaResponse
>>> import json >>> from luna3.common.http_objs import Policies, DetectPolicy >>> from testData.resources import FACE_WARP >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> policies = Policies(detectPolicy=DetectPolicy(detectFace=1)) >>> handlerId = client.createHandler( ... description="test_handler_events", policies=policies, raiseError=True ... ).json["handler_id"] >>> eventId = client.emitEvents( ... handlerId=handlerId, ... inputData=[FACE_WARP], ... city="Kazan", ... street="Saban", ... houseNumber="5", ... imageType=1, ... useExifInfo=1, ... meta={"foo": "bar"}, ... raiseError=True, ... ).json["events"][0]["event_id"] >>> response = client.getEvents(handlerIds=[handlerId], meta={"meta.foo__in:string": ["bar", "baz"]}) >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "events": [ { "accessories": null, "account_id": ..., "age": null, "attach_result": [], "body_basic_attributes": null, "body_detections": null, "create_time": ..., "deepfake": null, "emotion": null, "end_time": ..., "ethnic_group": null, "event_id": ..., "external_id": "", "face_detections": [ { "detect_time": ..., "detect_ts": null, "image_origin": null, "sample_id": ... } ], "face_id": null, "gender": null, "handler_id": ...", "liveness": null, "location": { "area": null, "city": "Kazan", "district": null, "geo_position": null, "house_number": "5", "street": "Saban" }, "lower_body": null, "mask": null, "match_result": null, "meta": { "foo": "bar" }, "source": null, "stream_id": null, "tags": null, "top_match": null, "track_id": null, "upper_body": null, "user_data": "" } ] } >>> print(response.statusCode) 200
Get events statistics by aggregation (<aggregator> and <groupBy> on <target>) and filters.
- Parameters:
query (
Union
[StatQuery
,dict
]) – query object or query dict, contained in StatQuery object- Returns:
body contains json with event stats.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import StatQuery >>> >>> statQuery = StatQuery().addGroupBy("dayOfWeek").addTarget(column="city") >>> response = client.getEventsStats(query=statQuery) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "fields": [ "Group by time: dayOfWeek", "city, aggregator 'count'" ], "stats": [ [...] ] }
Get face by id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getFace
- Parameters:
faceId (
str
) – face idtargets (
Optional
[List
[str
]]) – list of face fields to receive instead of full faceaccountIdFilter (
Optional
[str
]) – account id to get face
- Returns:
body contains json with face information.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json["face_id"] >>> response = client.getFace(faceId=faceId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "avatar": "", "create_time": ..., "event_id": null, "external_id": "", "face_id": ..., "lists": [], "user_data": "" }
Get face attributes
- Parameters:
faceId (
str
) – face idtargets (
Optional
[List
[str
]]) – targets to get face attributes. Available targets: create_time, face_descriptor, basic_attributes, face_descriptor_samples, basic_attributes_samples.descriptorVersion (
Optional
[int
]) – descriptor versionaccountIdFilter (
Optional
[str
]) – account id to get face attributes
- Returns:
body contains json with face information.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json["face_id"] >>> response = client.getFaceAttributes(faceId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "attributes": { "basic_attributes": null, "basic_attributes_samples": [], "create_time": null, "face_descriptor": null, "face_descriptor_samples": [] } }
Get face sample by id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getSample
- Parameters:
sampleId (
str
) – sample IdaccountIdFilter (
Optional
[str
]) – account id to get sample
- Returns:
body contains image as bytes.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP as image >>> >>> sampleId = client.saveFaceSample(image=image, raiseError=True).json["sample_id"] >>> response = client.getFaceSample(sampleId=sampleId) >>> print(response.statusCode) 200 >>> print(response.contentType) image/jpeg >>> assert image.body == response.body
Get samples which are associated with the face attributes (gender, age, ethnicity, descriptor).
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getFaceAttributeSamples # pylint: disable=line-too-long
- Parameters:
faceId (
str
) – face IdaccountIdFilter (
Optional
[str
]) – account id to get face samples
- Returns:
body contains json with basic attributes.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json['face_id'] >>> response = client.getFaceSamples(faceId=faceId) >>> print(response.statusCode) 200 >>> print(response.json) {'samples': [...]}
Getting faces which satisfy filters
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getFaces
- Parameters:
userData (
Optional
[str
]) – user data, part of user data, case insensitiveeventId (
Optional
[str
]) – event idlistId (
Optional
[str
]) – list idfaceIds (
Optional
[List
[str
]]) – face idstimeLt (
Optional
[str
]) – upper bound of face create timetimeGte (
Optional
[str
]) – lower bound of face create timepage (
Optional
[int
]) – page count, default 1pageSize (
Optional
[int
]) – page size, default 10, unlimited if -1externalIds (
Optional
[List
[str
]]) – list of external identifiers of persons, if they have their own mapping in the systemfaceIdGte (
Optional
[str
]) – upper bound of face idfaceIdLt (
Optional
[str
]) – lower bound of face idtargets (
Optional
[List
[str
]]) – targets to get facesaccountIdFilter (
Optional
[str
]) – account id to get faces
- Returns:
body contains json with faces info.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace( ... externalId="2xQ2gprbMePw1s9gw9fvA==", userData="test_data05", ... avatar="https://st.kp.yandex.net/images/actor_iphone/iphone360_460188.jpg", raiseError=True ... ).json["face_id"] >>> response = client.getFaces( ... faceIds=[faceId], targets=["external_id", "user_data", "avatar"], raiseError=True ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "faces": [ { "avatar": "https://st.kp.yandex.net/images/actor_iphone/iphone360_460188.jpg", "external_id": "2xQ2gprbMePw1s9gw9fvA==", "user_data": "test_data05" } ] }
Count faces with attributes. Optional you can set, that faces must belong to account.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getFaceAttributeCount # pylint: disable=line-too-long
- Parameters:
accountIdFilter (
Optional
[str
]) – account id to count faces with attributes- Returns:
body contains json with number of faces.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> response = client.getFacesAttributesCount() >>> print(response.statusCode) 200 >>> print(response.json) {'faces_count': ...}
Get platform features
- Parameters:
lunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$asyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultraiseError (
Optional
[bool
]) – if request fails, LunaApiException is raisedtotalTimeout (
Optional
[Real
]) – request processing timeout in seconds.connectTimeout (
Optional
[Real
]) – connection timeout seconds.sockReadTimeout (
Optional
[Real
]) – socket read timeoutsockConnectTimeout (
Optional
[Real
]) – socket connect timeout
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with platform features.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client
>>> response = client.getFeatures() >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, indent=4)) { "license": ..., "estimations": { "people_counter": ..., "face_quality": ..., "body_attributes": ..., "liveness": ..., "deepfake": ... }, "components": { "faces": ..., "events": ..., "tasks": ..., "sender": ..., "image_store": ..., "handlers": ... } }
Get general event by id.
- Parameters:
eventId (
str
) – event idaccountIdFilter (
Optional
[str
]) – event account id filter
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
Get general event descriptors by filters.
- Parameters:
eventIds (
Optional
[list
[str
]]) – event idsaccountIdFilter (
Optional
[str
]) – event account idpage (
Optional
[int
]) – number of result pagepageSize (
Optional
[int
]) – count of results in pageorder (
Optional
[str
]) – result sort order (ask or desc)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
Get general events by filters.
- Parameters:
eventType (
Optional
[list
[str
]]) – general event typescreateTimeGte (
Optional
[str
]) – lower including create time boundarycreateTimeLt (
Optional
[str
]) – upper excluding create time boundaryendTimeGte (
Optional
[str
]) – lower including end time boundaryendTimeLt (
Optional
[str
]) – upper excluding end time boundaryinsertTimeGte (
Optional
[str
]) – lower including insert time boundaryinsertTimeLt (
Optional
[str
]) – upper excluding insert time boundaryaccountIdFilter (
Optional
[str
]) – event account ideventIds (
Optional
[list
[str
]]) – event idseventIdGte (
Optional
[str
]) – event id lower including boundeventIdLt (
Optional
[str
]) – event id upper excluding boundsources (
Optional
[List
[Union
[str
,Literal
['null'
]]]]) – list of sourcestreamIds (
Optional
[list
[Union
[str
,Literal
['null'
]]]]) – list of stream idstrackIds (
Optional
[list
[Union
[str
,Literal
['null'
]]]]) – list of track idscities (
Optional
[list
[Union
[str
,Literal
['null'
]]]]) – list of citiesareas (
Optional
[list
[Union
[str
,Literal
['null'
]]]]) – list of areasdistricts (
Optional
[list
[Union
[str
,Literal
['null'
]]]]) – list of districtsstreets (
Optional
[list
[Union
[str
,Literal
['null'
]]]]) – list of streetshouseNumbers (
Optional
[list
[Union
[str
,Literal
['null'
]]]]) – list of house numbersoriginLongitude (
Union
[float
,Literal
['null'
],None
]) – origin longitude in degreesoriginLatitude (
Union
[float
,Literal
['null'
],None
]) – origin latitude in degreeslongitudeDelta (
Optional
[float
]) – longitude delta in degreeslatitudeDelta (
Optional
[float
]) – latitude delta in degreeseventContentFilters (
Optional
[dict
]) – event json content filterspage (
Optional
[int
]) – number of result pagepageSize (
Optional
[int
]) – count of results in pageorder (
Optional
[str
]) – result sort order (ask or desc)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
Get general events statistics by aggregation (<aggregator> and <groupBy> on <target>) and filters.
- Parameters:
query (
Union
[StatQuery
,dict
]) – query object or query dict, contained in GeneralStatQuery object- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with event statistics will be returned.
- Return type:
class
Get group.
- Parameters:
groupId (
str
) – group idaccountId (
Optional
[str
]) – account_id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with group will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> groupId = client.createGroup( ... groupName="get_group", ... description="test group description", ... raiseError=True, ... ).json["group_id"] >>> response = client.getGroup(groupId=groupId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "description": "test group description", "group_id": ..., "group_name": "get_group" }
Get groups by filters.
- Parameters:
accountId (
Optional
[str
]) – account idgroupNames (
Optional
[List
[str
]]) – group namesgroupIds (
Optional
[List
[str
]]) – group idspage (
Optional
[int
]) – page numberpageSize (
Optional
[int
]) – page size
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with groups will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> groupId = client.createGroup( ... groupName="get_groups", ... description="test groups description", ... raiseError=True, ... ).json["group_id"] >>> response = client.getGroups(groupIds=[groupId]) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "groups": [ { "account_id": ..., "create_time": ..., "description": "test groups description", "group_id": ..., "group_name": "get_groups" } ] }
Get handler by its id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getHandler
- Parameters:
handlerId (
str
) – handler idaccountIdFilter (
Optional
[str
]) – account id to get handler
- Returns:
body contains json with handler info.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> handlerId = client.createHandler(handlerType=1, description="dynamic", raiseError=True).json["handler_id"] >>> response = client.getHandlerById(handlerId=handlerId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "description": "dynamic", "handler_id": ..., "handler_type": 1, "is_dynamic": ..., "last_update_time": ..., "policies": null }
Get handlers by filters
- Parameters:
description (
Optional
[str
]) – Find all handlers with description which “like” of this parameterhandlerType (
Optional
[int
]) – handler type (0 - static, 1 - dynamic, 2 - lambda)page (
int
) – The number of pagepageSize (
int
) – The numbers of items on pageaccountIdFilter (
Optional
[str
]) – account id to get handlers
- Returns:
body contains json with handlers info.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import DetectPolicy, ExtractPolicy, StoragePolicy, LinkToListPolicy >>> from luna3.common.http_objs import MatchPolicy, Filters, Policies, FacePolicy >>> from luna3.common.http_objs import MatchPolicyCandidates, ConditionalTagPolicy >>> >>> _ = client.createHandler(handlerType=1, description="dynamic", raiseError=True) >>> response = client.getHandlers(description="dynamic", handlerType=1) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json[0], sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "description": "dynamic", "handler_id": ..., "handler_type": 1, "is_dynamic": ..., "last_update_time": ..., "policies": null } >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> policies = Policies( ... detectPolicy=DetectPolicy( ... estimateHeadPose=1, ... estimateEmotions=1, ... estimateGaze=1, ... extractExif=1, ... estimateLiveness=DetectPolicy.LivenessEstimationPolicy(1, 0.5, 0.5), ... estimateDeepfake=DetectPolicy.DeepfakeEstimationPolicy(1, 0.5, 2), ... rollThreshold=20, ... ), ... extractPolicy=ExtractPolicy(extractBasicAttributes=1, extractFaceDescriptor=1, fdScoreThreshold=0.7772), ... matchPolicy=[ ... MatchPolicy( ... candidates=MatchPolicyCandidates(origin="faces", listId=listId), ... label="test_faces", ... gender=1, ... ethnicities=[1, 2], ... limit=3, ... ) ... ], ... storagePolicy=StoragePolicy( ... facePolicy=FacePolicy( ... storeFace=1, ... filters=Filters(ageGte=18, ageLt=40), ... setSampleAsAvatar=1, ... linkToListsPolicy=[LinkToListPolicy(listId=listId)], ... ) ... ), ... conditionalTagsPolicy=[ConditionalTagPolicy(tag="test_tag")], ... ) >>> response = client.createHandler(description="test_persons", policies=policies, raiseError=True) >>> response = client.getHandlers(description="test_persons", handlerType=0) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json[0], sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "description": "test_persons", "handler_id": ..., "handler_type": 0, "is_dynamic": ..., "last_update_time": ..., "policies": { "conditional_tags_policy": [ { "filters": {}, "tag": "test_tag" } ], "detect_policy": { "body_attributes": { "estimate_accessories": 0, "estimate_basic_attributes": 0, "estimate_lower_body": 0, "estimate_upper_body": 0 }, "deepfake_states": null, "detect_body": 0, "detect_face": 1, "detect_landmarks68": 0, "estimate_deepfake": { "estimate": 1, "mode": 2, "real_threshold": 0.5 }, "estimate_emotions": 1, "estimate_eyes_attributes": 0, "estimate_face_occlusion": { "estimate": 0, "eye_threshold": 0.15, "forehead_threshold": 0.2, "hair_occlusion_threshold": 0.15, "lower_face_threshold": 0.2, "mouth_threshold": 0.15, "nose_threshold": 0.2, "occlusion_threshold": 0.07 }, "estimate_gaze": 1, "estimate_glasses": 0, "estimate_head_pose": 1, "estimate_liveness": { "estimate": 1, "liveness_threshold": 0.5, "quality_threshold": 0.5 }, "estimate_mask": 0, "estimate_mouth_attributes": 0, "estimate_people_count": { "estimate": 0, "people_coordinates": 1 }, "estimate_quality": 0, "extract_exif": 1, "face_occlusion_states": null, "face_quality": { "checks": {...}, "estimate": 0, "filter": 0 }, "liveness_states": null, "mask_states": null, "multiface_policy": 1, "pitch_threshold": null, "roll_threshold": 20, "yaw_threshold": null }, "extract_policy": { "extract_basic_attributes": 1, "extract_body_descriptor": 0, "extract_face_descriptor": 1, "fd_score_threshold": 0.7772 }, "match_policy": [ { "candidates": { "list_id": ..., "origin": "faces" }, "descriptor": { "descriptor_type": "face" }, "filters": { "ethnicities": [ 1, 2 ], "gender": 1 }, "label": "test_faces", "limit": 3 } ], "storage_policy": { "attribute_policy": { "filters": {}, "store_attribute": 0, "ttl": 300 }, "body_sample_policy": { "filters": {}, "store_sample": 1, "ttl": null }, "callbacks": [], "event_policy": { "filters": {}, "store_event": 1, "wait_saving": 1 }, "face_policy": { "filters": { "age__gte": 18, "age__lt": 40 }, "link_to_lists_policy": [ { "filters": {}, "list_id": ... } ], "set_sample_as_avatar": 1, "store_face": 1 }, "face_sample_policy": { "filters": {}, "store_sample": 1, "ttl": null }, "image_origin_policy": { "filters": {}, "store_image": 0, "ttl": null, "use_external_references": 1 }, "notification_policy": { "filters": {}, "send_notification": 1 } } } }
Get handlers count by filters
- Parameters:
description (
Optional
[str
]) – Find all handlers with description which “like” of this parameterhandlerType (
Optional
[int
]) – handler type (0 - static, 1 - dynamic, 2 - lambda)accountIdFilter (
Optional
[str
]) – account id to get handlers count
- Returns:
body contains json with handlers count
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> response = client.createHandler(handlerType=1, description="dynamic", raiseError=True) >>> response = client.getHandlersCount(description="dynamic", handlerType=1) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"handlers_count": ...}
Get image by id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getImage
- Parameters:
imageId (
str
) – image idaccountIdFilter (
Optional
[str
]) – account id to get imagewithMeta (
bool
) – whether to retrieve user-defined image metadata
- Returns:
body contains image as bytes.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP as image >>> >>> imageId = client.saveImage(image=image, raiseError=True).json["image_id"] >>> response = client.getImage(imageId=imageId) >>> print(response.statusCode) 200 >>> print(response.contentType) image/jpeg >>> assert image.body == response.body
Get lambda by id.
- Parameters:
lambdaId (
str
) – lambda idaccountIdFilter (
Optional
[str
]) – account id filter for get lambda
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> response = client.getLambda(lambdaId=lambdaId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "additional_user_docker_commands": [], "archive_ttl": null, "base_image": { "name": "lpa-lambda-base", "tag": ... }, "create_time": ..., "deploy_parameters": { "gpu_enabled": ..., "namespace": "default", "pod_count": ..., "resources": { "cpu_limit": ..., "cpu_request": ..., "ram_limit": ..., "ram_request": ... }, "selector": {} }, "description": "", "imported_image": { "name": null, "tag": ... }, "info": { "status": ... }, "lambda_id": ..., "lambda_name": ..., "lambda_type": "standalone", "last_update_time": ..., "version": 1, "workers": 1 }
Get lambda by id.
- Parameters:
lambdaId (
str
) – lambda idaccountId (
Optional
[str
]) – account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> from time import sleep >>> >>> def wait4start(lambdaId_: str): ... for _ in range(150): ... reply = client.getLambdaStatus(lambdaId_).json ... if reply["status"] == "running": ... break ... if reply["status"] == "terminated": ... raise Exception(f"Expected successfully lambda running. Lambda id: {lambdaId_}") ... sleep(1) ... else: ... raise Exception(f"Lambda execution took more than 150 seconds. Lambda id: {lambdaId_}") >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> wait4start(lambdaId) >>> response = client.getLambdaImage(lambdaId=lambdaId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"exported_image": {"image": ...}}
Get lambda image creation logs
- Parameters:
lambdaId (
str
) – lambda idtailLines (
Optional
[int
]) – number of last string from lambda logs
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda status will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> response = client.getLambdaImageCreationLogs(lambdaId=lambdaId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"logs": [...]}
Check lambda image creation status by id.
- Parameters:
lambdaId (
str
) – lambda idaccountIdFilter (
Optional
[str
]) – account id filter for get lambda image status
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda status will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> response = client.getLambdaImageCreationStatus(lambdaId=lambdaId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"status": ...}
Get lambda logs
- Parameters:
lambdaId (
str
) – lambda idtailLines (
Optional
[int
]) – number of last string from lambda logsaccountIdFilter (
Optional
[str
]) – account id filter for lambda logs
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda status will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> response = client.getLambdaLogs(lambdaId=lambdaId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"logs": {...}}
Get lambda spec
- Parameters:
lambdaId (
str
) – lambda idaccept (
str
) – accept headeraccountIdFilter (
Optional
[str
]) – account id filter for get lambda docs
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
Check lambda status by id.
- Parameters:
lambdaId (
str
) – lambda idaccountIdFilter (
Optional
[str
]) – account id filter for get lambda status
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda status will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> response = client.getLambdaStatus(lambdaId=lambdaId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"status": ...}
Get lambdas by filters.
- Parameters:
accountIdFilter (
Optional
[str
]) – account id filter for get lambdascreateTimeLt (
Optional
[str
]) – upper bound of face create timecreateTimeGte (
Optional
[str
]) – lower bound of face create timelambdaType (
Optional
[Literal
['standalone'
,'handlers'
,'tasks'
,'agent'
]]) – lambda typenamespace (
Optional
[list
]) – k8s namespacespage (
int
) – pagination page valuepageSize (
int
) – pagination page size value
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambdas will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> _ = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())) >>> response = client.getLambdas() >>> print(response.statusCode) 200 >>> print(json.dumps(response.json["lambdas"][0], sort_keys=True, indent=4)) { "account_id": ..., "additional_user_docker_commands": [], "archive_ttl": null, "base_image": { "name": "lpa-lambda-base", "tag": ... }, "create_time": ..., "deploy_parameters": { "gpu_enabled": ..., "namespace": "default", "pod_count": ..., "resources": { "cpu_limit": ..., "cpu_request": ..., "ram_limit": ..., "ram_request": ... }, "selector": {} }, "description": "", "imported_image": { "name": null, "tag": ... }, "info": { "status": ... }, "lambda_id": ..., "lambda_name": ..., "lambda_type": "standalone", "last_update_time": ..., "version": 1, "workers": 1 }
Get list by id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getList
- Parameters:
listId (
str
) – list idaccountIdFilter (
Optional
[str
]) – account id to get list
- Returns:
body contains json with info about list.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> response = client.getList(listId=listId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "last_update_time": ..., "list_id": ..., "user_data": "strange_persons" }
Get lists by filters
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getLists
- Parameters:
userData (
Optional
[str
]) – Find all objects with user_data which is “like” this parameteruserDataEq (
Optional
[str
]) – user data, case sensitivelistIds (
Optional
[List
[str
]]) – list idslistIdLt (
Optional
[str
]) – upper bound of list idlistIdGte (
Optional
[str
]) – lower bound of list idcreateTimeLt (
Optional
[str
]) – upper bound of list create timecreateTimeGte (
Optional
[str
]) – lower bound of list create timelastUpdateTimeLt (
Optional
[str
]) – upper bound of list last update timelastUpdateTimeGte (
Optional
[str
]) – lower bound of list last update timepage (
int
) – The number of page (>= 1)pageSize (
int
) – The numbers of items on page [ 1 .. 100 ]accountIdFilter (
Optional
[str
]) – account id to get lists
- Returns:
body contains json with lists that were found
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> response = client.getLists(listIds=[listId]) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "lists": [ { "account_id": ..., "create_time": ..., "last_update_time": ..., "list_id": ..., "user_data": "strange_persons" } ] }
Get lists count by filters
- Parameters:
userData (
Optional
[str
]) – Find all objects with user_data which is “like” this parameterlistIds (
Optional
[List
[str
]]) – list idslistIdLt (
Optional
[str
]) – upper bound of list idlistIdGte (
Optional
[str
]) – lower bound of list iduserDataEq (
Optional
[str
]) – user datacreateTimeLt (
Optional
[str
]) – upper bound of list create timecreateTimeGte (
Optional
[str
]) – lower bound of list create timelastUpdateTimeLt (
Optional
[str
]) – upper bound of list last update timelastUpdateTimeGte (
Optional
[str
]) – lower bound of list last update timeaccountIdFilter (
Optional
[str
]) – account id to count lists
- Returns:
body contains json with count of lists that were found
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> response = client.getListsCount(createTimeGte="2022-03-21T09:11:41.674Z") >>> print(response.statusCode) 200 >>> print(response.json) {'lists_count': ...}
Get an object by id
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getObject
- Parameters:
objectId (
str
) – object idaccountIdFilter (
Optional
[str
]) – account id to get object
- Returns:
body contains object or string.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> objectBody = "1,2,3" >>> contentType = "text/plain" >>> objectId = client.saveObject(objectBody=objectBody, contentType=contentType, raiseError=True).json[ ... "object_id" ... ] >>> response = client.getObject(objectId=objectId) >>> print(response.statusCode) 200 >>> print(response.text) 1,2,3
Get plugins of luna service
- Parameters:
lunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$asyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultraiseError (
Optional
[bool
]) – if request fails, LunaApiException is raisedtotalTimeout (
Optional
[Real
]) – request processing timeout in seconds.connectTimeout (
Optional
[Real
]) – connection timeout seconds.sockReadTimeout (
Optional
[Real
]) – socket read timeoutsockConnectTimeout (
Optional
[Real
]) – socket connect timeout
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with list of plugins.
- Return type:
class
Get final request id.
- Parameters:
lunaRequestId (
Optional
[str
]) – Luna-Request-Id as function argument. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$- Return type:
Optional
[str
]- Returns:
- None if both lunaRequestId and self.lunaRequestId are None or
lunaRequestId or self.lunaRequestId
Get final request id.
- Parameters:
lunaRequestId (
Optional
[str
]) – Luna-Request-Id as function argument. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$- Return type:
Dict
[str
,str
]- Returns:
- empty dict if both lunaRequestId and self.lunaRequestId are None or
return dict with lunaRequestId or self.lunaRequestId
Get restream
- Parameters:
streamId (
str
) – stream idrestreamType (
Literal
['hls'
]) – restream typerestreamQuality (
Optional
[int
]) – restream quality
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with stream will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="stream", ... reference="rtsp://dev02:5554/tenvision_1", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> response = client.getRestream(streamId=streamId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "quality": ..., "token": ..., "type": ..., "url": ... }
Get schedule by id
- Parameters:
scheduleId (
int
) – schedule idaccountIdFilter (
Optional
[str
]) – account id to get schedules
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with response.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> contentKwargs=dict( ... filters=FaceFilters(accountId=client.accountId), createList=1 ... ) >>> response = client.createSchedule( ... accountId=client.accountId, ... taskType=1, ... contentKwargs=contentKwargs, ... cron="5 4 * * *", ... cronTz="utc", ... startImmediately=False, ... raiseError=True ... ) >>> scheduleId = response.json["schedule_id"] >>> response = client.getSchedule( ... scheduleId=scheduleId ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "last_update_time": ..., "next_run_time": ..., "schedule_id": ..., "status": "running", "task": { "content": { "create_list": 1, "filters": { "account_id": ... }, "objects_type": "faces" }, "notification_policy": { "enable": 0, "subtask_callbacks": [], "task_callbacks": [] }, "result_storage_policy": {}, "task_type": 1 }, "task_ids": [], "trigger": { "cron": "5 4 * * *", "cron_timezone": "utc" } }
Create schedule template
- Parameters:
accountId (
Optional
[str
]) – account idscheduleId (
str
) – schedule id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.video_manager.http_objs import ScheduleTemplate >>> scheduleId = client.createScheduleTemplate( ... scheduleTemplate=ScheduleTemplate( ... startTime="2025-05-01T00:00:00.000000+00:00", ... endTime="2025-05-16T00:00:00.000000+00:00", ... cron="5 4 * * 4", ... duration=11, ... durationType="minute", ... ), ... raiseError=True, ... ).json["schedule_id"] >>> response = client.getScheduleTemplate(scheduleId=scheduleId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "cron": "5 4 * * 4", "cron_timezone": "local", "description": null, "duration": 11, "duration_type": "minute", "end_time": "2025-05-16T03:00:00.000000+03:00", "intervals": [ { "end_time": ..., "start_time": ... }, { "end_time": ... "start_time": ... }, { "end_time": ..., "start_time": ... } ], "schedule_id": ..., "start_time": "2025-05-01T03:00:00.000000+03:00" }
Create schedule template
- Parameters:
accountId (
Optional
[str
]) – account idscheduleId (
str
) – schedule id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.video_manager.http_objs import ScheduleTemplate >>> scheduleId = client.createScheduleTemplate( ... scheduleTemplate=ScheduleTemplate( ... startTime="2025-05-01T00:00:00.000000+00:00", ... endTime="2025-05-16T00:00:00.000000+00:00", ... cron="5 4 * * 4", ... duration=11, ... durationType="minute", ... ), ... raiseError=True, ... ).json["schedule_id"] >>> response = client.getScheduleTemplateIntervals(scheduleId=scheduleId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "intervals": [ { "end_time": ..., "start_time": ... }, { "end_time": ..., "start_time": ... }, { "end_time": ..., "start_time": ... } ] }
Get schedule templates
- Parameters:
accountId (
Optional
[str
]) – account idscheduleIds (
Optional
[List
[str
]]) – schedule idspage (
int
) – pagepageSize (
int
) – page size
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.video_manager.http_objs import ScheduleTemplate >>> scheduleId = client.createScheduleTemplate( ... scheduleTemplate=ScheduleTemplate( ... startTime="2025-05-01T00:00:00.000000+00:00", ... endTime="2025-05-16T00:00:00.000000+00:00", ... cron="5 4 * * 4", ... duration=11, ... durationType="minute", ... ), ... raiseError=True, ... ).json["schedule_id"] >>> response = client.getScheduleTemplates(scheduleIds=[scheduleId]) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "schedules": [ { "account_id": ..., "create_time": ..., "cron": "5 4 * * 4", "cron_timezone": "local", "description": null, "duration": 11, "duration_type": "minute", "end_time": "2025-05-16T03:00:00.000000+03:00", "intervals": [ { "end_time": ..., "start_time": ... }, { "end_time": ... "start_time": ... }, { "end_time": ..., "start_time": ... } ], "schedule_id": ..., "start_time": "2025-05-01T03:00:00.000000+03:00" } ] }
Get schedules with filters
- Parameters:
createTimeLt (
Optional
[str
]) – schedule create time upper excluding boundcreateTimeGte (
Optional
[str
]) – schedule create time lower including boundtaskType (
Optional
[int
]) – task type filteraccountIdFilter (
Optional
[str
]) – account id to get schedulespage (
Optional
[int
]) – pagepageSize (
Optional
[int
]) – page size
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with response.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> contentKwargs=dict( ... filters=FaceFilters(accountId=client.accountId), createList=1 ... ) >>> response = client.createSchedule( ... accountId=client.accountId, ... taskType=1, ... contentKwargs=contentKwargs, ... cron="5 4 * * *", ... cronTz="utc", ... startImmediately=False, ... raiseError=True ... ) >>> scheduleId = response.json["schedule_id"] >>> response = client.getSchedules( ... accountIdFilter=client.accountId ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) [ { "account_id": ..., "create_time": ..., "last_update_time": ..., "next_run_time": ..., "schedule_id": ..., "status": "running", "task": { "content": { "create_list": 1, "filters": { "account_id": ... }, "objects_type": "faces" }, "notification_policy": { "enable": 0, "subtask_callbacks": [], "task_callbacks": [] }, "result_storage_policy": {}, "task_type": 1 }, "task_ids": [], "trigger": { "cron": "5 4 * * *", "cron_timezone": "utc" } } ]
Get OpenApi documentation of luna service
- Parameters:
acceptHeaders (
Optional
[dict
]) – Accept request header. By default Accept-Type is text/html.lunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$asyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultraiseError (
Optional
[bool
]) – if request fails, LunaApiException is raisedtotalTimeout (
Optional
[Real
]) – request processing timeout in seconds.connectTimeout (
Optional
[Real
]) – connection timeout seconds.sockReadTimeout (
Optional
[Real
]) – socket read timeoutsockConnectTimeout (
Optional
[Real
]) – socket connect timeout
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return HTML or YAML as bytes.
- Return type:
class
Get standard headers (“LUNA-Account-Id”, “LUNA-Request-Id”) for request. :type lunaRequestId:
Optional
[str
] :param lunaRequestId: Luna request Id . Pattern:^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$
- Parameters:
accountId (
Optional
[str
]) – account id. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$login (
Optional
[str
]) – loginpassword (
Optional
[str
]) – passwordtoken (
Optional
[str
]) – token
- Return type:
Dict
[str
,str
]- Returns:
dict with corresponding headers if values are not None
Get stream by id.
- Parameters:
streamId (
str
) – stream idaccountId (
Optional
[str
]) – account idtargets (
Optional
[str
]) – targets to get streams
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with stream will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> response = client.getStream(streamId=streamId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "analytics": [ { "analytic_name": "doctests_analytic", "autorestart": { "attempt_count": 10, "current_attempt": 0, "delay": 60, "last_attempt_time": null, "restart": 0, "status": "disabled" }, "parameters": {}, "status": ... } ], "create_time": ..., "data": { "behavior_parameters": ..., "downloadable": false, "ffmpeg_kwargs": ..., "fps": ..., "orientation_strategy": "static", "pts": { "start_time": 0.0 }, "reference": "http://reference", "rotation": 0, "timeout": ..., "timestamp_source": "auto", "type": "videofile" }, "description": "test stream description", "groups": [], "last_error": null, "location": { "area": null, "city": null, "district": null, "geo_position": null, "house_number": null, "street": null }, "name": "test_stream", "notification_policy": { "enable": 0, "stream_callbacks": [] }, "source": null, "splittable": 0, "status": 0, "stream_id": ..., "version": 1 }
Get stream analytics working intervals
- Parameters:
accountId (
Optional
[str
]) – account idstreamId (
str
) – stream idanalyticIdx (
int
) – index of analytics of interestintervalsIdx (
int
) – index of intervals of interest
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic, Schedule, Interval >>> streamId = client.createStream( ... streamType="stream", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic( ... name=ANALYTIC_NAME, ... schedules=[Schedule(intervals=[ ... Interval(startTime="2025-05-01T01:16:00Z", endTime="2026-05-01T01:16:00Z")]) ... ])], ... raiseError=True, ... ).json["stream_id"] >>> response = client.getStreamAnalyticsWorkingIntervals( ... streamId=streamId, analyticIdx=0, intervalsIdx=0, raiseError=True ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "intervals": [ { "end_time": ..., "start_time": ... } ] }
Get stream by filters.
- Parameters:
accountId (
Optional
[str
]) – account idstreamIds (
Optional
[List
[str
]]) – stream idsstreamIdGte (
Optional
[str
]) – stream id lower included boundstreamIdLt (
Optional
[str
]) – stream id upper excluded boundstreamNames (
Optional
[List
[str
]]) – stream namesreference (
Optional
[str
]) – stream referencestatuses (
Optional
[List
[int
]]) – stream current status valuescreateTimeGte (
Optional
[str
]) – stream create time lower including boundcreateTimeLt (
Optional
[str
]) – stream create time upper excluding boundgroupName (
Optional
[str
]) – group namegroupId (
Optional
[str
]) – group idsources (
Optional
[List
[str
]]) – additional stream informationsplittable (
Optional
[int
]) – whether stream is splittableorder (
Optional
[Literal
['asc'
,'desc'
]]) – sorting orderpage (
Optional
[int
]) – page numberpageSize (
Optional
[int
]) – page sizetargets (
Optional
[str
]) – targets to get streams
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with streams will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> response = client.getStreams( ... streamIds=[streamId], ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "streams": [ { "account_id": ..., "analytics": [ { "analytic_name": "doctests_analytic", "autorestart": { "attempt_count": 10, "current_attempt": 0, "delay": 60, "last_attempt_time": null, "restart": 0, "status": "disabled" }, "parameters": {}, "status": ... } ], "create_time": ..., "data": { "behavior_parameters": ..., "downloadable": false, "ffmpeg_kwargs": ..., "fps": ..., "orientation_strategy": "static", "pts": { "start_time": 0.0 }, "reference": "http://reference", "rotation": 0, "timeout": ..., "timestamp_source": "auto", "type": "videofile" }, "description": "test stream description", "groups": [], "last_error": null, "location": { "area": null, "city": null, "district": null, "geo_position": null, "house_number": null, "street": null }, "name": "test_stream", "notification_policy": { "enable": 0, "stream_callbacks": [] }, "source": null, "splittable": 0, "status": 0, "stream_id": ..., "version": 1 } ] }
Get streams logs
- Parameters:
accountId (
Optional
[str
]) – account_idstreamIds (
Optional
[List
[str
]]) – stream idsstatuses (
Optional
[List
[int
]]) – streams statusestargets (
Optional
[List
[str
]]) – log targetslogTimeLt (
Optional
[str
]) – log time lower excluded boundarylogTimeGte (
Optional
[str
]) – log time upper included boundaryanalyticIndexes (
Optional
[List
[int
]]) – list of analytics indexes of interestpage (
Optional
[int
]) – pagepageSize (
Optional
[int
]) – page size
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> response = client.getStreamsLogs( ... streamIds=[streamId], ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "logs": [] }
Get task by id.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getTask
- Parameters:
taskId (
int
) – task idaccountIdFilter (
Optional
[str
]) – account id to get task
- Returns:
body contains json with task info.
- Return type:
LunaResponse
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> faceId = client.createFace( ... externalId="14159261415926", lists=[listId], userData="clustering_faces", raiseError=True ... ).json["face_id"] >>> faceFilters = FaceFilters( ... externalIds=["14159261415926"], ... listId=listId, ... faceIds=[faceId], ... userData="clustering_faces", ... ) >>> taskId = client.createClusteringTask(filters=faceFilters, raiseError=True).json["task_id"] >>> time.sleep(1) >>> response = client.getTask(taskId=taskId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "content": { "descriptor": { "type": "face" }, "filters": { "external_ids": [ "14159261415926" ], "face_ids": [...], "list_id": ..., "user_data": "clustering_faces" }, "limit": ..., "objects_type": "faces", "threshold": ... }, "count_task_parts_all": 1, "count_task_parts_done": 1, "create_time": ..., "description": "", "end_time": ..., "last_update_time": ..., "notification_policy": { "enable": 0, "subtask_callbacks": [], "task_callbacks": [] }, "result_id": ..., "result_storage_policy": {}, "task_id": ..., "task_status": 5, "task_type": 2 }
Get task errors by task id.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getErrors
- Parameters:
taskId (
int
) – task idpage (
Optional
[int
]) – pagepageSize (
Optional
[int
]) – page sizeaccountIdFilter (
Optional
[str
]) – account id to get task errors
- Returns:
body contains json with info about errors of a task by the task ID.
- Return type:
LunaResponse
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> unknownFaceId = "668ea250-9341-484f-a103-8dda6994a654" >>> faceFilters = FaceFilters(faceIds=[unknownFaceId]) >>> taskId = client.createClusteringTask( ... filters=faceFilters, descriptorTypeFilter="face", raiseError=True ... ).json["task_id"] >>> time.sleep(1) >>> response = client.getTaskErrors(taskId=taskId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "errors": [ { "additional_info": ..., "description": "Objects not found", "detail": "Objects for clustering not found (empty set)", "error_code": 28010, "error_id": ..., "error_time": ..., "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-28010", "subtask_id": ..., "task_id": ... } ] }
Get task notification policy by task id.
- Parameters:
taskId (
int
) – task idaccountIdFilter (
Optional
[str
]) – account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with response.
- Return type:
class
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> faceId = client.createFace( ... externalId="14159261415927", lists=[listId], userData="clustering_faces", raiseError=True ... ).json["face_id"] >>> faceFilters = FaceFilters( ... externalIds=["14159261415927"], ... listId=listId, ... faceIds=[faceId], ... userData="clustering_faces", ... ) >>> taskId = client.createClusteringTask(filters=faceFilters, raiseError=True).json["task_id"] >>> time.sleep(1) >>> response = client.getTaskNotificationPolicy(taskId=taskId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "enable": 0, "subtask_callbacks": [], "task_callbacks": [] }
Get task result by task id. Optional you can set, that task must belong to account.
- Parameters:
taskId (
int
) – task idaccountIdFilter (
Optional
[str
]) – account id to get task result
- Returns:
body contains json with task result.
- Return type:
LunaResponse
>>> import json >>> import time >>> from testData.resources import FACE_WARP >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample( ... sampleIds=[sampleId], extractBasicAttributes=1, raiseError=True ... ).json[0]["attribute_id"] >>> faceId = client.createFace(attributeId=attributeId, raiseError=True).json["face_id"] >>> faceFilters = FaceFilters(faceIds=[faceId]) >>> taskId = client.createClusteringTask( ... filters=faceFilters, descriptorTypeFilter="face", raiseError=True ... ).json["task_id"] >>> time.sleep(1) >>> response = client.getTaskResult(taskId=taskId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True)) {"errors": [...], "result": {"clusters": [[...]], "total_clusters": 1, "total_objects": 1}}
Get task’s sub tasks.
- Parameters:
taskId (
int
) – task idaccountIdFilter (
Optional
[str
]) – account id to get subtasks
- Returns:
body contains json with subtasks info.
- Return type:
LunaResponse
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> faceId = client.createFace( ... externalId="14159261415926", lists=[listId], userData="clustering_faces", raiseError=True ... ).json["face_id"] >>> faceFilters = FaceFilters( ... externalIds=["14159261415926"], ... listId=listId, ... faceIds=[faceId], ... userData="clustering_faces", ... ) >>> taskId = client.createClusteringTask(filters=faceFilters, raiseError=True).json["task_id"] >>> time.sleep(1) >>> response = client.getTaskSubTasks(taskId=taskId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json["subtasks"], sort_keys=True, indent=4)) [ { "content": { "descriptor": { "type": "face" }, "filters": { "external_ids": [ "14159261415926" ], "face_ids": [...], "list_id": ..., "user_data": "clustering_faces" }, "limit": ..., "objects_type": "faces", "threshold": ... }, "create_time": ..., "end_time": ..., "result_id": ..., "subtask_id": ..., "subtask_status": 4, "task_id": ... } ]
Get tasks with filters.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getTask
- Parameters:
taskIds (
Optional
[List
[int
]]) – task idscreateTimeLt (
Optional
[str
]) – task create time upper excluding boundcreateTimeGte (
Optional
[str
]) – task create time lower including boundendTimeLt (
Optional
[str
]) – task end time upper excluding boundendTimeGte (
Optional
[str
]) – task end time lower including boundtaskType (
Optional
[int
]) – task type filtertaskStatus (
Optional
[int
]) – task status filterpage (
Optional
[int
]) – pagepageSize (
Optional
[int
]) – page sizeaccountIdFilter (
Optional
[str
]) – account id to get tasksscheduleId (
Optional
[int
]) – schedule id filter
- Returns:
body contains json with tasks info.
- Return type:
LunaResponse
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> faceId = client.createFace( ... externalId="14159261415926", lists=[listId], userData="clustering_faces", raiseError=True ... ).json["face_id"] >>> faceFilters = FaceFilters( ... externalIds=["14159261415926"], ... listId=listId, ... faceIds=[faceId], ... userData="clustering_faces", ... ) >>> taskId = client.createClusteringTask( ... threshold=0.5, filters=faceFilters, raiseError=True ... ).json["task_id"] >>> time.sleep(1) >>> response = client.getTasks(taskType=2, taskStatus=5, taskIds=[taskId]) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json["tasks"], sort_keys=True, indent=4)) [ { "account_id": ..., "content": { "descriptor": { "type": "face" }, "filters": { "external_ids": [ "14159261415926" ], "face_ids": [...], "list_id": ..., "user_data": "clustering_faces" }, "limit": ..., "objects_type": "faces", "threshold": 0.5 }, "count_task_parts_all": 1, "count_task_parts_done": 1, "create_time": ..., "description": "", "end_time": ..., "last_update_time": ..., "notification_policy": { "enable": 0, "subtask_callbacks": [], "task_callbacks": [] }, "result_id": ..., "result_storage_policy": {}, "task_id": ..., "task_status": 5, "task_type": 2 } ]
Get tasks count with filters.
- Parameters:
taskIds (
Optional
[List
[int
]]) – task idscreateTimeLt (
Optional
[str
]) – task create time upper excluding boundcreateTimeGte (
Optional
[str
]) – task create time lower including boundendTimeLt (
Optional
[str
]) – task end time upper excluding boundendTimeGte (
Optional
[str
]) – task end time lower including boundtaskType (
Optional
[int
]) – task type filtertaskStatus (
Optional
[int
]) – task status filteraccountIdFilter (
Optional
[str
]) – account id to get tasks countscheduleId (
Optional
[str
]) – schedule id filter
- Returns:
body contains json with tasks count.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> faceId = client.createFace( ... externalId="14159261415926", lists=[listId], userData="clustering_faces", raiseError=True ... ).json["face_id"] >>> faceFilters = FaceFilters( ... externalIds=["14159261415926"], ... listId=listId, ... faceIds=[faceId], ... userData="clustering_faces", ... ) >>> taskId = client.createClusteringTask(filters=faceFilters, raiseError=True).json["task_id"] >>> response = client.getTasksCount(taskStatus=5) >>> print(response.statusCode) 200 >>> print(response.json) {'count': ...} >>> response = client.getTasksCount(taskIds=[taskId]) >>> print(response.json) {'count': 1}
Get token.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getToken
- Parameters:
tokenId (
str
) – token idaccountIdFilter (
Optional
[str
]) – account id to get token
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with token will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.accounts.http_objs import TokenPermissions >>> from uuid import uuid4 >>> import json >>> >>> tokenId = client.createToken(tokenPermissions=TokenPermissions(), raiseError=True).json["token_id"] >>> response = client.getToken(tokenId=tokenId) >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "description": "", "expiration_time": null, "last_update_time": ..., "permissions": { "account": [], "attribute": [], "body_sample": [], "emit_events": { "allowed": 1, "black_list": null, "white_list": null }, "event": [], "face": [], "face_sample": [], "handler": [], "image": [], "lambdas": [], "list": [], "object": [], "resources": [], "task": [], "token": [], "verifier": [], "verify": { "allowed": 1, "black_list": null, "white_list": null }, "video_agent": [], "video_analytic": [], "video_group": [], "video_stream": [] }, "token": ..., "token_id": ..., "visibility_area": "all" }
Get tokens.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/getTokens
- Parameters:
page (
int
) – page, default 1pageSize (
int
) – page size, default 10accountIdFilter (
Optional
[str
]) – account id to get tokenscreateTimeLt (
Optional
[str
]) – upper bound for token create_timecreateTimeGte (
Optional
[str
]) – lower bound for token create_time
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with tokens will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.accounts.http_objs import TokenPermissions >>> from uuid import uuid4 >>> import json >>> >>> _ = client.createToken(tokenPermissions=TokenPermissions(), raiseError=True) >>> response = client.getTokens(pageSize=1) >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "tokens": [ { "account_id": ..., "create_time": ..., "description": "", "expiration_time": null, "last_update_time": ..., "permissions": { "account": [], "attribute": [], "body_sample": [], "emit_events": { "allowed": 1, "black_list": null, "white_list": null }, "event": [], "face": [], "face_sample": [], "handler": [], "image": [], "lambdas": [], "list": [], "object": [], "resources": [], "task": [], "token": [], "verifier": [], "verify": { "allowed": 1, "black_list": null, "white_list": null }, "video_agent": [], "video_analytic": [], "video_group": [], "video_stream": [] }, "token": ..., "token_id": ..., "visibility_area": "all" } ] }
Get final totalTimeout.
- Parameters:
totalTimeout (
Optional
[Real
]) – request’s processing timeout in seconds.- Return type:
Real
- Returns:
request timeout seconds.
Get verifier
- Parameters:
verifierId (
str
) – verifier idaccountIdFilter (
Optional
[str
]) – account id to get verifier
- Returns:
body contains json with verifier info.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> verifierId = client.createVerifier( ... description="Happy_persons", policies=policies, raiseError=True ... ).json["verifier_id"] >>> response = client.getVerifier(verifierId=verifierId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "description": "Happy_persons", "last_update_time": ..., "policies": { "detect_policy": { "deepfake_states": null, "detect_landmarks68": 0, "estimate_deepfake": { "estimate": 0, "mode": 2, "real_threshold": 0.5 }, "estimate_emotions": 1, "estimate_eyes_attributes": 0, "estimate_face_occlusion": { "estimate": 0, "eye_threshold": 0.15, "forehead_threshold": 0.2, "hair_occlusion_threshold": 0.15, "lower_face_threshold": 0.2, "mouth_threshold": 0.15, "nose_threshold": 0.2, "occlusion_threshold": 0.07 }, "estimate_gaze": 0, "estimate_glasses": 0, "estimate_head_pose": 0, "estimate_liveness": { "estimate": 0, "liveness_threshold": 0.5, "quality_threshold": 0.5 }, "estimate_mask": 0, "estimate_mouth_attributes": 0, "estimate_quality": 0, "extract_exif": 0, "face_occlusion_states": null, "face_quality": { "checks": { "aspect_ratio": { "estimate": 1, "threshold": { "max": 0.8, "min": 0.74 } }, "background_lightness": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.2 } }, "background_uniformity": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.5 } }, "blurriness_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.61 } }, "dark_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.5 } }, "dynamic_range": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.5 } }, "eye_distance": { "estimate": 1, "threshold": { "min": 90.0 } }, "eyebrows_state": { "estimate": 1, "threshold": [ "neutral" ] }, "face_color_type": { "estimate": 1, "threshold": [ "color" ] }, "face_height": { "estimate": 1, "threshold": { "min": 180 } }, "face_occlusion": { "estimate": 1, "threshold": 0 }, "face_width": { "estimate": 1, "threshold": { "min": 180 } }, "forehead_occlusion": { "estimate": 1, "threshold": 0 }, "gaze_pitch": { "estimate": 1, "threshold": { "max": 5.0, "min": -5.0 } }, "gaze_yaw": { "estimate": 1, "threshold": { "max": 5.0, "min": -5.0 } }, "glasses": { "estimate": 1, "threshold": [ "no_glasses", "eyeglasses" ] }, "head_height": { "estimate": 1, "threshold": { "max": 0.9, "min": 0.6 } }, "head_horizontal_center": { "estimate": 1, "threshold": { "max": 0.55, "min": 0.45 } }, "head_pitch": { "estimate": 1, "threshold": { "max": 5.0, "min": -5.0 } }, "head_roll": { "estimate": 1, "threshold": { "max": 8.0, "min": -8.0 } }, "head_vertical_center": { "estimate": 1, "threshold": { "max": 0.5, "min": 0.3 } }, "head_width": { "estimate": 1, "threshold": { "max": 0.75, "min": 0.5 } }, "head_yaw": { "estimate": 1, "threshold": { "max": 5.0, "min": -5.0 } }, "headwear_type": { "estimate": 1, "threshold": [ "none" ] }, "illumination_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.3 } }, "illumination_uniformity": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.5 } }, "image_format": { "estimate": 1, "threshold": [ "JPEG", "JPEG2000", "PNG" ] }, "image_height": { "estimate": 1, "threshold": { "max": 1080, "min": 180 } }, "image_modification": { "estimate": 1, "threshold": 0 }, "image_size": { "estimate": 1, "threshold": { "max": 2097152, "min": 5120 } }, "image_width": { "estimate": 1, "threshold": { "max": 1920, "min": 180 } }, "indent_left": { "estimate": 1, "threshold": { "min": 20 } }, "indent_lower": { "estimate": 1, "threshold": { "min": 20 } }, "indent_right": { "estimate": 1, "threshold": { "min": 20 } }, "indent_upper": { "estimate": 1, "threshold": { "min": 20 } }, "left_eye": { "estimate": 1, "threshold": [ "open" ] }, "light_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.57 } }, "lower_face_occlusion": { "estimate": 1, "threshold": 0 }, "mouth_occluded": { "estimate": 1, "threshold": { "max": 0.5, "min": 0.0 } }, "mouth_open": { "estimate": 1, "threshold": { "max": 0.5, "min": 0.0 } }, "mouth_smiling": { "estimate": 1, "threshold": { "max": 0.5, "min": 0.0 } }, "natural_light": { "estimate": 1, "threshold": 1 }, "nose_occlusion": { "estimate": 1, "threshold": 0 }, "radial_distortion": { "estimate": 1, "threshold": 0 }, "red_eyes": { "estimate": 1, "threshold": 0 }, "right_eye": { "estimate": 1, "threshold": [ "open" ] }, "shoulders_position": { "estimate": 1, "threshold": [ "parallel" ] }, "smile_properties": { "estimate": 1, "threshold": [ "none" ] }, "specularity_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.3 } } }, "estimate": 0, "filter": 0 }, "liveness_states": null, "mask_states": null, "multiface_policy": 1, "pitch_threshold": null, "roll_threshold": null, "yaw_threshold": null }, "extract_policy": { "extract_basic_attributes": 1, "fd_score_threshold": 0.0 }, "storage_policy": { "attribute_policy": { "store_attribute": 1 }, "face_sample_policy": { "store_sample": 1, "ttl": null } }, "verification_threshold": 0.5 }, "verifier_id": ..., "version": 0 }
Get verifiers by filters
- Parameters:
description (
Optional
[str
]) – verifier description (“like” parameter)page (
int
) – The number of pagepageSize (
int
) – The numbers of items on pageaccountIdFilter (
Optional
[str
]) – account id to get verifiers
- Returns:
body contains json with verifiers info
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> response = client.createVerifier(description="Happy_persons", policies=policies, raiseError=True) >>> response = client.getVerifiers(description="Happy_persons", pageSize=1) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) [ { "account_id": ..., "create_time": ..., "description": "Happy_persons", "last_update_time": ..., "policies": { "detect_policy": { "deepfake_states": null, "detect_landmarks68": 0, "estimate_deepfake": { "estimate": 0, "mode": 2, "real_threshold": 0.5 }, "estimate_emotions": 1, "estimate_eyes_attributes": 0, "estimate_face_occlusion": { "estimate": 0, "eye_threshold": 0.15, "forehead_threshold": 0.2, "hair_occlusion_threshold": 0.15, "lower_face_threshold": 0.2, "mouth_threshold": 0.15, "nose_threshold": 0.2, "occlusion_threshold": 0.07 }, "estimate_gaze": 0, "estimate_glasses": 0, "estimate_head_pose": 0, "estimate_liveness": { "estimate": 0, "liveness_threshold": 0.5, "quality_threshold": 0.5 }, "estimate_mask": 0, "estimate_mouth_attributes": 0, "estimate_quality": 0, "extract_exif": 0, "face_occlusion_states": null, "face_quality": { "checks": { "aspect_ratio": { "estimate": 1, "threshold": { "max": 0.8, "min": 0.74 } }, "background_lightness": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.2 } }, "background_uniformity": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.5 } }, "blurriness_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.61 } }, "dark_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.5 } }, "dynamic_range": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.5 } }, "eye_distance": { "estimate": 1, "threshold": { "min": 90.0 } }, "eyebrows_state": { "estimate": 1, "threshold": [ "neutral" ] }, "face_color_type": { "estimate": 1, "threshold": [ "color" ] }, "face_height": { "estimate": 1, "threshold": { "min": 180 } }, "face_occlusion": { "estimate": 1, "threshold": 0 }, "face_width": { "estimate": 1, "threshold": { "min": 180 } }, "forehead_occlusion": { "estimate": 1, "threshold": 0 }, "gaze_pitch": { "estimate": 1, "threshold": { "max": 5.0, "min": -5.0 } }, "gaze_yaw": { "estimate": 1, "threshold": { "max": 5.0, "min": -5.0 } }, "glasses": { "estimate": 1, "threshold": [ "no_glasses", "eyeglasses" ] }, "head_height": { "estimate": 1, "threshold": { "max": 0.9, "min": 0.6 } }, "head_horizontal_center": { "estimate": 1, "threshold": { "max": 0.55, "min": 0.45 } }, "head_pitch": { "estimate": 1, "threshold": { "max": 5.0, "min": -5.0 } }, "head_roll": { "estimate": 1, "threshold": { "max": 8.0, "min": -8.0 } }, "head_vertical_center": { "estimate": 1, "threshold": { "max": 0.5, "min": 0.3 } }, "head_width": { "estimate": 1, "threshold": { "max": 0.75, "min": 0.5 } }, "head_yaw": { "estimate": 1, "threshold": { "max": 5.0, "min": -5.0 } }, "headwear_type": { "estimate": 1, "threshold": [ "none" ] }, "illumination_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.3 } }, "illumination_uniformity": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.5 } }, "image_format": { "estimate": 1, "threshold": [ "JPEG", "JPEG2000", "PNG" ] }, "image_height": { "estimate": 1, "threshold": { "max": 1080, "min": 180 } }, "image_modification": { "estimate": 1, "threshold": 0 }, "image_size": { "estimate": 1, "threshold": { "max": 2097152, "min": 5120 } }, "image_width": { "estimate": 1, "threshold": { "max": 1920, "min": 180 } }, "indent_left": { "estimate": 1, "threshold": { "min": 20 } }, "indent_lower": { "estimate": 1, "threshold": { "min": 20 } }, "indent_right": { "estimate": 1, "threshold": { "min": 20 } }, "indent_upper": { "estimate": 1, "threshold": { "min": 20 } }, "left_eye": { "estimate": 1, "threshold": [ "open" ] }, "light_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.57 } }, "lower_face_occlusion": { "estimate": 1, "threshold": 0 }, "mouth_occluded": { "estimate": 1, "threshold": { "max": 0.5, "min": 0.0 } }, "mouth_open": { "estimate": 1, "threshold": { "max": 0.5, "min": 0.0 } }, "mouth_smiling": { "estimate": 1, "threshold": { "max": 0.5, "min": 0.0 } }, "natural_light": { "estimate": 1, "threshold": 1 }, "nose_occlusion": { "estimate": 1, "threshold": 0 }, "radial_distortion": { "estimate": 1, "threshold": 0 }, "red_eyes": { "estimate": 1, "threshold": 0 }, "right_eye": { "estimate": 1, "threshold": [ "open" ] }, "shoulders_position": { "estimate": 1, "threshold": [ "parallel" ] }, "smile_properties": { "estimate": 1, "threshold": [ "none" ] }, "specularity_quality": { "estimate": 1, "threshold": { "max": 1.0, "min": 0.3 } } }, "estimate": 0, "filter": 0 }, "liveness_states": null, "mask_states": null, "multiface_policy": 1, "pitch_threshold": null, "roll_threshold": null, "yaw_threshold": null }, "extract_policy": { "extract_basic_attributes": 1, "fd_score_threshold": 0.0 }, "storage_policy": { "attribute_policy": { "store_attribute": 1 }, "face_sample_policy": { "store_sample": 1, "ttl": null } }, "verification_threshold": 0.5 }, "verifier_id": ..., "version": 0 } ]
Count verifiers that satisfy the filters
- Parameters:
description (
Optional
[str
]) – verifier description (“like” parameter)accountIdFilter (
Optional
[str
]) – account id to count verifiers
- Returns:
body contains json with verifier count
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> response = client.createVerifier(description="Happy_persons", policies=policies, raiseError=True) >>> response = client.getVerifiersCount(description="Happy_persons") >>> print(response.statusCode) 200 >>> print(response.json) {'verifiers_count': ...}
Get version of luna service
- Parameters:
lunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$asyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultraiseError (
Optional
[bool
]) – if request fails, LunaApiException is raisedtotalTimeout (
Optional
[Real
]) – request processing timeout in seconds.connectTimeout (
Optional
[Real
]) – connection timeout seconds.sockReadTimeout (
Optional
[Real
]) – socket read timeoutsockConnectTimeout (
Optional
[Real
]) – socket connect timeout
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
Get video task data
- Parameters:
taskId (
str
) – task id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with task status, progress or result url.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.public.sdk import VideoSDKInput,VideoSDKAnalytics,VideoSDKProperties,DeferredTask >>> from luna3.public.sdk import PeopleCountAnalyticsParams, Rate, StoragePolicy >>> url ="https://lunatestttttt.s3.eu-central-1.amazonaws.com/video_test.avi" >>> params = PeopleCountAnalyticsParams(rate=Rate(unit="second", period=1), probeCount=2) >>> analytics = [VideoSDKAnalytics(name="people_count", targets=[], parameters=params)] >>> deferred = DeferredTask(1, StoragePolicy("luna_image_store")) >>> response = client.videosdk(inputData=VideoSDKInput(VideoSDKProperties(url), analytics, deferred)) >>> taskId = response.json["task_id"] >>> response = client.getVideoTask(taskId) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "progress": null, "status": ..., "task_id": ... }
Update lambda
- Parameters:
accountId – account id
archive (
Optional
[bytes
]) – archive file byteslambdaName (
Optional
[str
]) – name of lambdadescription (
Optional
[str
]) – descriptionworkers (
Optional
[int
]) – count of lambda workersarchiveTtl (
Optional
[Literal
[-1
,1
,2
,3
,4
,5
,6
,7
,14
,30
,60
,90
,180
,365
]]) – ttl for lambda archiveenableGPU (
Optional
[bool
]) – whether to enable GPUpodCount (
Optional
[int
]) – count of lambda podscpuLimit (
Optional
[int
]) – cpu limit for lambda in cpu unitsramLimit (
Optional
[int
]) – ram limit for lambda in GBcpuRequest (
Optional
[int
]) – cpu request for lambda in cpu unitsramRequest (
Optional
[int
]) – ram request for lambda in GBnamespace (
Optional
[str
]) – namespaceselector (
Optional
[dict
]) – kubernetes pod node selector
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_EXPORT_ARCHIVE >>> ... response = client.importLambda(lambdaName=str(uuid4()), archive=LAMBDA_EXPORT_ARCHIVE) >>> >>> print(response.statusCode) 202
Attach or detach streams to group. Optional you can set, that group and streams must belong to account.
- Parameters:
groupId (
str
) – group identifierstreamIds (
List
[str
]) – stream idsaction (
Literal
['attach'
,'detach'
]) – attach or detachaccountId (
Optional
[str
]) – account id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> groupId = client.createGroup( ... groupName="linked_group", ... description="test group description", ... raiseError=True, ... ).json["group_id"] >>> response = client.link(groupId=groupId, streamIds=[streamId], action="attach") >>> print(response.statusCode) 204 >>> response = client.getStream(streamId=streamId, raiseError=True) >>> print(response.json["groups"] == [groupId]) True
attach/detach faces to the list
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/linkFaces
- Parameters:
listId (
str
) – list idaction (
str
) – expected action with list and faces (Enum:”attach” “detach”)faceIds (
list
) – faces for attach or detach to/from list
- Raises:
ValueError – if action parameter not in (“attach”, “detach”)
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json["face_id"] >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> response = client.linkFacesToList(listId=listId, action='attach', faceIds=[faceId]) >>> print(response.statusCode) 204 >>> response = client.linkFacesToList(listId=listId, action='detach', faceIds=[faceId]) >>> print(response.statusCode) 204
Prepare account header and make request.
- Parameters:
url (
str
) – request URLmethod (
str
) – request methodqueryParams (
Optional
[dict
]) – query parametersbody (
Union
[str
,bytes
,dict
,list
,Payload
,RequestPayload
,None
]) – request bodyheaders (
Optional
[dict
]) – headers for requestasyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultlunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$accountId (
Optional
[str
]) – account idlogin (
Optional
[str
]) – loginpassword (
Optional
[str
]) – passwordtoken (
Optional
[str
]) – token
- Returns:
structure with status code, request and decoded Luna API response body is returned.
Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/matchFaces
- Parameters:
candidates (
List
[Candidates
]) – Candidates object with info about candidatesreferences (
List
[Union
[Reference
,BinaryReference
]]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, attributes, faces)accountIdFilter (
Optional
[str
]) – account id to match facesaccept (
str
) – expected content type
- Returns:
body contains json with results of matching (failed and succeeded matches)
- Return type:
LunaResponse
>>> import json >>> from testData.resources import FACE_WARP >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> from luna3.python_matcher.match_objects import Reference >>> from luna3.python_matcher.match_objects import Candidates >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample(sampleIds=[sampleId], raiseError=True).json[0]["attribute_id"] >>> faceId = client.createFace(attributeId=attributeId, raiseError=True).json["face_id"] >>> response = client.matchFaces( ... candidates=[Candidates(FaceFilters(faceIds=[faceId]), limit=3, threshold=0.5)], ... references=[Reference("face", faceId)] ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) [ { "matches": [ { "filters": { "face_ids": [...], "origin": "faces" }, "result": [ { "face": { "account_id": ..., "avatar": "", "create_time": ..., "event_id": null, "external_id": "", "face_id": ..., "lists": [], "user_data": "" }, "similarity": 1.0 } ] } ], "reference": { "id": ..., "type": "face" } } ]
Matcher API allows to submit tasks to a service that searches for human bodies similar to a given reference(s) by matching them. A body attribute descriptor should be extracted for reference(s) and candidate(s).
The sources for references are events or binary descriptor. The sources for candidates is events.
- Parameters:
candidates (
List
[Candidates
]) – Candidates object with info about candidatesreferences (
List
[Union
[Reference
,BinaryReference
]]) – list of Reference objects. Each object has entity id and it type (possible type variants: event, sdk_descriptor, raw_descriptor)accountIdFilter (
Optional
[str
]) – account id to match bodiesaccept (
str
) – expected content type
- Returns:
body contains json with results of matching (failed and succeeded matches).
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import BODY_WARP >>> from luna3.common.http_objs import Policies, DetectPolicy, ExtractPolicy >>> from luna3.python_matcher.match_objects import EventFilters >>> from luna3.python_matcher.match_objects import Reference >>> from luna3.python_matcher.match_objects import Candidates >>> >>> detectPolicy = DetectPolicy(detectBody=1, detectFace=0) >>> extractPolicy = ExtractPolicy(extractBodyDescriptor=1, extractFaceDescriptor=0) >>> policies = Policies(detectPolicy=detectPolicy, extractPolicy=extractPolicy) >>> handlerId = client.createHandler( ... description="happy_people", policies=policies, raiseError=True ... ).json["handler_id"] >>> eventId = client.emitEvents( ... handlerId=handlerId, inputData=BODY_WARP, raiseError=True, ... ).json['events'][0]['event_id'] >>> response = client.matchBodies( ... candidates=[Candidates(EventFilters(eventIds=[eventId]), limit=1, threshold=0.5)], ... references=[Reference("event", eventId)] ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) [ { "matches": [ { "filters": { "event_ids": [...], "origin": "events" }, "result": [ { "event": { "accessories": null, "account_id": ..., "age": null, "attach_result": [], "body_basic_attributes": null, "body_detections": [ { "detect_time": ..., "detect_ts": null, "detection": { "rect": { "height": ..., "width": ..., "x": ..., "y": ... } }, "image_origin": null, "sample_id": ... } ], "create_time": ..., "deepfake": null, "emotion": null, "end_time": ..., "ethnic_group": null, "event_id": ..., "external_id": "", "face_detections": null, "face_id": null, "gender": null, "handler_id": ..., "liveness": null, "location": { "area": null, "city": null, "district": null, "geo_position": null, "house_number": null, "street": null }, "lower_body": null, "mask": null, "match_result": null, "meta": null, "source": null, "stream_id": null, "tags": null, "top_match": null, "track_id": null, "upper_body": null, "user_data": "" }, "similarity": 1.0 } ] } ], "reference": { "id": ..., "type": "event" } } ]
Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/matchFaces
- Parameters:
candidates (
List
[Candidates
]) – Candidates object with info about candidatesreferences (
List
[Union
[Reference
,BinaryReference
]]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, attributes, faces)accountIdFilter (
Optional
[str
]) – account id to match facesaccept (
str
) – expected content type
- Returns:
body contains json with results of matching (failed and succeeded matches)
- Return type:
LunaResponse
>>> import json >>> from testData.resources import FACE_WARP >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> from luna3.python_matcher.match_objects import Reference >>> from luna3.python_matcher.match_objects import Candidates >>> >>> sampleId = client.saveFaceSample(FACE_WARP, raiseError=True).json["sample_id"] >>> attributeId = client.extractAttrFromSample(sampleIds=[sampleId], raiseError=True).json[0]["attribute_id"] >>> faceId = client.createFace(attributeId=attributeId, raiseError=True).json["face_id"] >>> response = client.matchFaces( ... candidates=[Candidates(FaceFilters(faceIds=[faceId]), limit=3, threshold=0.5)], ... references=[Reference("face", faceId)] ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) [ { "matches": [ { "filters": { "face_ids": [...], "origin": "faces" }, "result": [ { "face": { "account_id": ..., "avatar": "", "create_time": ..., "event_id": null, "external_id": "", "face_id": ..., "lists": [], "user_data": "" }, "similarity": 1.0 } ] } ], "reference": { "id": ..., "type": "face" } } ]
Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.
- Parameters:
descriptorType (
str
) – base descriptor type for references and candidatesdescriptorVersion (
Optional
[int
]) – descriptor version of matchingplatCoef (
Optional
[List
[Union
[dict
,PlatCoef
]]]) – plat coefs, for normalizing matching resultscandidates (
List
[Candidates
]) – Candidates object with info about candidatesreferences (
List
[Union
[Reference
,BinaryReference
]]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, attributes, faces, raw descriptors)accountId (
Optional
[str
]) – account idaccept (
str
) – expected content type
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
Matcher raw API allows to match each candidate with each reference descriptors.
- Parameters:
candidates (
List
[BinaryReference
]) – list of BinaryReference objects for candidatesreferences (
List
[BinaryReference
]) – list of BinaryReference objects for referencesaccountIdFilter (
Optional
[str
]) – account id to match rawaccept (
str
) – expected content type
- Returns:
body contains json with results of matching for each reference.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import RawDescriptor >>> from luna3.python_matcher.match_objects import RawDescriptorReference >>> from testData.resources import DESCRIPTOR >>> >>> response = client.matchRaw( ... references=[RawDescriptorReference("raw_descriptor_references", DESCRIPTOR)], ... candidates=[RawDescriptorReference("raw_descriptor_candidates", DESCRIPTOR)], ... ) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "matches": [ { "matches": [ { "candidate_id": "raw_descriptor_candidates", "similarity": 1.0 } ], "reference_id": "raw_descriptor_references" } ] }
Patch account.
- Parameters:
newLogin (
Optional
[str
]) – account loginnewPassword (
Optional
[str
]) – account passwordnewAccountType (
Optional
[Literal
['advanced_user'
,'user'
]]) – account typenewDescription (
Optional
[str
]) – account description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse 204 status code will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from uuid import uuid4 >>> >>> response = client.patchAccount(newDescription="new description") >>> print(response.statusCode) 204
Update fields of face (user_data, external_id, attribute_id)
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/patchFace
- Parameters:
faceId (
str
) – face idexternalId (
Optional
[str
]) – user-defined external id for faceuserData (
Optional
[str
]) – user dataavatar (
Optional
[str
]) – avatar for face, references to a sample or a user-defined referenceeventId (
Optional
[str
]) – event id associated with creating the face
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json['face_id'] >>> response = client.patchFace(faceId=faceId, userData="test_data05_patched") >>> print(response.statusCode) 204
Update group description.
- Parameters:
groupId (
str
) – group iddescription (
str
) – group descriptionaccountId (
Optional
[str
]) – account_id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> groupId = client.createGroup( ... groupName="patch_group", ... description="test group description", ... raiseError=True, ... ).json["group_id"] >>> response = client.patchGroup(groupId=groupId, description="new description") >>> print(response.statusCode) 204 >>> response = client.getGroup(groupId=groupId) >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "create_time": ..., "description": "new description", "group_id": ..., "group_name": "patch_group" }
Patch stream by id.
- Parameters:
groupId (
str
) – group idaccountId (
Optional
[str
]) – account idaction (
str
) – pause or resume
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
It’s impossible to create a working doctest because the stream must be processing.
import json from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME from luna3.video_manager.http_objs import StreamAnalytic groupId = client.createGroup(
groupName=”delete_group”, description=”test group description”, raiseError=True,
).json[“group_id”] streamId = client.createStream(
streamType=”videofile”, reference=”http://reference”, name=”test_stream”, description=”test stream description”, analytics=[StreamAnalytic(name=ANALYTIC_NAME)], groupId=groupId, raiseError=True,
).json[“stream_id”] response = client.patchGroupStreams(groupId=groupId, action=”pause”) print(response.statusCode) 204
Patch lambda
- Parameters:
lambdaId (
str
) – lambda idlambdaName (
Optional
[str
]) – name of lambdadescription (
Optional
[str
]) – descriptionlambdaType (
Optional
[Literal
['standalone'
,'handlers'
,'tasks'
,'agent'
]]) – lambda type
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> newName = str(uuid4()) >>> response = client.patchLambda(lambdaId=lambdaId, lambdaName=newName) >>> print(response.statusCode) 204
Patch schedule by id
- Parameters:
scheduleId (
int
) – schedule idaction (
str
) – action for schedule
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with response.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> contentKwargs=dict( ... filters=FaceFilters(accountId=client.accountId), createList=1 ... ) >>> response = client.createSchedule( ... accountId=client.accountId, ... taskType=1, ... contentKwargs=contentKwargs, ... cron="5 4 * * *", ... cronTz="utc", ... startImmediately=False, ... raiseError=True ... ) >>> scheduleId = response.json["schedule_id"] >>> response = client.patchSchedule( ... scheduleId=scheduleId, ... action="pause" ... ) >>> print(response.statusCode) 204
Patch stream by id.
- Parameters:
streamId (
str
) – stream idaccountId (
Optional
[str
]) – account idaction (
str
) – pause or resume
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
It’s impossible to create a working doctest because the stream must be processing.
import json from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME from luna3.video_manager.http_objs import StreamAnalytic streamId = client.createStream(
streamType=”videofile”, reference=”http://reference”, name=”test_stream”, description=”test stream description”, analytics=[StreamAnalytic(name=ANALYTIC_NAME)], raiseError=True,
).json[“stream_id”] response = client.patchStream(streamId=streamId, action=”pause”) print(response.statusCode) 204
Property get plugins uri
>>> self.pluginsUri "http://127.0.0.1:5030/plugins"
Get agent streams which processing must be started
- Parameters:
agentId (
str
) – agent id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from time import sleep >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client, ACCOUNT_ID, AGENT_ID >>> response = client.postAgentStreams(agentId=AGENT_ID, accountId=ACCOUNT_ID) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "streams": [] }
Post feedback on stream
- Parameters:
agentId (
str
) – agent idstreamsInfo (
list
[StreamInfo
]) – list of stream info
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from uuid import uuid4 >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME, ACCOUNT_ID, ANALYTIC_NAME, AGENT_ID >>> from luna3.video_manager.http_objs import Agent, StreamInfo >>> response = client.postStreamsFeedback( ... agentId=AGENT_ID, ... streamsInfo=[ ... StreamInfo( ... streamId=str(uuid4()), ... status=1, ... version=1, ... time="2024-08-11T09:11:41.674Z", ... analyticIndexes=[0], ... ) ... ] ... ) >>> >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "streams": [ { "action": "stop", "stream_id": ..., "version": 1 } ] }
Liveness API allows to predict liveness for given images.
- Parameters:
images (
Union
[BinaryImage
,List
[BinaryImage
],None
]) – Single image or images list (supported formats “jpeg, png, tif, ppm, bmp”).urls (
Optional
[List
[str
]]) – list of urls with imagesmeta (
Optional
[Dict
]) –A dict with device information Fields:
os: A str, device os. Required manufacture: A str, manufacture model: A str, model
xMeta (
Optional
[Dict
]) – A dict with any additional informationaggregate (
Optional
[int
]) – Available values : 0, 1; whether to aggregate liveness estimations
- Returns:
body contains json with results of predictions (failed and succeeded predictions)
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP >>> >>> response = client.predictLiveness(images=[FACE_WARP]) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "images": [ { "error": { "desc": "Success", "detail": "Success", "error_code": 0, "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0" }, "filename": "Claudia_Schiffer_warp.jpg", "liveness": { "estimations": { "probability": ..., "quality": ... }, "prediction": ... }, "status": 1 } ] }
Proxy GET request to lambda
- Parameters:
lambdaId (
str
) – lambda idpath (
str
) – lambda uri pathheaders (
Optional
[dict
]) – request headersqueries (
Optional
[dict
]) – request queries
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
Proxy POST request to lambda
- Parameters:
lambdaId (
str
) – lambda idpath (
str
) – lambda uri pathbody (
Union
[str
,bytes
,dict
,list
,Payload
,RequestPayload
,None
]) – request bodyheaders (
Optional
[dict
]) – request headersqueries (
Optional
[dict
]) – request queries
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
Put face attributes.
- Parameters:
faceId (
str
) – face idattributeId (
Optional
[str
]) – attribute iddescriptors (
Optional
[List
[Union
[bytes
,RawDescriptor
]]]) – list of descriptors different versionsdescriptorSamples (
List
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
Optional
[dict
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
List
[str
]) – list of warp image id from which the basic attribute was extracted.
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> faceId = client.createFace(raiseError=True).json["face_id"] >>> basicAttributes = {"age": 29, "gender": 0, "ethnicity": 3} >>> response = client.putFaceAttributes(faceId=faceId, basicAttributes=basicAttributes) >>> print(response.statusCode) 204
Update schedule
- Parameters:
scheduleId (
int
) – schedule idtaskType (
int
) – type of taskcontentKwargs (
dict
) – kwargs for create contentcron (
str
) – cron stringcronTz (
Optional
[str
]) – cron timezonestartImmediately (
Optional
[bool
]) – start task immediatelycreateStopped (
Optional
[bool
]) – create task stopped schedule tasktaskNotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policy
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with schedule id.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> contentKwargs=dict( ... filters=FaceFilters(accountId=client.accountId), createList=1 ... ) >>> response = client.createSchedule( ... accountId=client.accountId, ... taskType=1, ... contentKwargs=contentKwargs, ... cron="5 4 * * *", ... cronTz="utc", ... startImmediately=False, ... raiseError=True ... ) >>> scheduleId = response.json["schedule_id"] >>> response = client.putSchedule( ... scheduleId=scheduleId, ... taskType=1, ... contentKwargs=contentKwargs, ... cron="0 * * * *", ... cronTz="utc", ... startImmediately=False, ... ) >>> print(response.statusCode) 200 >>> print(response.json) {'schedule_id': ...}
Create/replace stream analytics working intervals
- Parameters:
streamId (
str
) – stream idanalyticIdx (
int
) – index of analytics of interestintervalsIdx (
int
) – index of intervals of interestschedule (
Schedule
) – schedule object with schedule id or list of intervals
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic, Schedule, Interval >>> streamId = client.createStream( ... streamType="stream", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic( ... name=ANALYTIC_NAME, ... schedules=[Schedule(intervals=[ ... Interval(startTime="2025-05-01T01:16:00Z", endTime="2026-05-01T01:16:00Z")]) ... ])], ... raiseError=True, ... ).json["stream_id"] >>> response = client.putStreamAnalyticsWorkingIntervals( ... streamId=streamId, ... analyticIdx=0, ... intervalsIdx=0, ... schedule=Schedule(intervals=[ ... Interval(startTime="2025-05-01T01:16:00Z", endTime="2026-05-01T01:16:00Z")]), ... raiseError=True ... ) >>> print(response.statusCode) 204
Replace verifier
- Parameters:
verifierId (
str
) – verifier idpolicies (
Optional
[VerifierPolicies
]) – object with policies informationdescription (
Optional
[str
]) – user description
- Returns:
body contains json with verifier current version.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> verifierId = client.createVerifier( ... description="Happy_persons", policies=policies, raiseError=True ... ).json["verifier_id"] >>> newPolicies = policies >>> newPolicies.verificationThreshold = 0.9 >>> response = client.putVerifier(verifierId=verifierId, policies=newPolicies) >>> print(response.statusCode) 200 >>> print(response.json) {'version': 1}
Replace analytic.
- Parameters:
analyticId (
str
) – analytic idanalytic (
Analytic
) – analytic structure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from time import sleep >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ACCOUNT_ID >>> from uuid import uuid4 >>> analyticName = str(uuid4()) >>> analyticId = client.createAnalytic( ... analytic=Analytic(analyticName=analyticName), raiseError=True ... ).json["analytic_id"] >>> response = client.replaceAnalytic( ... analyticId=analyticId, analytic=Analytic(analyticName=analyticName, description="new descr") ... ) >>> >>> print(response.statusCode) 204
Create schedule template
- Parameters:
scheduleId (
str
) – schedule idscheduleTemplate (
ScheduleTemplate
) – schedule template object
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.video_manager.http_objs import ScheduleTemplate >>> scheduleId = client.createScheduleTemplate( ... scheduleTemplate=ScheduleTemplate( ... startTime="2025-05-01T00:00:00.000000+00:00", ... endTime="2025-05-16T00:00:00.000000+00:00", ... cron="5 4 * * 4", ... duration=11, ... durationType="minute", ... ), ... raiseError=True, ... ).json["schedule_id"] >>> response = client.replaceScheduleTemplate(scheduleId=scheduleId, scheduleTemplate=ScheduleTemplate( ... startTime="2026-05-01T00:00:00.000000+00:00", ... endTime="2026-05-16T00:00:00.000000+00:00", ... cron="1 4 * * 4", ... duration=1, ... durationType="hour", ... )) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "intervals": [ { "end_time": ..., "start_time": ... }, { "end_time": ..., "start_time": ... } ], "schedule_id": ... }
Replace an existent stream in luna-streams
- Parameters:
streamId (
str
) – id to put stream byanalytics (
List
[StreamAnalytic
]) – stream analyticsname (
Optional
[str
]) – stream namedescription (
Optional
[str
]) – stream descriptionstreamType (
Literal
['stream'
,'videofile'
]) – stream typedownloadable (
bool
) – whether reference is downloadabletimestampSource (
Literal
['pts'
,'server'
,'frame_rate'
,'auto'
]) – timestamp source where pts - video labels, server - server time, frame_rate - video file auto logic described in openapireference (
str
) – stream URLrotation (
Optional
[Literal
[0
,90
,180
,270
]]) – angle of camera frame rotation (0, 90, 180 or 270)pts (
Optional
[VideoPTS
]) – video pts settingsfps (
Optional
[Real
]) – video decoder fpslocation (
Optional
[Location
]) – location that stream belongssource (
Optional
[str
]) – additional stream informationrestart (
Optional
[Restart
]) – auto-restart configurationgroupName (
Optional
[str
]) – group namegroupId (
Optional
[str
]) – group identifiertimeout (
Optional
[int
]) – stream/videofile read timeoutnotificationPolicy (
Optional
[StreamNotificationPolicy
]) – stream notification policysplittable (
Optional
[int
]) – whether stream is splittableffmpegKwargs (
Optional
[dict
]) – additional ffmpeg kwargsbehaviorParameters (
Optional
[BehaviorParameters
]) – behavior parameters for stream
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created stream id & version will be returned.
- Return type:
class
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> streamId = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ).json["stream_id"] >>> response = client.replaceStream( ... streamId=streamId, ... streamType="videofile", ... reference="http://reference.local/replaced", ... name="replaced_name", ... description="replaced description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... ) >>> print(response.statusCode) 200 >>> response = client.getStream(streamId=streamId, raiseError=True) >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "account_id": ..., "analytics": [ { "analytic_name": "doctests_analytic", "autorestart": { "attempt_count": 10, "current_attempt": 0, "delay": 60, "last_attempt_time": null, "restart": 0, "status": "disabled" }, "parameters": {}, "status": ... } ], "create_time": ..., "data": { "behavior_parameters": ..., "downloadable": false, "ffmpeg_kwargs": ..., "fps": ..., "orientation_strategy": "static", "pts": { "start_time": 0.0 }, "reference": "http://reference.local/replaced", "rotation": 0, "timeout": ..., "timestamp_source": "auto", "type": "videofile" }, "description": "replaced description", "groups": [], "last_error": null, "location": { "area": null, "city": null, "district": null, "geo_position": null, "house_number": null, "street": null }, "name": "replaced_name", "notification_policy": { "enable": 0, "stream_callbacks": [] }, "source": null, "splittable": 0, "status": 0, "stream_id": ..., "version": 2 }
Replace task notification policy by task id.
- Parameters:
taskId (
int
) – task idaccountIdFilter (
Optional
[str
]) – account idnotificationPolicy (
Optional
[TaskNotificationPolicy
]) – task notification policy
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with response.
- Return type:
class
>>> import json >>> import time >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.python_matcher.match_objects import FaceFilters >>> from luna3.tasks.http_objs import TaskNotificationPolicy >>> >>> listId = client.createList("happy_persons", raiseError=True).json["list_id"] >>> faceId = client.createFace( ... externalId="14159261415928", lists=[listId], userData="clustering_faces", raiseError=True ... ).json["face_id"] >>> faceFilters = FaceFilters( ... externalIds=["14159261415928"], ... listId=listId, ... faceIds=[faceId], ... userData="clustering_faces", ... ) >>> taskId = client.createClusteringTask(filters=faceFilters, raiseError=True).json["task_id"] >>> time.sleep(1) >>> response = client.replaceTaskNotificationPolicy(taskId=taskId, ... notificationPolicy=TaskNotificationPolicy(enable=0, taskCallbacks=[], subtaskCallbacks=[])) >>> print(response.statusCode) 204
Replace token.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/putToken
- Parameters:
tokenId (
str
) – token idgrantAllPermissions (
int
) – grant all permissions to tokentokenPermissions (
Optional
[TokenPermissions
]) – token permissionsexpirationTime (
Optional
[str
]) – token expiration timevisibilityArea (
Optional
[Literal
['all'
,'account'
]]) – token visibility areadescription (
Optional
[str
]) – account description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created token id and token will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.accounts.http_objs import TokenPermissions >>> from uuid import uuid4 >>> import json >>> >>> tokenId = client.createToken(tokenPermissions=TokenPermissions(), raiseError=True).json["token_id"] >>> response = client.replaceToken(tokenId=tokenId, tokenPermissions=TokenPermissions()) >>> print(response.statusCode) 201 >>> print(response.json) {'token_id': ..., 'token': ..., 'url': ...}
Save body sample to the system.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/saveSample
- Parameters:
image (
BinaryImage
) – Single image object.ttl (
Optional
[int
]) – Object lifetime
- Returns:
body contains json with sample_id and url.
- Return type:
LunaResponse
- Raises:
ValueError – if body has unsupported mimetype.
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import BODY_WARP as image >>> >>> response = client.saveBodySample(image=image) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"sample_id": ..., "url": ...}
Save raw event.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/saveEvent
- Parameters:
handlerId (
str
) – handler idevent (
Union
[ApiRawEvent
,Dict
[str
,Any
]]) – raw eventwaitSaving (
Optional
[int
]) – whether to wait for event saving
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> handlerId = client.createHandler( ... handlerType=1, description="dynamic_handler", raiseError=True ... ).json["handler_id"] >>> event = { ... "face_attributes": { ... "basic_attributes": { ... "age": 29, ... "gender": 1, ... "ethnicities": { ... "predominant_ethnicity": "asian", ... "estimations": { ... "african_american": 1.92238889737406e-12, ... "asian": 0.954671621322632, ... "caucasian": 0.045328326523304, ... "indian": 7.65100649502415e-10, ... }, ... }, ... } ... }, ... "user_data": "event_user_data", ... } >>> response = client.saveEvent(handlerId=handlerId, event=event, waitSaving=1) >>> print(response.statusCode) 201
Save face sample to the system.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/saveSample
- Parameters:
image (
BinaryImage
) – Single image object.ttl (
Optional
[int
]) – Sample lifetime
- Returns:
body contains json with sample_id and url.
- Return type:
LunaResponse
- Raises:
ValueError – if body has unsupported mimetype.
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP as image >>> >>> response = client.saveFaceSample(image=image) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"sample_id": ..., "url": ...}
Save general events to luna-events.
- Parameters:
events (
list
[Union
[GeneralEvent
,dict
]]) – list of eventswaitEventsSaving (
Optional
[bool
]) – whether to wait events saving (response will be received only after events will be saved)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
Save image to the system.
- Parameters:
image (
BinaryImage
) – Single image object.ttl (
Optional
[int
]) – Image lifetime
- Returns:
body contains json with image_id and url.
- Return type:
LunaResponse
- Raises:
ValueError – if body has unsupported mimetype
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_IMAGE as image >>> >>> response = client.saveImage(image=image) >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"external_url": "http://127.0.0.1:5000/6/images/...", "image_id": ..., "url": ...}
Save object to the system.
- Parameters:
objectBody (
str
) – object, available: text, jsoncontentType (
Optional
[str
]) – content-type of object or application/json for defaultttl (
Optional
[int
]) – Object lifetime
- Returns:
body contains json with object_id and url.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> response = client.saveObject("1,2,3", contentType = "text/plain") >>> print(response.statusCode) 201 >>> print(json.dumps(response.json, sort_keys=True)) {"external_url": "http://127.0.0.1:5000/6/objects/...", "object_id": ..., "url": ...}
Detect faces on input images.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/sdk
- Parameters:
inputData (
Union
[BinaryImage
,List
[BinaryImage
],List
[UrlForDetection
],List
[str
]]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idsestimateImageModification (
int
) – Available values : 0, 1estimatePeopleCount (
int
) – Available values : 0, 1peopleCountCoordinates (
int
) – Available values : 0, 1multifacePolicy (
int
) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the imagedetectFace (
Optional
[int
]) – detect facesdetectBody (
Optional
[int
]) – detect human bodiesestimateHeadPose (
Optional
[int
]) – Available values : 0, 1estimateLandmarks5 (
Optional
[int
]) – Available values : 0, 1estimateLandmarks68 (
Optional
[int
]) – Available values : 0, 1estimateQuality (
Optional
[int
]) – Available values : 0, 1estimateGaze (
Optional
[int
]) – Available values : 0, 1estimateEyesAttributes (
Optional
[int
]) – Available values : 0, 1estimateMouthAttributes (
Optional
[int
]) – Available values : 0, 1estimateEmotions (
Optional
[int
]) – Available values : 0, 1estimateMask (
Optional
[int
]) – Available values : 0, 1estimateLiveness (
Optional
[int
]) – Available values : 0, 1estimateDeepfake (
Optional
[int
]) – Available values : 0, 1estimateGlasses (
Optional
[int
]) – Available values : 0, 1estimateFaceDescriptor (
Optional
[int
]) – Available values : 0, 1estimateBasicAttributes (
Optional
[int
]) – Available values : 0, 1estimateBodyDescriptor (
Optional
[int
]) – Available values : 0, 1estimateUpperBody (
Optional
[int
]) – Available values : 0, 1estimateLowerBody (
Optional
[int
]) – Available values : 0, 1estimateBodyBasicAttributes (
Optional
[int
]) – Available values : 0, 1estimateAccessories (
Optional
[int
]) – Available values : 0, 1estimateFaceOcclusion (
Optional
[int
]) – Available values : 0, 1estimateBodyWarp (
Optional
[int
]) – Available values : 0, 1estimateFaceWarp (
Optional
[int
]) – Available values : 0, 1pitchThreshold (
Optional
[int
]) – maximum deviation pitch angle from 0rollThreshold (
Optional
[int
]) – maximum deviation roll angle from 0yawThreshold (
Optional
[int
]) – maximum deviation yaw angle from 0scoreThreshold (
float
) – descriptor garbage scoremaskStates (
Optional
[List
[int
]]) – Array of integer (filter by mask state) (Items Enum:1 2 3)livenessStates (
Optional
[List
[int
]]) – Array of integer (filter by liveness state) (Items Enum:0 1 2)deepfakeStates (
Optional
[List
[int
]]) – Array of integer (filter by deepfake state) (Items Enum:0 1)faceOcclusionStates (
Optional
[List
[str
]]) – Array of strings (Items Enum: “face”, “forehead”, “eye”, “nose”, “mouth”, “lower_face”)aggregateAttributes (
Optional
[int
]) – Available values : 0, 1imageType (
Optional
[int
]) – image type (0 - raw image, 1 - face warped image, 2 - body warped image)useExifInfo (
Optional
[int
]) – whether to use exif info for auto orientationextractExif (
Optional
[int
]) – extract EXIF meta information from imagesaccept (
str
) – expected content type
- Returns:
body contains json with samples, exif, filename for succeeded images and errors for failed images.
- Return type:
LunaResponse
- Raises:
ValueError – if no images were found
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import FACE_WARP as image >>> >>> response = client.sdk( ... inputData=image, ... estimatePeopleCount=1, ... peopleCountCoordinates=1, ... detectFace=1, ... estimateHeadPose=1, ... estimateEmotions=1, ... estimateGaze=1, ... estimateLiveness=1, ... estimateDeepfake=1, ... estimateQuality=1, ... estimateMask=1, ... estimateEyesAttributes=1, ... estimateMouthAttributes=1, ... estimateGlasses=1, ... estimateFaceWarp=1, ... estimateFaceDescriptor=1, ... estimateLandmarks5=1, ... estimateLandmarks68=1, ... estimateBasicAttributes=1, ... estimateBodyBasicAttributes=1, ... estimateUpperBody=1, ... estimateLowerBody=1, ... estimateAccessories=1, ... pitchThreshold=20, ... rollThreshold=20, ... yawThreshold=20, ... scoreThreshold=0.7, ... livenessStates=[1], ... deepfakeStates=[1], ... aggregateAttributes=1, ... imageType=1, ... useExifInfo=1, ... extractExif=1, ... accept="application/json" ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "aggregate_estimations": { "body": null, "face": { "attributes": { "basic_attributes": { "age": ..., "ethnicities": { "estimations": { "african_american": ..., "asian": ..., "caucasian": ..., "indian": ... }, "predominant_ethnicity": "caucasian" }, "gender": 0 }, "descriptor": { "score": ..., "sdk_descriptor": ... }, "emotions": { "estimations": { "anger": ..., "disgust": ..., "fear": ..., "happiness": ..., "neutral": ..., "sadness": ..., "surprise": ... }, "predominant_emotion": "neutral" }, "mask": { "estimations": { "medical_mask": ..., "missing": ..., "occluded": ... }, "face_occlusion": { "estimations": { "chin": ..., "clear": ..., "correct": ..., "full": ..., "mouth": ..., "partially": ... }, "predominant_occlusion": "clear" }, "predominant_mask": "missing" } } } }, "images_estimations": [ { "estimations": [ { "body": null, "face": { "detection": { "attributes": { "emotions": { "estimations": { "anger": ..., "disgust": ..., "fear": ..., "happiness": ..., "neutral": ..., "sadness": ..., "surprise": ... }, "predominant_emotion": "neutral" }, "glasses": { "glasses": "no_glasses" }, "mask": { "estimations": { "medical_mask": ..., "missing": ..., "occluded": ... }, "face_occlusion": { "estimations": { "chin": ..., "clear": ..., "correct": ..., "full": ..., "mouth": ..., "partially": ... }, "predominant_occlusion": "clear" }, "predominant_mask": "missing" }, "mouth_attributes": { "occluded": ..., "opened": ..., "score": ..., "smile": ... } }, "quality": { "blurriness": ..., "dark": ..., "illumination": ..., "light": ..., "specularity": ... }, "warp": ... } } } ], "exif": {}, "filename": "raw image", "image_estimations": { "people": { "coordinates": ..., "count": ... } } } ] }
Aiohttp session getter. Same for one BaseHTTPAPI instance.
- Returns:
initialised aiohttp session or None
Create ws-connection to receive real time data from stream analytics
- Parameters:
streamId (
str
) – stream idanalyticIndex (
int
) – analytics of interest indexaccountId (
Optional
[str
]) – account id to connect tologin (
Optional
[str
]) – account loginpassword (
Optional
[str
]) – account passwordtoken (
Optional
[str
]) – tokenasyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultmessageReceiveTimeout (
Optional
[Real
]) – message receive timeout (time between start waiting message and message appearance)
- Return type:
Union
[_BaseRequestContextManager
[ClientWebSocketResponse
],contextmanager
]- Returns:
context manager with connection to luna-video-manager
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.lunavl.mixins.doctests.config import ANALYTIC_NAME >>> from luna3.video_manager.http_objs import StreamAnalytic >>> response = client.createStream( ... streamType="videofile", ... reference="http://reference", ... name="test_stream", ... description="test stream description", ... analytics=[StreamAnalytic(name=ANALYTIC_NAME)], ... raiseError=True, ... ) >>> streamId = response.json["stream_id"] >>> with client.streamsWsConnect(streamId=streamId, messageReceiveTimeout=5) as ws: ... WS_RESP = json.loads(ws.recv()) >>> print(ws.status) 101 >>> print(json.dumps(WS_RESP, sort_keys=True, indent=4)) { "stream_status": "in_progress", "error": null, "analytics_results": { "crowd": { "track_id": ..., "event_id": ..., "people_count": ..., "time_offset": ..., "event_status": "started", "people_coordinates": ... } } }
Test connection to current configured service.
- Parameters:
lunaRequestId (
Optional
[str
]) – External request id. Helps uniquely identifying messages, corresponding to particular requests, in system logs. Pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$asyncRequest (bool) – default mode for request async or blocking
raiseError (
Optional
[bool
]) – if request fails, LunaApiException is raisedtotalTimeout (
Optional
[Real
]) – request processing timeout in seconds.connectTimeout (
Optional
[Real
]) – connection timeout seconds.sockReadTimeout (
Optional
[Real
]) – socket read timeoutsockConnectTimeout (
Optional
[Real
]) – socket connect timeoutcloseSession (
bool
) – whether to close session
- Return type:
Union
[Awaitable
[bool
],bool
]- Returns:
boolean status of establish connection
Update a handler. You can not update a part of handler.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/putHandler
- Parameters:
handlerId (
str
) – handler idpolicies (
Optional
[Policies
]) – object with policies informationhandlerType (
Optional
[int
]) – handler type (0 - static, 1 - dynamic, 2 - lambda)description (
Optional
[str
]) – user description
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> handlerId = client.createHandler(handlerType=1, description="dynamic", raiseError=True).json['handler_id'] >>> response = client.updateHandler( ... handlerId=handlerId, handlerType=1, description="test_persons_3" ... ) >>> print(response.statusCode) 204
Update lambda
- Parameters:
lambdaId (
str
) – lambda idarchive (
bytes
) – archive file byteslambdaName (
str
) – name of lambdadescription (
Optional
[str
]) – descriptionlambdaType (
Optional
[Literal
['standalone'
,'handlers'
,'tasks'
,'agent'
]]) – lambda typeimageBuilder (
Optional
[Literal
['kaniko'
,'buildah'
]]) – image builder typeadditionalUserDockerCommands (
Optional
[List
[str
]]) – additional user docker commandsbaseImageName (
Optional
[str
]) – base lambda image namebaseImageTag (
Optional
[str
]) – base lambda image tag (for custom image)archiveTtl (
Optional
[Literal
[-1
,1
,2
,3
,4
,5
,6
,7
,14
,30
,60
,90
,180
,365
]]) – ttl for lambda archiveworkers (
Optional
[int
]) – count of lambda workersenableGPU (
Optional
[bool
]) – whether to enable GPUpodCount (
Optional
[int
]) – count of lambda podscpuLimit (
Optional
[int
]) – cpu limit for lambda in cpu unitsramLimit (
Optional
[int
]) – ram limit for lambda in GBcpuRequest (
Optional
[int
]) – cpu request for lambda in cpu unitsramRequest (
Optional
[int
]) – ram request for lambda in GBnamespace (
Optional
[str
]) – k8s namespaceselector (
Optional
[dict
]) – kubernetes pod node selectorimageName (
Optional
[str
]) – lambda imageimageTag (
Optional
[str
]) – lambda image tagagentParameters (
Optional
[AgentParameters
]) – lambda agent paramters
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> from uuid import uuid4 >>> from time import sleep >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> def wait4start(lambdaId_: str): ... for _ in range(150): ... reply = client.getLambdaStatus(lambdaId_).json ... if reply["status"] == "running": ... break ... if reply["status"] == "terminated": ... raise Exception(f"Expected successfully lambda running. Lambda id: {lambdaId_}") ... sleep(1) ... else: ... raise Exception(f"Lambda execution took more than 150 seconds. Lambda id: {lambdaId_}") ... >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4())).json["lambda_id"] >>> wait4start(lambdaId) >>> newName = str(uuid4()) >>> response = client.updateLambda(lambdaId=lambdaId, lambdaName=newName, archive=LAMBDA_ARCHIVE) >>> print(response.statusCode) 200
Update lambda using latest base image
- Parameters:
lambdaId (
str
) – lambda id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> from uuid import uuid4 >>> from time import sleep >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> def wait4start(lambdaId_: str): ... for _ in range(150): ... reply = client.getLambdaStatus(lambdaId_).json ... if reply["status"] == "running": ... break ... if reply["status"] == "terminated": ... raise Exception(f"Expected successfully lambda running. Lambda id: {lambdaId_}") ... sleep(1) ... else: ... raise Exception(f"Lambda execution took more than 150 seconds. Lambda id: {lambdaId_}") >>> >>> lambdaId = client.createLambda(archive=LAMBDA_ARCHIVE, lambdaName=str(uuid4()), ... raiseError=True).json["lambda_id"] >>> wait4start(lambdaId) >>> response = client.updateLambdaImage(lambdaId=lambdaId) >>> print(response.statusCode) 200
Update the list user_data
- Parameters:
listId (
str
) – list iduserData (
str
) – user data associated with the list (<= 128 characters)
- Returns:
not contains response body.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> response = client.updateList(listId=listId, userData="test_data12_updated") >>> print(response.statusCode) 204
Update settings.
- Keyword Arguments:
see Attributes
Validate handler policies.
- Parameters:
policies (
Policies
) – object with policies information- Returns:
not contains response body.
- Return type:
LunaResponse
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import DetectPolicy, ExtractPolicy, StoragePolicy, LinkToListPolicy >>> from luna3.common.http_objs import MatchPolicy, Filters, Policies, FacePolicy >>> from luna3.common.http_objs import MatchPolicyCandidates, ConditionalTagPolicy >>> >>> listId = client.createList("strange_persons", raiseError=True).json["list_id"] >>> policies = Policies( ... detectPolicy=DetectPolicy( ... estimateHeadPose=1, ... estimateEmotions=1, ... estimateGaze=1, ... extractExif=1, ... estimateLiveness=DetectPolicy.LivenessEstimationPolicy(1, 0.5, 0.5), ... estimateDeepfake=DetectPolicy.DeepfakeEstimationPolicy(1, 0.5, 2), ... rollThreshold=20, ... ), ... extractPolicy=ExtractPolicy(extractBasicAttributes=1, extractFaceDescriptor=1, fdScoreThreshold=0.7772), ... matchPolicy=[ ... MatchPolicy( ... candidates=MatchPolicyCandidates(origin="faces", listId=listId), ... label="test_faces", ... gender=1, ... ethnicities=[1, 2], ... limit=3, ... ) ... ], ... storagePolicy=StoragePolicy( ... facePolicy=FacePolicy( ... storeFace=1, ... filters=Filters(ageGte=18, ageLt=40), ... setSampleAsAvatar=1, ... linkToListsPolicy=[LinkToListPolicy(listId=listId)], ... ) ... ), ... conditionalTagsPolicy=[ConditionalTagPolicy(tag="test_tag")], ... ) >>> response = client.validateHandler(policies=policies) >>> print(response.statusCode) 204
Validate lambda.
- Parameters:
archive (
bytes
) – archive file byteslambdaType (
Optional
[Literal
['standalone'
,'handlers'
,'tasks'
,'agent'
]]) – lambda type
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lambda_id will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from testData.resources import LAMBDA_ARCHIVE >>> >>> response = client.validateLambda(archive=LAMBDA_ARCHIVE, lambdaType="standalone") >>> print(response.statusCode) 204
Verify account data.
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#operation/verifier
- Parameters:
accountId (
Optional
[str
]) – account idtoken (
Optional
[str
]) – account JWT tokenlogin (
Optional
[str
]) – account loginpassword (
Optional
[str
]) – account password
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse 204 status code will be returned.
- Return type:
class
>>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from uuid import uuid4 >>> import json >>> >>> response = client.verifyAccount(login=client.login, password=client.password) >>> print(response.statusCode) 200 >>> print(response.json['account_type']) advanced_user
Perform data verification against specified objects. Only one objects set is allowed.
- Parameters:
verifierId (
str
) – verifier idinputData (
Union
[BinaryImage
,BinaryDescriptorData
,List
[Union
[BinaryImage
,BinaryDescriptorData
]]]) – one of: - Single image - Single descriptor - List of images and descriptorsfaceIds (
Optional
[List
[str
]]) – faces ids to verify againsteventIds (
Optional
[List
[str
]]) – event ids to verify againstexternalIds (
Optional
[List
[str
]]) – external ids to verify againstattributeIds (
Optional
[List
[str
]]) – temporary attribute ids to verify againstimageType (
Optional
[int
]) – image type (0 - raw image, 1 - face warped image)useExifInfo (
Optional
[int
]) – whether to use exif info for auto orientation
- Returns:
body contains json with verifications info.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> from testData.resources import FACE_WARP as image >>> >>> sampleId = client.detectFaces( ... inputData=image, raiseError=True ... ).json["images"][0]["detections"]["samples"][0]["face"]["sample_id"] >>> attributeId = client.extractAttrFromSample(sampleIds=[sampleId], raiseError=True).json[0]["attribute_id"] >>> faceId = client.createFace(attributeId=attributeId, raiseError=True).json["face_id"] >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> verifierId = client.createVerifier( ... description="test_verifier", policies=policies, raiseError=True).json["verifier_id"] >>> response = client.verifyData( ... verifierId=verifierId, faceIds=[faceId], inputData=image, imageType=1, useExifInfo=1 ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "images": [ { "detections": { "face_detections": [ { "face_attributes": { "attribute_id": ..., "basic_attributes": { "age": ..., "ethnicities": { "estimations": { "african_american": ..., "asian": ..., "caucasian": ..., "indian": ... }, "predominant_ethnicity": "caucasian" }, "gender": 0 }, "samples": [...], "score": ..., "url": "/6/attributes/..." }, "sample": { "face": { "attributes": { "emotions": { "estimations": { "anger": ..., "disgust": ..., "fear": ..., "happiness": ..., "neutral": ..., "sadness": ..., "surprise": ... }, "predominant_emotion": "neutral" } }, "sample_id": ..., "url": "/6/samples/faces/..." } }, "verifications": [ { "face": { "face_id": ... }, "similarity": ..., "status": true } ] } ], "filtered_detections": { "face_detections": [] } }, "error": { "desc": "Success", "detail": "Success", "error_code": 0, "link": "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0" }, "filename": "raw_image", "status": 1 } ] }
Verify raw API allows to match each candidate with each reference descriptors.
- Parameters:
verifierId (
str
) – verifier idcandidates (
List
[BinaryReference
]) – list of BinaryReference objects for candidatesreferences (
List
[BinaryReference
]) – list of BinaryReference objects for references verifierId: verifier id
- Returns:
body contains json with results of matching.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import VerifierPolicies, VerifierAttributePolicy, VerifierDetectPolicy >>> from luna3.common.http_objs import VerifierExtractPolicy, VerifierStoragePolicy, VerifierFaceSamplePolicy >>> from luna3.python_matcher.match_objects import RawDescriptorReference, RawDescriptor >>> from testData.resources import DESCRIPTOR >>> >>> policies = VerifierPolicies( ... verificationThreshold=0.5, ... detectPolicy=VerifierDetectPolicy(estimateEmotions=1), ... extractPolicy=VerifierExtractPolicy(extractBasicAttributes=1), ... storagePolicy=VerifierStoragePolicy( ... faceSamplePolicy=VerifierFaceSamplePolicy(storeSample=1), ... attributePolicy=VerifierAttributePolicy(storeAttribute=1), ... ), ... ) >>> verifierId = client.createVerifier( ... description="test_verifier", policies=policies, raiseError=True ... ).json["verifier_id"] >>> candidate = RawDescriptorReference(referenceId="candidate_id", descriptor=DESCRIPTOR) >>> reference = RawDescriptorReference(referenceId="reference_id", descriptor=DESCRIPTOR) >>> response = client.verifyRaw( ... verifierId=verifierId, candidates=[candidate], references=[reference] ... ) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "matches": [ { "matches": [ { "candidate_id": "candidate_id", "similarity": 1.0, "status": true } ], "reference_id": "reference_id" } ] }
Property get version uri
>>> self.versionUri "http://127.0.0.1:5030/version"
Process video
- Parameters:
inputData (
VideoSDKInput
) – video properties including url and analytics params- Returns:
body contains json with analytics results errors for failed images.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.public.sdk import VideoSDKInput, VideoSDKAnalytics, VideoSDKProperties >>> from luna3.public.sdk import PeopleCountAnalyticsParams, Rate >>> url ="https://lunatestttttt.s3.eu-central-1.amazonaws.com/video_test.avi" >>> params = PeopleCountAnalyticsParams(rate=Rate(unit="second", period=1), probeCount=2) >>> analytics = [VideoSDKAnalytics(name="people_count", targets=[], parameters=params)] >>> response = client.videosdk(inputData=VideoSDKInput(VideoSDKProperties(url), analytics)) >>> print(response.statusCode) 200 >>> print(json.dumps(response.json, sort_keys=True, indent=4)) { "analytics": [ { "name": "people_count", "result": { "crowd": { "events": [ { "event_id": ..., "frames_estimations": [ { "people_count": ..., "time_offset": ... }, { "people_count": ..., "time_offset": ... }, { "people_count": ..., "time_offset": ... }, { "people_count": ..., "time_offset": ... } ], "people_count": 2, "track_id": ..., "video_segment": { "end_time_offset": ..., "start_time_offset": 1.0 } } ] } } } ], "video_data": { "duration": 5.0, "error_count": 0, "frame_rate": 24.0, "frames_count": 120, "processed_parts": [ { "end_offset": ..., "start_offset": 0 } ], "rotation": ... } }
Create ws-connection to luna-sender
See https://docs.visionlabs.ai/luna/latest/ReferenceManuals/APIReferenceManual.html#tag/ws
- Parameters:
accountId (
Optional
[str
]) – account id to connect tologin (
Optional
[str
]) – account loginpassword (
Optional
[str
]) – account passwordtoken (
Optional
[str
]) – tokenageLt (
Optional
[int
]) – [ 0 .. 100 ] - upper bound for reference ageageGte (
Optional
[int
]) – [ 0 .. 100 ] - lower including bound for reference agegender (
Optional
[int
]) – Gender. 1 - male, 0 - femaleethnicGroups (
Optional
[List
[int
]]) – Array of integer (ethnicities_filter) - Items Enum:1 2 3 4 ( AfricanAmerican - 1; Indian - 2; Asian - 3; Caucasian - 4)tags (
Optional
[List
[str
]]) – users tagsobjectSimilarityLt (
Optional
[float
]) – upper excluding similarity boundaryobjectSimilarityGte (
Optional
[float
]) – lower including similarity boundarysources (
Optional
[List
[str
]]) – list of sourcestreamIds (
Optional
[List
[str
]]) – list of stream idsmatchingCandidatesLabels (
Optional
[List
[str
]]) – matching candidate label listuserData (
Optional
[str
]) – event user datageoPosition (
Union
[GeoBbox
,str
,None
]) – geo position bbox filter specified by coordinates of its center (origin) and some deltacities (
Optional
[List
[str
]]) – list of citiesareas (
Optional
[List
[str
]]) – list of areasdistricts (
Optional
[List
[str
]]) – list of districtsstreets (
Optional
[List
[str
]]) – list of streetshouseNumbers (
Optional
[List
[str
]]) – list of house numbershandlerIds (
Optional
[List
[str
]]) – handler idsliveness (
Optional
[List
[int
]]) – allowed liveness states: 0 - spoof, 1 - real, 2 - fakedeepfake (
Optional
[List
[int
]]) – allowed deepfake states: 0 - fake, 1 - realmasks (
Optional
[List
[int
]]) – Array of integer (masks) - Items Enum: 1, 2, 3 (1 - missing, 2 - medical mask, 3 - occluded)emotions (
Optional
[List
[int
]]) – Array of integer (emotions) - Items Enum: 1, 2, 3, 4, 5, 6, 7 ( 1 - anger, 2 - disgust, 3 - fear, 4 - happiness, 5 - neutral, 6 - sadness, 7 - surprise)apparentGender (
Optional
[List
[Literal
[0
,1
,2
]]]) – apparent gender (body) of event (0, 1, 2) - means (female, male, undefined)apparentAgeLt (
Optional
[int
]) – upper excluding apparent age boundary (body)apparentAgeGte (
Optional
[int
]) – lower including apparent age boundary (body)backpackStates (
Optional
[List
[Literal
[0
,1
,2
]]]) – interest backpack states list ((0, 1, 2) - means (no, yes, unknown)headwearStates (
Optional
[List
[Literal
[0
,1
,2
]]]) – interest headwear states list ((0, 1, 2) - means (no, yes, unknown)upperClothingColors (
Optional
[List
[Literal
['black'
,'blue'
,'green'
,'gray'
,'orange'
,'purple'
,'red'
,'white'
,'yellow'
,'pink'
,'brown'
,'beige'
,'khaki'
,'multicolored'
,'undefined'
]]]) – interest upper clothing colors listsleeveLengths (
Optional
[List
[Literal
['short'
,'long'
,'undefined'
]]]) – interest sleeve length list (short, long, undefined)asyncRequest (
Optional
[bool
]) – execution in asynchronous mode, disabled by defaultmessageReceiveTimeout (
Optional
[Real
]) – message receive timeout (time between start waiting message and message appearance)
- Returns:
body contains json with event info.
- Return type:
LunaResponse
>>> import json >>> from luna3.lunavl.mixins.doctests.config import TEST_CLIENT as client >>> from luna3.common.http_objs import DetectPolicy, ExtractPolicy, NotificationPolicy >>> from luna3.common.http_objs import MatchPolicy, Policies, Filters, StoragePolicy >>> from luna3.common.http_objs import MatchPolicyCandidates >>> from testData.resources import FACE_WARP as image >>> >>> listId = client.createList(userData="happy_persons", raiseError=True).json["list_id"] >>> policies = Policies( ... detectPolicy=DetectPolicy(detectFace=1), ... extractPolicy=ExtractPolicy(extractBasicAttributes=1, fdScoreThreshold=0.0,), ... matchPolicy=[ ... MatchPolicy( ... candidates=MatchPolicyCandidates(origin="faces", listId=listId), ... label="happy", ... limit=3, ... threshold=0.5, ... gender=0, ... ) ... ], ... storagePolicy=StoragePolicy(notificationPolicy=NotificationPolicy(sendNotification=1, ... filters=Filters(gender=0)))) >>> handler = client.createHandler(description="test_handler_notification", policies=policies, raiseError=True) >>> with client.wsConnect(messageReceiveTimeout=5) as ws: ... event = client.emitEvents( ... handlerId=handler.json["handler_id"], ... inputData=[image], ... tags="notify_tag", ... imageType=1, ... useExifInfo=1, ... raiseError=True, ... meta={"foo": "bar"}, ... ) ... WS_RESP = json.loads(ws.recv()) >>> print(ws.status) 101 >>> print(json.dumps(WS_RESP, sort_keys=True, indent=4)) { "Luna-Request-id": ..., "event": { "aggregate_estimations": { "body": { "attributes": {} }, "face": { "attributes": {} } }, "body_attributes": null, "detections": [ { "detect_time": ..., "detect_ts": null, "filename": "Claudia_Schiffer_warp.jpg", "image_origin": null, "samples": { "body": null, "face": { "detection": {}, "sample_id": ..., "url": "/6/samples/faces/..." } } } ], "event_id": ..., "external_id": "", "face": null, "face_attributes": { "attribute_id": null, "basic_attributes": { "age": ..., "ethnicities": { "estimations": { "african_american": ..., "asian": ..., "caucasian": ..., "indian": ... }, "predominant_ethnicity": "caucasian" }, "gender": ... }, "samples": [...], "score": ..., "url": null }, "location": {}, "matches": [ { "candidates": [], "label": "happy" } ], "meta": { "foo": "bar" }, "source": null, "stream_id": null, "tags": [ "notify_tag" ], "track_id": null, "url": "/6/events/...", "user_data": "" }, "event-create-time": ..., "event-end-time": ..., "handler_id": ... }