Skip to main content

Execution callbacks

This section serves as a concise guide to familiarize yourself with the Openfabric Python SDK, which simplifies the interaction with the Openfabric platform using Python programming language. The guide aims to provide you with the necessary knowledge and tools to effectively utilize the Python SDK for seamless integration and enhanced functionality.

config(configuration: Dict[str, ConfigClass], state: State)

This function is a callback function that is called when the configuration is updated.

############################################################
# Callback function called on update config
############################################################

def config(configuration: Dict[str, ConfigClass], state: State):

# Here you can update configuration of your application
...
ParameterDescriptionSchema
configurationA dictionary containing the configuration settings.Dict[str, ConfigClass]
stateAn instance of the State class representing the execution state.State

def execute(request: InputClass, ray: Ray, state: State) -> OutputClass

This function is executed during each pass of the main execution loop.

############################################################
# Callback function called on each execution
############################################################

def execute(request: InputClass, ray: Ray, state: State) -> OutputClass:

# Set progress bar to 0%
ray.progress(step=0)

# Process user request
user_input = request.user_input
...
output = input_after_processing

# Set progress bar to 100%
ray.progress(step=100)

return SchemaUtil.create(OutputClass(), dict(user_output=output))
ParameterDescriptionSchema
requestAn instance of InputClass representing the input request.InputClass
rayAn instance of the Ray class representing the current ray of execution.Ray
stateAn instance of the State class representing the execution state.State

For more in depth examples of how these functions are used, please refer to Tutorials.

OpenfabricAI Footer