App
AppState
¶
OpsML application state object. This is typically used in API
workflows where you wish create a shared state to share among all requests.
The OpsML app state provides a convenient way to load and store artifacts.
Most notably, it provides an integration with Scouter so that you can load a ServiceCard
along with a ScouterQueue
for drift detection. Future iterations of this class may
include other convenience methods that simplify common API tasks.
Source code in python/opsml/app/_app.pyi
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
queue
property
¶
Get the Scouter queue.
reloader_running
property
¶
Check if the ServiceReloader is currently running.
service
property
¶
Get the service card.
from_path(path, transport_config=None, reload_config=None, load_kwargs=None)
staticmethod
¶
Load the AppState from a file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The file path to load the AppState from. This is typically the path
pointing to the directory containing the |
required |
transport_config
|
KafkaConfig | RabbitMQConfig | RedisConfig | HTTPConfig | None
|
Optional transport configuration for the queue publisher Can be KafkaConfig, RabbitMQConfig RedisConfig, or HTTPConfig. If not provided, the queue will not be initialized. |
None
|
load_kwargs
|
Dict[str, Dict[str, Any]]
|
Optional kwargs for loading cards. Expected format: { "card_alias": { "interface": interface_object, "load_kwargs": DataLoadKwargs | ModelLoadKwargs } } |
None
|
Example
Returns:
Name | Type | Description |
---|---|---|
AppState |
AppState
|
The loaded AppState. |
Source code in python/opsml/app/_app.pyi
reload()
¶
shutdown()
¶
Shuts down the AppState
ScouterQueue
and reloader if running.
This is a destructive operation and will attempt to close all background threads
associated with the ScouterQueue
and reloader. Only use this method with graceful
shutdown procedures in mind.
Source code in python/opsml/app/_app.pyi
start_reloader()
¶
ReloadConfig
¶
Reload configuation to use with an Opsml AppState object. Defines the reload logic for checking, downloading and reloading ServiceCards and ScouterQueues associated with an AppState
Source code in python/opsml/app/_app.pyi
cron
property
writable
¶
Get the cron expression for the reload schedule.
__init__(cron, max_retries=3, write_path=None)
¶
Initialize the reload configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cron
|
str
|
The cron expression for the reload schedule. |
required |
max_retries
|
int
|
The maximum number of retries for loading the service card. Defaults to 3. |
3
|
write_path
|
Optional[Path]
|
The optional path to write the service card. Defaults to Path({current directory})/ service_reload |
None
|