id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
178,229
import torch import numpy as np import requests from PIL import Image from mplug_owl.modeling_mplug_owl import MplugOwlForConditionalGeneration from mplug_owl.processing_mplug_owl import MplugOwlImageProcessor, MplugOwlProcessor from transformers import AutoTokenizer The provided code snippet includes necessary depend...
The interface for generation Args: prompts (List[str]): The prompt text image_list (List[str]): Paths of images model (MplugOwlForConditionalGeneration): MplugOwlForConditionalGeneration tokenizer (AutoTokenizer): AutoTokenizer processor (MplugOwlProcessor): MplugOwlProcessor use_bf16 (bool, optional): Whether to use b...
178,230
import math from typing import Any, Optional, Tuple, Union import torch from dataclasses import dataclass import torch.utils.checkpoint from torch import nn from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, BaseModelOutputWithPastAndCrossAttentions from transformers.modeling_utils i...
Build masks and position id for left to right model.
178,231
import math from typing import Any, Optional, Tuple, Union import torch from dataclasses import dataclass import torch.utils.checkpoint from torch import nn from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, BaseModelOutputWithPastAndCrossAttentions from transformers.modeling_utils i...
null
178,232
import math from typing import Any, Optional, Tuple, Union import torch from dataclasses import dataclass import torch.utils.checkpoint from torch import nn from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, BaseModelOutputWithPastAndCrossAttentions from transformers.modeling_utils i...
null
178,233
import re import torch import torch.utils.checkpoint from transformers.processing_utils import ProcessorMixin from transformers.tokenization_utils_base import BatchEncoding from transformers.models.clip.image_processing_clip import CLIPImageProcessor The provided code snippet includes necessary dependencies for implem...
Detokenize the generated tokens.
178,234
import re import torch import torch.utils.checkpoint from transformers.processing_utils import ProcessorMixin from transformers.tokenization_utils_base import BatchEncoding from transformers.models.clip.image_processing_clip import CLIPImageProcessor def _tokenize_prompts_and_batch(prompts, tokens_to_generate, add_BOS,...
Tokenize prompts and make them avaiable on all ranks.
178,235
import requests import streamlit as st def audio(): url = "https://www.w3schools.com/html/horse.ogg" file = requests.get(url).content st.audio(file)
null
178,236
import requests import streamlit as st def video(): url = "https://www.w3schools.com/html/mov_bbb.mp4" file = requests.get(url).content st.video(file)
null
178,237
import streamlit as st st.set_page_config( page_title="Heya, world?", page_icon=":shark:", layout="wide", initial_sidebar_state="collapsed", ) st.sidebar.button("Sidebar!") st.markdown("Main!") st.button("Balloons", on_click=show_balloons) st.button("Double Set Page Config", on_click=double_set_page_con...
null
178,238
import streamlit as st st.set_page_config( page_title="Heya, world?", page_icon=":shark:", layout="wide", initial_sidebar_state="collapsed", ) st.sidebar.button("Sidebar!") st.markdown("Main!") st.button("Balloons", on_click=show_balloons) st.button("Double Set Page Config", on_click=double_set_page_con...
null
178,239
import streamlit as st st.set_page_config( page_title="Heya, world?", page_icon=":shark:", layout="wide", initial_sidebar_state="collapsed", ) st.sidebar.button("Sidebar!") st.markdown("Main!") st.button("Balloons", on_click=show_balloons) st.button("Double Set Page Config", on_click=double_set_page_con...
null
178,240
import streamlit as st st.write( """ If this is failing locally, it could be because you have a browser with Streamlit open. Close it and the test should pass. """ ) def cached_write(value): st.write(value)
null
178,241
import streamlit as st st.write( """ If this is failing locally, it could be because you have a browser with Streamlit open. Close it and the test should pass. """ ) def cached_write_nowarn(value): st.write(value)
null
178,242
import streamlit as st st.write( """ If this is failing locally, it could be because you have a browser with Streamlit open. Close it and the test should pass. """ ) def cached_widget(name): st.button(name)
null
178,243
import io import numpy as np from PIL import Image, ImageDraw import streamlit as st def create_gif(size, frames=1): # Create grayscale image. im = Image.new("L", (size, size), "white") images = [] # Make circle of a constant size with a number of frames, moving across the # principal diagonal of...
null
178,244
import io import numpy as np from PIL import Image, ImageDraw import streamlit as st img = np.repeat(0, 10000).reshape(100, 100) def numpy_image(): st.image(img, caption="Black Square with no output format specified", width=100)
null
178,245
import io import numpy as np from PIL import Image, ImageDraw import streamlit as st def svg_image(): st.image( """ <svg> <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /> </svg> """ )
null
178,246
import io import numpy as np from PIL import Image, ImageDraw import streamlit as st gif = create_gif(64, frames=32) def gif_image(): st.image(gif, width=100)
null
178,247
import io import numpy as np from PIL import Image, ImageDraw import streamlit as st def url_image(): st.image("https://avatars.githubusercontent.com/anoctopus", width=200)
null
178,248
import streamlit as st from streamlit import runtime def on_checkbox_change(changed_checkbox_number): if changed_checkbox_number == 1: st.session_state.checkbox2 = False elif changed_checkbox_number == 2: st.session_state.checkbox1 = False
null
178,249
import io from typing import TYPE_CHECKING, Any import numpy as np from PIL import Image, ImageDraw import streamlit as st def create_gif(size, frames=1): # Create grayscale image. im = Image.new("L", (size, size), "white") images = [] # Make circle of a constant size with a number of frames, moving ...
null
178,250
import streamlit as st with st.sidebar: st.text_input("This is a label", key="1") draw_header_test(True) st.text("Headers in single st.markdown") st.text("Headers in multiple st.markdown") st.text("Headers in columns") st.text("Headers in columns with other elements above") st.text("Headers in column beside wid...
null
178,251
import streamlit as st def rerun_record(): return [0]
null
178,252
import numpy as np import pandas as pd import streamlit as st The provided code snippet includes necessary dependencies for implementing the `color_negative_red` function. Write a Python function `def color_negative_red(val)` to solve the following problem: Takes a scalar and returns a string with the css property `'c...
Takes a scalar and returns a string with the css property `'color: red'` for negative strings, black otherwise.
178,253
import numpy as np import pandas as pd import streamlit as st np.random.seed(24) The provided code snippet includes necessary dependencies for implementing the `highlight_max` function. Write a Python function `def highlight_max(data, color="yellow")` to solve the following problem: highlight the maximum in a Series o...
highlight the maximum in a Series or DataFrame
178,254
import numpy as np import streamlit as st img = np.repeat(0, 10000).reshape(100, 100) if st.checkbox("show image", True): image() def image(): st.image(img)
null
178,255
import streamlit as st from streamlit import runtime with st.form("foo"): form_file = st.file_uploader("Inside form:", type=["txt"]) st.form_submit_button("Submit") if form_file is None: st.text("No upload") else: st.text(form_file.read()) def file_uploader_on_change(): st.sessi...
null
178,256
import streamlit as st st.button("click to rerun") side_effects = [] st.text(side_effects) def foo(): side_effects.append("function ran") r = st.radio("radio", ["foo", "bar", "baz", "qux"], index=1) return r
null
178,257
from datetime import date import streamlit as st from streamlit import runtime st.sidebar.write("Value A:", s1) st.sidebar.write("Range Value A:", r1) with st.sidebar.expander("Expander", expanded=True): s2 = st.slider("Label B", 10000, 25000, 10000) st.write("Value B:", s2) r2 = st.slider("Range B", 10000,...
null
178,258
import numpy as np import pandas as pd import streamlit as st from streamlit import runtime st.write("Value 1:", w1) st.write("Value 2:", w2) st.write("Value 3:", w3) st.write("Value 4:", w4) st.write("Value 5:", w5) st.write("Value 6:", w6) st.write("Value 7:", w7) with st.expander("Expander", expanded=True): w9 =...
null
178,259
import random import streamlit as st from streamlit import config cache_was_hit = True if cache_was_hit: st.warning("You must clear your cache before you run this script!") st.write( """ To clear the cache, press `C` then `Enter`. Then press `R` on this page to rerun. """ ) else:...
null
178,260
import random import streamlit as st from streamlit import config def my_func(arg1, arg2=None, *args, **kwargs): return random.randint(0, 2**32)
null
178,262
import os import streamlit as st VIDEO_EXTENSIONS = ["mp4", "ogv", "m4v", "webm"] def get_video_files_in_dir(directory): out = [] for item in os.listdir(directory): try: name, ext = item.split(".") except: continue if name and ext: if ext in VIDEO_EXT...
null
178,263
import os import streamlit as st def shorten_vid_option(opt): return opt.split("/")[-1]
null
178,264
import io import os import wave import numpy as np import streamlit as st AUDIO_EXTENSIONS = ["wav", "flac", "mp3", "aac", "ogg", "oga", "m4a", "opus", "wma"] def get_audio_files_in_dir(directory): out = [] for item in os.listdir(directory): try: name, ext = item.split(".") except: ...
null
178,265
import io import os import wave import numpy as np import streamlit as st def note(freq, length, amp, rate): t = np.linspace(0, length, length * rate) data = np.sin(2 * np.pi * freq * t) * amp return data.astype(np.int16)
null
178,266
import io import os import wave import numpy as np import streamlit as st def shorten_audio_option(opt): return opt.split("/")[-1]
null
178,267
from __future__ import annotations import re import textwrap from typing import TYPE_CHECKING, Any, Final, cast from streamlit.errors import StreamlitAPIException The provided code snippet includes necessary dependencies for implementing the `decode_ascii` function. Write a Python function `def decode_ascii(string: by...
Decodes a string as ascii.
178,268
from __future__ import annotations import re import textwrap from typing import TYPE_CHECKING, Any, Final, cast from streamlit.errors import StreamlitAPIException def is_emoji(text: str) -> bool: class StreamlitAPIException(MarkdownFormattedException): def __repr__(self) -> str: def validate_emoji(maybe_emoji: s...
null
178,269
from __future__ import annotations import re import textwrap from typing import TYPE_CHECKING, Any, Final, cast from streamlit.errors import StreamlitAPIException The provided code snippet includes necessary dependencies for implementing the `max_char_sequence` function. Write a Python function `def max_char_sequence(...
Returns the count of the max sequence of a given char in a string.
178,270
from __future__ import annotations import re import textwrap from typing import TYPE_CHECKING, Any, Final, cast from streamlit.errors import StreamlitAPIException _RE_CONTAINS_HTML: Final = re.compile(r"(?:</[^<]+>)|(?:<[^<]+/>)") The provided code snippet includes necessary dependencies for implementing the `probably...
Returns True if the given string contains what seem to be HTML tags. Note that false positives/negatives are possible, so this function should not be used in contexts where complete correctness is required.
178,271
from __future__ import annotations from streamlit.proto.ForwardMsg_pb2 import ForwardMsg from streamlit.runtime.scriptrunner import get_script_run_ctx The provided code snippet includes necessary dependencies for implementing the `post_parent_message` function. Write a Python function `def post_parent_message(message:...
Sends a string message to the parent window (when host configuration allows).
178,272
from __future__ import annotations import os from typing import Final, NoReturn import streamlit as st from streamlit import source_util from streamlit.deprecation_util import make_deprecated_name_warning from streamlit.errors import NoSessionContext, StreamlitAPIException from streamlit.file_util import get_main_scrip...
Stops execution immediately. Streamlit will not run any statements after `st.stop()`. We recommend rendering a message to explain why the script has stopped. Example ------- >>> import streamlit as st >>> >>> name = st.text_input('Name') >>> if not name: >>> st.warning('Please input a name.') >>> st.stop() >>> st.succe...
178,273
from __future__ import annotations import os from typing import Final, NoReturn import streamlit as st from streamlit import source_util from streamlit.deprecation_util import make_deprecated_name_warning from streamlit.errors import NoSessionContext, StreamlitAPIException from streamlit.file_util import get_main_scrip...
Rerun the script immediately. When ``st.experimental_rerun()`` is called, the script is halted - no more statements will be run, and the script will be queued to re-run from the top.
178,274
from __future__ import annotations import os from typing import Final, NoReturn import streamlit as st from streamlit import source_util from streamlit.deprecation_util import make_deprecated_name_warning from streamlit.errors import NoSessionContext, StreamlitAPIException from streamlit.file_util import get_main_scrip...
Programmatically switch the current page in a multipage app. When ``st.switch_page`` is called, the current page execution stops and the specified page runs as if the user clicked on it in the sidebar navigation. The specified page must be recognized by Streamlit's multipage architecture (your main Python file or a Pyt...
178,275
from __future__ import annotations import random from textwrap import dedent from typing import TYPE_CHECKING, Final, Literal, Mapping, Union, cast from typing_extensions import TypeAlias from streamlit.elements import image from streamlit.errors import StreamlitAPIException from streamlit.proto.ForwardMsg_pb2 import F...
Configures the default settings of the page. .. note:: This must be the first Streamlit command used on an app page, and must only be set once per page. Parameters ---------- page_title: str or None The page title, shown in the browser tab. If None, defaults to the filename of the script ("app.py" would show "app • Str...
178,276
from __future__ import annotations import urllib.parse as parse from typing import Any from streamlit import util from streamlit.constants import ( EMBED_OPTIONS_QUERY_PARAM, EMBED_QUERY_PARAM, EMBED_QUERY_PARAMS_KEYS, ) from streamlit.errors import StreamlitAPIException from streamlit.proto.ForwardMsg_pb2 ...
Return the query parameters that is currently showing in the browser's URL bar. Returns ------- dict The current query parameters as a dict. "Query parameters" are the part of the URL that comes after the first "?". Example ------- Let's say the user's web browser is at `http://localhost:8501/?show_map=True&selected=as...
178,277
from __future__ import annotations import urllib.parse as parse from typing import Any from streamlit import util from streamlit.constants import ( EMBED_OPTIONS_QUERY_PARAM, EMBED_QUERY_PARAM, EMBED_QUERY_PARAMS_KEYS, ) from streamlit.errors import StreamlitAPIException from streamlit.proto.ForwardMsg_pb2 ...
Set the query parameters that are shown in the browser's URL bar. .. warning:: Query param `embed` cannot be set using this method. Parameters ---------- **query_params : dict The query parameters to set, as key-value pairs. Example ------- To point the user's web browser to something like "http://localhost:8501/?show_...
178,278
from __future__ import annotations import functools from typing import Any, Callable, Final, TypeVar, cast import streamlit from streamlit import config from streamlit.logger import get_logger TFunc = TypeVar("TFunc", bound=Callable[..., Any]) def show_deprecation_warning(message: str) -> None: """Show a deprecatio...
Wrap an `st` function whose name has changed. Wrapped functions will run as normal, but will also show an st.warning saying that the old name will be removed after removal_date. (We generally set `removal_date` to 3 months from the deprecation date.) Parameters ---------- func The `st.` function whose name has changed....
178,279
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
null
178,280
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
null
178,281
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
null
178,282
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
null
178,283
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
null
178,284
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
null
178,285
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
null
178,286
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
null
178,287
from __future__ import annotations import os import re from datetime import timedelta from typing import Any, Final, Literal, TypeVar, overload from streamlit.connections import ( BaseConnection, SnowflakeConnection, SnowparkConnection, SQLConnection, ) from streamlit.deprecation_util import deprecate_o...
Create a new connection to a data store or API, or return an existing one. Config options, credentials, secrets, etc. for connections are taken from various sources: - Any connection-specific configuration files. - An app's ``secrets.toml`` files. - The kwargs passed to this function. Parameters ---------- name : str T...
178,288
from __future__ import annotations import collections import threading from typing import Final from streamlit.logger import get_logger from streamlit.runtime.media_file_storage import MediaFileKind, MediaFileStorage The provided code snippet includes necessary dependencies for implementing the `_get_session_id` funct...
Get the active AppSession's session_id.
178,289
from __future__ import annotations import itertools from abc import abstractmethod from typing import TYPE_CHECKING, NamedTuple, Protocol, runtime_checkable class CacheStat(NamedTuple): """Describes a single cache entry. Properties ---------- category_name : str A human-readable name for the cac...
Group a list of CacheStats by category_name and cache_name and sum byte_length
178,290
from __future__ import annotations import hashlib from typing import TYPE_CHECKING, Final, MutableMapping from weakref import WeakKeyDictionary from streamlit import config, util from streamlit.logger import get_logger from streamlit.proto.ForwardMsg_pb2 import ForwardMsg from streamlit.runtime.stats import CacheStat, ...
Create a ForwardMsg that refers to the given message via its hash. The reference message will also get a copy of the source message's metadata. Parameters ---------- msg : ForwardMsg The ForwardMsg to create the reference to. Returns ------- ForwardMsg A new ForwardMsg that "points" to the original message via the ref_...
178,291
from __future__ import annotations import asyncio import sys import uuid from enum import Enum from typing import TYPE_CHECKING, Callable, Final import streamlit.elements.exception as exception_utils from streamlit import config, runtime, source_util from streamlit.case_converters import to_snake_case from streamlit.lo...
Randomly generate a unique ID for a script execution.
178,292
from __future__ import annotations import asyncio import sys import uuid from enum import Enum from typing import TYPE_CHECKING, Callable, Final import streamlit.elements.exception as exception_utils from streamlit import config, runtime, source_util from streamlit.case_converters import to_snake_case from streamlit.lo...
null
178,293
from __future__ import annotations import asyncio import sys import uuid from enum import Enum from typing import TYPE_CHECKING, Callable, Final import streamlit.elements.exception as exception_utils from streamlit import config, runtime, source_util from streamlit.case_converters import to_snake_case from streamlit.lo...
null
178,294
from __future__ import annotations import asyncio import sys import uuid from enum import Enum from typing import TYPE_CHECKING, Callable, Final import streamlit.elements.exception as exception_utils from streamlit import config, runtime, source_util from streamlit.case_converters import to_snake_case from streamlit.lo...
null
178,295
from __future__ import annotations import asyncio import sys import uuid from enum import Enum from typing import TYPE_CHECKING, Callable, Final import streamlit.elements.exception as exception_utils from streamlit import config, runtime, source_util from streamlit.case_converters import to_snake_case from streamlit.lo...
null
178,296
from __future__ import annotations import contextlib import inspect import os import sys import threading import time import uuid from collections.abc import Sized from functools import wraps from typing import Any, Callable, Final, TypeVar, cast, overload from streamlit import config, util from streamlit.logger import...
Get the machine ID This is a unique identifier for a user for tracking metrics in Segment, that is broken in different ways in some Linux distros and Docker images. - at times just a hash of '', which means many machines map to the same ID - at times a hash of the same string, when running in a Docker container
178,297
from __future__ import annotations import contextlib import inspect import os import sys import threading import time import uuid from collections.abc import Sized from functools import wraps from typing import Any, Callable, Final, TypeVar, cast, overload from streamlit import config, util from streamlit.logger import...
null
178,298
from __future__ import annotations import contextlib import inspect import os import sys import threading import time import uuid from collections.abc import Sized from functools import wraps from typing import Any, Callable, Final, TypeVar, cast, overload from streamlit import config, util from streamlit.logger import...
null
178,299
from __future__ import annotations import contextlib import inspect import os import sys import threading import time import uuid from collections.abc import Sized from functools import wraps from typing import Any, Callable, Final, TypeVar, cast, overload from streamlit import config, util from streamlit.logger import...
Function decorator to add telemetry tracking to commands. Parameters ---------- func : callable The function to track for telemetry. name : str or None Overwrite the function name with a custom name that is used for telemetry tracking. Example ------- >>> @st.gather_metrics ... def my_command(url): ... return url >>> @...
178,300
from __future__ import annotations import contextlib import inspect import os import sys import threading import time import uuid from collections.abc import Sized from functools import wraps from typing import Any, Callable, Final, TypeVar, cast, overload from streamlit import config, util from streamlit.logger import...
Create and return the full PageProfile ForwardMsg.
178,301
from __future__ import annotations import contextlib import functools import hashlib import inspect import math import os import pickle import shutil import threading import time from collections import namedtuple from dataclasses import dataclass from typing import Any, Callable, Final, Iterator, TypeVar, cast, overlo...
If appropriate, warn about calling st.foo inside @cache. DeltaGenerator's @_with_element and @_widget wrappers use this to warn the user when they're calling st.foo() from within a function that is wrapped in @st.cache. Parameters ---------- dg : DeltaGenerator The DeltaGenerator to publish the warning to. st_func_name...
178,302
from __future__ import annotations import contextlib import functools import hashlib import inspect import math import os import pickle import shutil import threading import time from collections import namedtuple from dataclasses import dataclass from typing import Any, Callable, Final, Iterator, TypeVar, cast, overlo...
Clear the memoization cache. Returns ------- boolean True if the disk cache was cleared. False otherwise (e.g. cache file doesn't exist on disk).
178,303
from __future__ import annotations import contextlib import functools import hashlib import inspect import math import os import pickle import shutil import threading import time from collections import namedtuple from dataclasses import dataclass from typing import Any, Callable, Final, Iterator, TypeVar, cast, overlo...
Get markdown representation of the function name.
178,304
from __future__ import annotations import collections import enum import functools import hashlib import inspect import io import os import pickle import sys import tempfile import textwrap import threading import weakref from typing import Any, Callable, Dict, Pattern, Type, Union from streamlit import config, file_ut...
null
178,305
from __future__ import annotations import collections import enum import functools import hashlib import inspect import io import os import pickle import sys import tempfile import textwrap import threading import weakref from typing import Any, Callable, Dict, Pattern, Type, Union from streamlit import config, file_ut...
null
178,306
from __future__ import annotations import collections import enum import functools import hashlib import inspect import io import os import pickle import sys import tempfile import textwrap import threading import weakref from typing import Any, Callable, Dict, Pattern, Type, Union from streamlit import config, file_ut...
Return key for memoization.
178,307
from __future__ import annotations import collections import enum import functools import hashlib import inspect import io import os import pickle import sys import tempfile import textwrap import threading import weakref from typing import Any, Callable, Dict, Pattern, Type, Union from streamlit import config, file_ut...
null
178,308
from __future__ import annotations import collections import enum import functools import hashlib import inspect import io import os import pickle import sys import tempfile import textwrap import threading import weakref from typing import Any, Callable, Dict, Pattern, Type, Union from streamlit import config, file_ut...
null
178,309
from __future__ import annotations import collections import enum import functools import hashlib import inspect import io import os import pickle import sys import tempfile import textwrap import threading import weakref from typing import Any, Callable, Dict, Pattern, Type, Union from streamlit import config, file_ut...
Get list of strings (lines of code) from lineno to lineno+3. Ideally we'd return the exact line where the error took place, but there are reasons why this is not possible without a lot of work, including playing with the AST. So for now we're returning 3 lines near where the error took place.
178,310
from __future__ import annotations import json import os import sys import textwrap from collections import namedtuple from datetime import datetime from typing import Final, NoReturn from uuid import uuid4 from streamlit import cli_util, env_util, file_util, util from streamlit.logger import get_logger if env_util.IS_...
null
178,311
from __future__ import annotations import json import os import sys import textwrap from collections import namedtuple from datetime import datetime from typing import Final, NoReturn from uuid import uuid4 from streamlit import cli_util, env_util, file_util, util from streamlit.logger import get_logger The provided c...
Send the user's email to segment.io, if submitted
178,312
from __future__ import annotations import json import os import sys import textwrap from collections import namedtuple from datetime import datetime from typing import Final, NoReturn from uuid import uuid4 from streamlit import cli_util, env_util, file_util, util from streamlit.logger import get_logger _LOGGER: Final ...
Verify the user's email address. The email can either be an empty string (if the user chooses not to enter it), or a string with a single '@' somewhere in it. Parameters ---------- email : str Returns ------- _Activation An _Activation object. Its 'is_valid' property will be True only if the email was validated.
178,313
from __future__ import annotations import json import os import sys import textwrap from collections import namedtuple from datetime import datetime from typing import Final, NoReturn from uuid import uuid4 from streamlit import cli_util, env_util, file_util, util from streamlit.logger import get_logger _LOGGER: Final ...
Exit program with error.
178,314
from __future__ import annotations from typing import Any from streamlit.runtime.metrics_util import gather_metrics The provided code snippet includes necessary dependencies for implementing the `transparent_write` function. Write a Python function `def transparent_write(*args: Any) -> Any` to solve the following prob...
The function that gets magic-ified into Streamlit apps. This is just st.write, but returns the arguments you passed to it.
178,315
from __future__ import annotations import collections import threading from dataclasses import dataclass, field from typing import Callable, Counter, Dict, Final, Union from urllib import parse from typing_extensions import TypeAlias from streamlit import runtime from streamlit.errors import StreamlitAPIException from ...
Adds the current ScriptRunContext to a newly-created thread. This should be called from this thread's parent thread, before the new thread starts. Parameters ---------- thread : threading.Thread The thread to attach the current ScriptRunContext to. ctx : ScriptRunContext or None The ScriptRunContext to add, or None to ...
178,316
from __future__ import annotations import gc import sys import threading import types from contextlib import contextmanager from enum import Enum from timeit import default_timer as timer from typing import Callable, Final from blinker import Signal from streamlit import config, runtime, source_util, util from streamli...
Some modules are stateful, so we have to clear their state.
178,317
from __future__ import annotations import gc import sys import threading import types from contextlib import contextmanager from enum import Enum from timeit import default_timer as timer from typing import Callable, Final from blinker import Signal from streamlit import config, runtime, source_util, util from streamli...
null
178,318
from __future__ import annotations import ast from typing import Any, Final from streamlit import config def _modify_ast_subtree( tree: Any, body_attr: str = "body", is_root: bool = False, file_ends_in_semicolon: bool = False, ): """Parses magic commands and modifies the given AST (sub)tree.""" ...
Modifies the code to support magic Streamlit commands. Parameters ---------- code : str The Python code. script_path : str The path to the script file. Returns ------- ast.Module The syntax tree for the code.
178,319
from __future__ import annotations from typing import Any from streamlit import config from streamlit.errors import MarkdownFormattedException from streamlit.proto.ForwardMsg_pb2 import ForwardMsg from streamlit.runtime.forward_msg_cache import populate_hash_if_needed The provided code snippet includes necessary depen...
True if the given message qualifies for caching.
178,320
from __future__ import annotations from typing import Any from streamlit import config from streamlit.errors import MarkdownFormattedException from streamlit.proto.ForwardMsg_pb2 import ForwardMsg from streamlit.runtime.forward_msg_cache import populate_hash_if_needed class MessageSizeError(MarkdownFormattedException):...
Serialize a ForwardMsg to send to a client. If the message is too large, it will be converted to an exception message instead.
178,321
from __future__ import annotations import pickle import threading import types from datetime import timedelta from typing import Any, Callable, Final, Literal, TypeVar, Union, cast, overload from typing_extensions import TypeAlias import streamlit as st from streamlit import runtime from streamlit.deprecation_util impo...
Return the StatsProvider for all @st.cache_data functions.
178,322
from __future__ import annotations import types from typing import Any from streamlit import type_util from streamlit.errors import ( MarkdownFormattedException, StreamlitAPIException, StreamlitAPIWarning, ) from streamlit.runtime.caching.cache_type import CacheType, get_decorator_api_name def get_cached_fu...
null
178,323
from __future__ import annotations import functools import hashlib import inspect import math import threading import time import types from abc import abstractmethod from collections import defaultdict from datetime import timedelta from typing import Any, Callable, Final, Literal, overload from streamlit import type_...
null
178,324
from __future__ import annotations import functools import hashlib import inspect import math import threading import time import types from abc import abstractmethod from collections import defaultdict from datetime import timedelta from typing import Any, Callable, Final, Literal, overload from streamlit import type_...
null
178,325
from __future__ import annotations import functools import hashlib import inspect import math import threading import time import types from abc import abstractmethod from collections import defaultdict from datetime import timedelta from typing import Any, Callable, Final, Literal, overload from streamlit import type_...
Convert a ttl value to a float representing "number of seconds".
178,326
from __future__ import annotations import functools import hashlib import inspect import math import threading import time import types from abc import abstractmethod from collections import defaultdict from datetime import timedelta from typing import Any, Callable, Final, Literal, overload from streamlit import type_...
Create a callable wrapper around a CachedFunctionInfo. Calling the wrapper will return the cached value if it's already been computed, and will call the underlying function to compute and cache the value otherwise. The wrapper also has a `clear` function that can be called to clear all of the wrapper's cached values.
178,327
from __future__ import annotations import functools import hashlib import inspect import math import threading import time import types from abc import abstractmethod from collections import defaultdict from datetime import timedelta from typing import Any, Callable, Final, Literal, overload from streamlit import type_...
Create the key for a value within a cache. This key is generated from the function's arguments. All arguments will be hashed, except for those named with a leading "_". Raises ------ StreamlitAPIException Raised (with a nicely-formatted explanation message) if we encounter an un-hashable arg.
178,328
from __future__ import annotations import functools import hashlib import inspect import math import threading import time import types from abc import abstractmethod from collections import defaultdict from datetime import timedelta from typing import Any, Callable, Final, Literal, overload from streamlit import type_...
Create the unique key for a function's cache. A function's key is stable across reruns of the app, and changes when the function's source code changes.
178,329
from __future__ import annotations import collections import dataclasses import datetime import functools import hashlib import inspect import io import os import pickle import sys import tempfile import threading import uuid import weakref from enum import Enum from typing import Any, Callable, Dict, Final, Pattern, T...
null