L iUdZddlmZddlmZddlmZmZmZm Z ddl m Z ddl m Z mZerddlmZeeZded <Gd d e ZGd d eZddZdaded<ddZy)z"Runtime-related utility functions.) annotations) getLogger) TYPE_CHECKINGAnyFinalcast)config)MarkdownFormattedExceptionStreamlitAPIException) ForwardMsgr_LOGGERc,eZdZdZdfd ZddZxZS)MessageSizeErrorzNException raised when a websocket message is larger than the configured limit.cF|j|}t| |y)N) _get_messagesuper__init__)selffailed_msg_strmsg __class__s d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/runtime/runtime_util.pyrzMessageSizeError.__init__"s / cbdt|dz ddtdz djdS)Nz **Data of size .Az.1fz& MB exceeds the message size limit of a MB.** This is often caused by a large chart or dataframe. Please decrease the amount of data sent to the browser, or increase the limit by setting the config option `server.maxMessageSize`. [Click here to learn more about config options](https://docs.streamlit.io/develop/api-reference/configuration/config.toml). _Note that increasing the limit may lead to long loading times and large memory consumption of the client's browser and the Streamlit server._  )lenget_max_message_size_bytesstrip)rrs rrzMessageSizeError._get_message&sFN#c)#./#$%  %+ r)rrreturnNone)rrr str)__name__ __module__ __qualname____doc__rr __classcell__)rs@rrrsXrrceZdZdZddZy)BadDurationStringErrorz5Raised when a bad duration argument string is passed.c6tj|d|y)NzcTTL string doesn't look right. It should be formatted as`'1d2h34m'` or `2 days`, for example. Got: )r r)rdurations rrzBadDurationStringError.__init__:s#"++  ::B E rN)r+r"r r!)r#r$r%r&rrrr)r)7s ? rr)cB|j}t|tkDrxddlm}t |}t jd||j|jjj|d|j_ |j}|S)zSerialize a ForwardMsg to send to a client. If the message is too large, it will be converted to an exception message instead. r) exceptionzDWebsocket message size limit exceeded. Showing error to the user: %sF) SerializeToStringrrstreamlit.elementsr.rr warningmarshalldelta new_elementmetadata cacheable)rmsg_strr.msg_size_errors rserialize_forward_msgr9Bs##%G 7|022 1)'2 R   39900::NK!& '') NrNz int | None_max_message_size_bytescpt!tjdtdzat dtS)zReturns the max websocket message size in bytes. This will lazyload the value from the config and store it in the global symbol table. zserver.maxMessageSizerint)r:r get_optionr<rr,rrrrbs4&"("3"34K"LsSVx"W . //r)rr r bytes)r r<)r& __future__rloggingrtypingrrrr streamlitr streamlit.errorsr r streamlit.proto.ForwardMsg_pb2r r#r __annotations__rr)r9r:rr,rrrFsb)"22N98$$10 2 :'+* 0r