Skip to main content

Execution context

The following utility classes can be used in an execution context to provide more information about the application execution process.

from openfabric_pysdk.context import Ray, State, StateStatus, MessageType

Ray

This class, Ray, is a utility class that represents the execution context and provides functionality to track progress, manage status, and store messages during the execution of a task. It keeps track of various attributes such as unique identifiers, session details, and timestamps, as well as maintaining progress bars and messages to monitor and report on the progress of the execution.

Functions

  • progress
  • message
  • clear_messages

progress(self, name='default', step=1, total=100)

ParameterDescriptionSchema
nameThe name of the progress bar.str
stepThe number of steps to update.int
totalThe total number of steps in the bar.int
ray.progress(step=100)

message(self, message_type: MessageType, content: str)

ParameterDescriptionSchema
message_typeThe name of the progress bar.MessageType
contentThe number of steps to update.str
ray.message(
message_type=MessageType.INFO,
content="Hey, Kindly read the Key features and Description before you start."
)

clear_messages(self)

Removes all messages logged using message().

ray.clear_messages()

MessageType

This class, MessageType, is an enumeration that represents different types of messages that can be generated during the execution of a task. These message types help categorize the messages based on their severity and purpose, allowing for better organization and handling of messages within the application.

TypeDescription
INFORepresents informational messages, typically used to convey general information about the progress or state of a task.
ERRORRepresents error messages, usually associated with issues or problems that occurred during the execution of a task, which may require attention or intervention.
WARNINGRepresents warning messages, used to communicate potential issues or concerns that may not be critical but could have an impact on the task's outcome or performance.

State

This class, State, represents the state of an execution context during the processing of a task. It contains information about the current status of the task and the time when the task was started. This class helps track the progress of a task and can be used to provide insights into its performance or behavior.

AttributeDescription
statusRepresents the current status of the task.
started_atStores the date and time when the task was started.

StateStatus

This class, StateStatus, is an enumeration that represents the various possible statuses of a task during its execution.

TypeDescription
UNKNOWNThe initial status of a task, indicating that its state is not yet known.
STARTINGThe task is in the process of being initialized and starting up.
RUNNINGThe task is actively running and processing data.
CRASHEDThe task has encountered an error and stopped executing unexpectedly.
PENDING_CONFIGThe task is waiting for a configuration update before it can continue.
OpenfabricAI Footer