Device Detection services for 51Degrees Pipeline

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise Class Reference

Detailed Description

The Device Detection On Premise engine uses a datafile to generate a list of properties about a device based on evidence supplied to it.

Inheritance diagram for fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise:

[legend]

Collaboration diagram for fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise:

[legend]

Public Member Functions

 __init__ (self, data_file_path=None, data=None, auto_update=None, cache=None, restricted_properties=None, licence_keys=None, download=True, max_matched_useragent_length=None, drift=None, difference=None, allow_unmatched=None, file_system_watcher=False, polling_interval=30, update_time_maximum_randomisation=10, create_temp_data_copy=True, update_matched_useragent=None, performance_profile="Balanced", reuse_temp_file=False, concurrency=multiprocessing.cpu_count(), update_on_start=False, data_update_url="https://distributor.51degrees.com/api/v2/download", use_predictive_graph=None, use_performance_graph=None, data_update_use_url_formatter=True, data_update_verify_md5=True, data_update_product_type=None, **kwargs)
 Constructor for the DeviceDetection On Premise Engine.
 init_engine (self)
 Function for initialising the engine, wrapped like this so that an engine can be initialised once the datafile is retrieved if update_on_start is set to true.
 read_property_indexes (self)
 The index of each property the engine was built with, keyed by its name in lower case.
 get_metric_properties (self)
 get_evidence_key_filter (self)
 Returns evidence key filter for the on premise engine.
 set_cache (self, cache)
 Not supported.
 on_registration (self, pipeline)
 Function called after the engine is registered with a pipeline the engine base class registers the datafile but we also need to initialise the SWIG wrapper so call self.init_engine() here after the datafile is registered.
 close (self)
 Stop the data file updates and release the native engine.
 process_internal (self, flow_data)
 Internal process method of the Device Detection On Premise engine Gets properties through the SWIG wrapper and stores them in a SwigData extension of the ElementData class.
 get_component (self, property)

Public Member Functions inherited from fiftyone_pipeline_engines::engine::Engine

 __init__ (self, data_file=None)
 set_cache (self, cache)
 set_restricted_properties (self, properties_list)
 is_cacheable (self, data)
 in_cache (self, flowdata)
 refresh (self, identifier)
 process (self, flowdata)
 on_registration (self, pipeline)
 close (self)
 register_data_file (self, data_file)

Public Attributes

str datakey = "device"
 data = data
 build_property_names = list(restricted_properties_vector)
 config = config
 properties_list = properties_list
 data_file_path = data_file_path
 engine = engine
 property_indexes = self.read_property_indexes()
 evidence_keys_list = evidence_keys_list
 properties = properties

Public Attributes inherited from fiftyone_pipeline_engines::engine::Engine

 data_file
 cache
 restricted_properties
dict restricted_property_keys

Constructor & Destructor Documentation

◆ __init__()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.__init__ ( self,
data_file_path = None,
data = None,
auto_update = None,
cache = None,
restricted_properties = None,
licence_keys = None,
download = True,
max_matched_useragent_length = None,
drift = None,
difference = None,
allow_unmatched = None,
file_system_watcher = False,
polling_interval = 30,
update_time_maximum_randomisation = 10,
create_temp_data_copy = True,
update_matched_useragent = None,
performance_profile = "Balanced",
reuse_temp_file = False,
concurrency = multiprocessing.cpu_count(),
update_on_start = False,
data_update_url = "https://distributor.51degrees.com/api/v2/download",
use_predictive_graph = None,
use_performance_graph = None,
data_update_use_url_formatter = True,
data_update_verify_md5 = True,
data_update_product_type = None,
** kwargs )

Constructor for the DeviceDetection On Premise Engine.

@type data_file_path: string

Parameters
data_file_pathpath to the data file @type data: binary
datain memory version of datafile @type auto_update: bool
auto_updatewhether to automatically update the datafile when required @type restricted_properties: list
restricted_propertiesList of property keys to limit the engine to @type license_keys: string
licence_keyslicencekeys to use for the data file update service @type download: bool
downloadwhether to download the datafile or keep it in memory when it is returned from the datafile update service @type max_matched_useragent_length: int
max_matched_useragent_lengthLimit in bytes on the length of a single header such as User-Agent, of a pseudo header including the separators between its values, and of the matched User-Agent. A value longer than the limit is ignored and detection moves on to the next header. The limit applies whether or not update_matched_useragent is on. Left unset, the native default of 500 applies. A larger limit raises the memory each set of results holds. @type update_matched_useragent: bool
update_matched_useragentTrue if the detection should record the matched characters from the target User-Agent, which the UserAgents property returns. On by default, as the native code sets it. Set it to False when UserAgents is not needed, which saves recording the characters. @type drift: int
driftSet maximum drift in hash position to allow when processing HTTP headers @type difference: int
differenceset the maximum difference to allow when processing HTTP headers. The difference is the difference in hash value between the hash that was found, and the hash that is being searched for. By default this is 0. @type allow_unmatched : bool
allow_unmatchedTrue if there should be at least one matched node in order for the results to be considered valid. By default, this is false @type performance_profile: string
performance_profileoptions are: LowMemory, MaxPerformance, Balanced, BalancedTemp, HighPerformance. Balanced by default, as in the native code. @type reuse_temp_file: bool
reuse_temp_fileIndicates that an existing temp file may be used. This should be selected if multiple instances wish to use the same file to prevent high disk usage. @type concurrency: int
concurrencydefaults to the number of cpus in the machine @type update_on_start : bool
update_on_start: When this is set to true the datafile is updated / downloaded immediately on initialization. This is useful if no initial datafile is present. @type file_system_watcher: bool
file_system_watcherwhether to check the datafile's path for changes and update the connected FlowElement's data @type polling_interval: int
polling_intervalHow often to poll for updates to the datafile (minutes) @type update_time_maximum_randomisation : int
update_time_maximum_randomisation: Maximum randomisation offset in seconds to polling time interval @type data_update_verify_md5 : bool @type create_temp_copy: bool
create_temp_copywhether to copy datafile to temporary location when updating @type data_update_url: string
data_update_urlbase url for the datafile update service @type use_performance_graph: bool
use_performance_graphTrue if the performance optimized graph should be used for processing @type use_predictive_graph: bool
use_predictive_graphTrue if the predictive optimized graph should be used for processing
data_update_use_url_formatterThis must be set to false to prevent the API from appending the query string parameters that are required when calling the 51Degrees Distributor service. @type data_update_use_url_formatter: bool

Member Function Documentation

◆ close()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.close ( self)

Stop the data file updates and release the native engine.

Its data is freed once no results read from it are still held, so close every FlowData the engine processed as well. Closing the pipeline closes the engine.

◆ get_component()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.get_component ( self,
property )

◆ get_evidence_key_filter()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.get_evidence_key_filter ( self)

Returns evidence key filter for the on premise engine.

Generated via a list of evidence keys from the swig engine

◆ get_metric_properties()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.get_metric_properties ( self)

◆ init_engine()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.init_engine ( self)

Function for initialising the engine, wrapped like this so that an engine can be initialised once the datafile is retrieved if update_on_start is set to true.

If this is the case, processing is held until the data file is downloaded and available.

◆ on_registration()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.on_registration ( self,
pipeline )

Function called after the engine is registered with a pipeline the engine base class registers the datafile but we also need to initialise the SWIG wrapper so call self.init_engine() here after the datafile is registered.

◆ process_internal()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.process_internal ( self,
flow_data )

Internal process method of the Device Detection On Premise engine Gets properties through the SWIG wrapper and stores them in a SwigData extension of the ElementData class.

Each property value (or lack of) is returned in an AspectPropertyData wrapper from the core Pipeline library.

◆ read_property_indexes()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.read_property_indexes ( self)

The index of each property the engine was built with, keyed by its name in lower case.

The native code gives a property the place of its name among the names the engine was built with, the first place where a name is given twice. An engine built with no names takes the names the native code gives after the first load, which are every property in that data set sorted by name and which a reload does not change.

◆ set_cache()

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.set_cache ( self,
cache )

Not supported.

Results read from native memory, which is not safe to share between requests through a cache.

Member Data Documentation

◆ build_property_names

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.build_property_names = list(restricted_properties_vector)

◆ config

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.config = config

◆ data

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.data = data

◆ data_file_path

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.data_file_path = data_file_path

◆ datakey

str fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.datakey = "device"

◆ engine

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.engine = engine

◆ evidence_keys_list

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.evidence_keys_list = evidence_keys_list

◆ properties

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.properties = properties

◆ properties_list

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.properties_list = properties_list

◆ property_indexes

fiftyone_devicedetection_onpremise.devicedetection_onpremise.DeviceDetectionOnPremise.property_indexes = self.read_property_indexes()