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)
Parameter | Description | Schema |
---|---|---|
name | The name of the progress bar. | str |
step | The number of steps to update. | int |
total | The total number of steps in the bar. | int |
ray.progress(step=100)
message(self, message_type: MessageType, content: str)
Parameter | Description | Schema |
---|---|---|
message_type | The name of the progress bar. | MessageType |
content | The 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.
Type | Description |
---|---|
INFO | Represents informational messages, typically used to convey general information about the progress or state of a task. |
ERROR | Represents error messages, usually associated with issues or problems that occurred during the execution of a task, which may require attention or intervention. |
WARNING | Represents 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.
Attribute | Description |
---|---|
status | Represents the current status of the task. |
started_at | Stores 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.
Type | Description |
---|---|
UNKNOWN | The initial status of a task, indicating that its state is not yet known. |
STARTING | The task is in the process of being initialized and starting up. |
RUNNING | The task is actively running and processing data. |
CRASHED | The task has encountered an error and stopped executing unexpectedly. |
PENDING_CONFIG | The task is waiting for a configuration update before it can continue. |