utils.rcclient.libs.streamlit_utils.activity_tracker
Submodules
Package Contents
Classes
Base class for HTTP request handlers. |
|
Base class for HTTP request handlers. |
|
Base class for HTTP request handlers. |
Functions
|
Injects custom RESTful routes into the Streamlit application by |
- utils.rcclient.libs.streamlit_utils.activity_tracker.init_global_tornado_hook(rule_list: Iterable[CustomRule | tornado.routing.Rule])
Injects custom RESTful routes into the Streamlit application by intercepting the underlying Tornado web framework.
This function serves as a mechanism to add custom behavior to a Streamlit application without modifying its core logic. It ensures that the custom routes are injected only once, and that the native behavior of Streamlit is preserved for other routes.
Calling this function twice has no effect. To change the rule list, first call ‘uninitialize_global_tornado_hook’ and then call this function again with the new rule list.
Example
>>> from src.hooks.injectApi import ( >>> init_global_tornado_hook, CustomRule >>> ) >>> from tornado.web import RequestHandler >>> class CustomHelloWorldHandler(RequestHandler): >>> def get(self): >>> self.write({ >>> "text": "Hello World" >>> }) >>> init_global_tornado_hook( >>> [ CustomRule("/hello", CustomHelloWorldHandler) ] >>> )
- Parameters:
rule_list (Iterable[Union[CustomRule, Rule]]) – A list of custom rules
application. (to inject into the Streamlit)
- Returns:
TRUE if the hooking mechanism was executed successfully, FALSE otherwise.
- class utils.rcclient.libs.streamlit_utils.activity_tracker.CustomRule(path_pattern: str | tornado.routing.Matcher, handler_class: Any, target_kwargs: Dict[str, Any] | None = None, name: str | None = None)
- class utils.rcclient.libs.streamlit_utils.activity_tracker.User
- last_activity_at: datetime.datetime
- num_hrs_since_inactive: int = 0
- class utils.rcclient.libs.streamlit_utils.activity_tracker.ActivityHandler(application: Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)
Bases:
tornado.web.RequestHandler
Base class for HTTP request handlers.
Subclasses must define at least one of the methods defined in the “Entry points” section below.
Applications should not construct RequestHandler objects directly and subclasses should not override
__init__
(override ~RequestHandler.initialize instead).- current_user
- class utils.rcclient.libs.streamlit_utils.activity_tracker.TrackActivityHandler(application: Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)
Bases:
ActivityHandler
Base class for HTTP request handlers.
Subclasses must define at least one of the methods defined in the “Entry points” section below.
Applications should not construct RequestHandler objects directly and subclasses should not override
__init__
(override ~RequestHandler.initialize instead).- get()
- class utils.rcclient.libs.streamlit_utils.activity_tracker.GetActivityHandler(application: Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)
Bases:
ActivityHandler
Base class for HTTP request handlers.
Subclasses must define at least one of the methods defined in the “Entry points” section below.
Applications should not construct RequestHandler objects directly and subclasses should not override
__init__
(override ~RequestHandler.initialize instead).- get()
- utils.rcclient.libs.streamlit_utils.activity_tracker.init_activity_tracker()