Graph Runtime Python APIs¶
Context¶
Create context¶
context_create()
Creates a new Graph Runtime context
A Graph Runtime context is required for all almost all Graph Runtime operations. The context must be destroyed with ‘GxfContextDestroy’. Multiple contexts can be created in the same process, however they can not communicate with each other.
returns: A unique integer representing context.
Destroy context¶
context_destroy(context)
Destroys a Graph Runtime context
Every Graph Runtime context must be destroyed by calling this function. The context must have been previously created with ‘GxfContextCreate’. This will also destroy all entities and components which were created as part of the context.
parameter:
contextA unique integer representing contextreturns:
None. Throws one of the Graph Runtime errors in not successful
Extensions¶
Maximum number of extensions in a context can be 1024.
Load Extensions from a file¶
load_extensions(context, extension_filenames, manifest_filenames, base_directory)
Loads extension in the given context from file.
parameter:
contextA valid Graph Runtime contextparameter:
extension_filenamesA list of valid filename.parameter:
manifest_filenamesA list of valid filename.parameter:
base_directoryValid directory.returns:
None. Throws one of the Graph Runtime errors in not successful.
Graph¶
Loads a list of entities from YAML file¶
graph_load_file(context, filename)
parameter:
contextA valid Graph Runtime contextparameter:
filenameA valid YAML filename.returns:
None. Throws one of the Graph Runtime errors in not successful.
Activate all system components¶
graph_activate(context)
parameter:
contextA valid Graph Runtime contextreturns:
None. Throws one of the Graph Runtime errors in not successful.
Deactivate all System components¶
graph_deactivate(context)
parameter:
contextA valid Graph Runtime contextreturns:
None. Throws one of the Graph Runtime errors in not successful.
Starts the execution of the graph asynchronously¶
graph_run_async(context)
parameter:
contextA valid Graph Runtime contextreturns:
None. Throws one of the Graph Runtime errors in not successful.
Waits for the graph to complete execution¶
graph_wait(context)
parameter:
contextA valid Graph Runtime contextreturns:
None. Throws one of the Graph Runtime errors in not successful.
Runs all System components and waits for their completion¶
graph_run(context)
parameter:
contextA valid Graph Runtime contextreturns:
None. Throws one of the Graph Runtime errors in not successful.
Entities¶
Find an entity¶
entity_find(context, entity_name)
Finds an entity by its name
parameter:
contextA valid Graph Runtime contextparameter:
entitiy_nameA C string with the name of the entity. Ownership is not transferred.returns: A unique entity identifier if successful else throws one of the Graph Runtime errors in not successful.
Get status of an entity¶
entity_get_status(context, eid)
Gets the status of the entity.
parameter:
contextA valid Graph Runtime contextparameter:
eidThe UID of a valid entityreturns: Returns entity status integer if successful else throws one of the Graph Runtime errors in not successful.
Components¶
Maximum number of components in an entity or an extension can be up to 1024.
Find a component in an entity¶
component_find(context, eid, tid, component_name)
Finds a component in an entity
Searches components in an entity which satisfy certain criteria: component type, component name, and component min index. All three criteria are optional; in case no criteria is given the first component is returned. The main use case for “component min index” is a repeated search which continues at the index which was returned by a previous search.
In case no entity with the given criteria was found GXF_ENTITY_NOT_FOUND is thrown.
parameter:
contextA valid Graph Runtime contextparameter:
eidThe unique object ID (UID) of the entity which is searched.parameter:
tidThe component type ID (TID) of the component to find (optional)parameter:
component_nameThe component name of the component to find (optional). Ownership not transferred.returns: List of
cidsif successful else throws one of the Graph Runtime errors in not successful.
Primitive Parameters¶
64-bit floating point¶
Set¶
parameter_set_float64(context, eid, key, value)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.parameter:
valuea double valuereturns:
None. Throws one of the Graph Runtime errors in not successful.
Get¶
parameter_get_float64(context, eid, key)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.returns: value of parameter if present. Throws one of the Graph Runtime errors in not successful.
64-bit signed integer¶
Set¶
parameter_set_int64(context, eid, key, value)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.parameter:
value64-bit integer value to set.returns:
None. Throws one of the Graph Runtime errors in not successful.
Get¶
parameter_get_int64(context, eid, key)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.returns: value of parameter if present. Throws one of the Graph Runtime errors in not successful.
64-bit unsigned integer¶
Set¶
parameter_set_uint64(context, eid, key, value)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.parameter:
valueunsigned 64-bit integer value to set.returns:
None. Throws one of the Graph Runtime errors in not successful.
Get¶
parameter_get_uint64(context, eid, key)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.returns: value of parameter if present. Throws one of the Graph Runtime errors in not successful.
32-bit signed integer¶
Set¶
parameter_set_int32(context, eid, key, value)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.parameter:
value32-bit integer value to set.returns:
None. Throws one of the Graph Runtime errors in not successful.
Get¶
parameter_get_int32(context, eid, key)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.returns: value of parameter if present. Throws one of the Graph Runtime errors in not successful.
String parameter¶
Set¶
parameter_set_str(context, eid, key, value)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.parameter:
valueA char array containing value to set.returns:
None. Throws one of the Graph Runtime errors in not successful.
Get¶
parameter_get_str(context, eid, key)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.returns: value of parameter if present. Throws one of the Graph Runtime errors in not successful.
Boolean¶
Set¶
parameter_set_bool(context, eid, key, value)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.parameter:
valueA boolean value to set.returns:
None. Throws one of the Graph Runtime errors in not successful.
Get¶
parameter_get_bool(context, eid, key)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.returns: value of parameter if present. Throws one of the Graph Runtime errors in not successful.
Handle¶
Set¶
parameter_set_handle(context, eid, key, value)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.parameter:
valueUnique identifier to set.returns:
None. Throws one of the Graph Runtime errors in not successful.
Get¶
parameter_get_handle(context, eid, key)
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyA valid name of a component to set.returns: value of parameter if present. Throws one of the Graph Runtime errors in not successful.
Vector Parameters¶
To set/get the vector parameters of a component, users can use the following python-APIs for various data types:
Set 1-D Vector Parameters¶
Users can call parameter_set_1d_'data_type'_vector(context, eid, key, value, length)
value should be a list of the data to be set. The size of the stored array should match the length argument passed.
See the table below for all the supported data types and their corresponding function signatures.
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyThe name of the parameterparameter:
valueThe value to set of the parameterparameter:
lengthThe length of the vector parameterreturns:
None. Throws one of the Graph Runtime errors in not successful.
Function Name |
data_type |
|---|---|
|
|
|
|
|
|
|
|
Set 2-D Vector Parameters¶
Users can call parameter_set_2d_'data_type'_vector(context, eid, key, value, height, width)
value should point to a list of list of the data to be set. The length of the first dimension of the list
should match the height argument passed and similarly the length of the second dimension of the
list should match the width passed.
See the table below for all the supported data types and their corresponding function signatures.
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyThe name of the parameterparameter:
valueThe value to set of the parameterparameter:
heightThe height of the 2-D vector parameterparameter:
widthThe width of the 2-D vector parameterreturns:
None. Throws one of the Graph Runtime errors in not successful.
Function Name |
data_type |
|---|---|
|
|
|
|
|
|
|
|
Get 1-D Vector Parameters¶
Users can call parameter_get_1d_'data_type'_vector(context, eid, key, length) to get the value of a 1-D vector.
If the length should match the length of the parameter. If it is less than the parameter length then error is thrown.
If it is greater than the length a larger list with the values set is returned.
See the table below for all the supported data types and their corresponding function signatures.
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyThe name of the parameterparameter:
lengthThe length of the stored 1-D vector parameter.returns: A list containing the values.
Function Name |
data_type |
|---|---|
|
|
|
|
|
|
|
|
Get 2-D Vector Parameters¶
Users can call parameter_get_2d_'data_type'_vector(context, eid, key, height, width) to get
the value of a 2D vector.
The height or width should match the height and width of the stored vector. If they are smaller than the
stored values then error is thrown. If greater than the stored values then larger lists will be returned with values set.
See the table below for all the supported data types and their corresponding function signatures.
parameter:
contextA valid Graph Runtime context.parameter:
eidA valid component identifier.parameter:
keyThe name of the parameterparameter:
heightThe height of the stored 2-D vector parameter.parameter:
widthThe width of the stored 2-D vector parameter.returns: A list of list containing the values.
Function Name |
data_type |
|---|---|
|
|
|
|
|
|
|
|