instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Fully document this Python code with docstrings |
import dataclasses
from pathlib import Path
from types import SimpleNamespace
from reflex.constants.base import Dirs
from reflex.constants.compiler import Ext, PageNames
from reflex.plugins.shared_tailwind import (
TailwindConfig,
TailwindPlugin,
tailwind_config_js_template,
)
class Constants(SimpleName... | --- +++ @@ -1,3 +1,4 @@+"""Base class for all plugins."""
import dataclasses
from pathlib import Path
@@ -13,6 +14,7 @@
class Constants(SimpleNamespace):
+ """Tailwind constants."""
# The Tailwindcss version
VERSION = "tailwindcss@4.1.18"
@@ -37,6 +39,14 @@
def compile_config(config: Tailwind... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/plugins/tailwind_v4.py |
Add docstrings for better understanding |
from collections.abc import Callable, Sequence
from pathlib import Path
from typing import TYPE_CHECKING, ParamSpec, Protocol, TypedDict
from typing_extensions import Unpack
if TYPE_CHECKING:
from reflex.app import App, UnevaluatedPage
class CommonContext(TypedDict):
P = ParamSpec("P")
class AddTaskProtoco... | --- +++ @@ -1,3 +1,4 @@+"""Base class for all plugins."""
from collections.abc import Callable, Sequence
from pathlib import Path
@@ -10,12 +11,14 @@
class CommonContext(TypedDict):
+ """Common context for all plugins."""
P = ParamSpec("P")
class AddTaskProtocol(Protocol):
+ """Protocol for addi... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/plugins/base.py |
Create docstrings for all classes and functions |
from __future__ import annotations
from importlib.util import find_spec
from pathlib import Path
from typing import TYPE_CHECKING
import click
from reflex_cli.v2.deployments import hosting_cli
from reflex import constants
from reflex.config import get_config
from reflex.custom_components.custom_components import cu... | --- +++ @@ -1,3 +1,4 @@+"""Reflex CLI to create, run, and deploy apps."""
from __future__ import annotations
@@ -21,6 +22,13 @@
def set_loglevel(ctx: click.Context, self: click.Parameter, value: str | None):
+ """Set the log level.
+
+ Args:
+ ctx: The click context.
+ self: The click comma... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/reflex.py |
Provide docstrings following PEP 257 |
import functools
import os
import tempfile
from collections.abc import Sequence
from pathlib import Path
from packaging import version
from reflex import constants
from reflex.config import Config, get_config
from reflex.environment import environment
from reflex.utils import console, net, path_ops, processes
from r... | --- +++ @@ -1,3 +1,4 @@+"""This module provides utilities for managing JavaScript runtimes like Node.js and Bun."""
import functools
import os
@@ -17,6 +18,11 @@
def check_node_version() -> bool:
+ """Check the version of Node.js.
+
+ Returns:
+ Whether the version of Node.js is valid.
+ """
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/js_runtimes.py |
Add docstrings for utility scripts |
from __future__ import annotations
import hashlib
import importlib.util
import json
import os
import platform
import re
import subprocess
import sys
from collections.abc import Sequence
from pathlib import Path
from typing import Any, NamedTuple, TypedDict
from urllib.parse import urljoin
from reflex import constant... | --- +++ @@ -1,3 +1,4 @@+"""Everything regarding execution of the built app."""
from __future__ import annotations
@@ -28,6 +29,14 @@
def get_package_json_and_hash(package_json_path: Path) -> tuple[PackageJson, str]:
+ """Get the content of package.json and its hash.
+
+ Args:
+ package_json_path: ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/exec.py |
Improve documentation using docstrings |
import dataclasses
from pathlib import Path
from types import SimpleNamespace
from reflex.constants.base import Dirs
from reflex.constants.compiler import Ext, PageNames
from reflex.plugins.shared_tailwind import (
TailwindConfig,
TailwindPlugin,
tailwind_config_js_template,
)
class Constants(SimpleName... | --- +++ @@ -1,3 +1,4 @@+"""Base class for all plugins."""
import dataclasses
from pathlib import Path
@@ -13,6 +14,7 @@
class Constants(SimpleNamespace):
+ """Tailwind constants."""
# The Tailwindcss version
VERSION = "tailwindcss@3.4.17"
@@ -38,6 +40,14 @@
def compile_config(config: Tailwind... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/plugins/tailwind_v3.py |
Help me write clear docstrings |
import asyncio
import contextlib
from collections.abc import AsyncIterator
from typing import Self, TypeVar
from reflex.constants import ROUTER_DATA
from reflex.event import Event, get_hydrate_event
from reflex.state import BaseState, State, _override_base_method, _substate_key
from reflex.utils import console
from r... | --- +++ @@ -1,3 +1,4 @@+"""Base classes for shared / linked states."""
import asyncio
import contextlib
@@ -15,6 +16,11 @@
def _log_update_client_errors(task: asyncio.Task):
+ """Log errors from updating other clients.
+
+ Args:
+ task: The asyncio task to check for errors.
+ """
try:
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/istate/shared.py |
Write docstrings describing functionality |
from __future__ import annotations
import asyncio
import copy
import dataclasses
import functools
import inspect
import json
import sys
from collections.abc import Callable, Sequence
from importlib.util import find_spec
from types import MethodType
from typing import TYPE_CHECKING, Any, SupportsIndex, TypeVar
import... | --- +++ @@ -1,3 +1,4 @@+"""A module to hold state proxy classes."""
from __future__ import annotations
@@ -30,12 +31,46 @@
class StateProxy(wrapt.ObjectProxy):
+ """Proxy of a state instance to control mutability of vars for a background task.
+
+ Since a background task runs against a state instance wit... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/istate/proxy.py |
Create simple docstrings for beginners |
import dataclasses
import inspect
import sys
import types
from base64 import b64encode
from collections.abc import Callable, Mapping, Sequence
from functools import lru_cache, partial
from typing import (
TYPE_CHECKING,
Annotated,
Any,
Generic,
Literal,
NoReturn,
Protocol,
TypeVar,
... | --- +++ @@ -1,3 +1,4 @@+"""Define event classes to connect the frontend and backend."""
import dataclasses
import inspect
@@ -60,6 +61,7 @@ frozen=True,
)
class Event:
+ """An event that describes any state change in the app."""
# The token to specify the client that the event is for.
token: st... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/event.py |
Add docstrings to meet PEP guidelines |
from __future__ import annotations
import asyncio
import builtins
import contextlib
import copy
import dataclasses
import datetime
import functools
import inspect
import pickle
import re
import sys
import time
import uuid
import warnings
from collections.abc import AsyncIterator, Callable, Iterator, Sequence
from enu... | --- +++ @@ -1,3 +1,4 @@+"""Define the reflex state specification."""
from __future__ import annotations
@@ -103,6 +104,19 @@
def _no_chain_background_task(state: BaseState, name: str, fn: Callable) -> Callable:
+ """Protect against directly chaining a background task from another event handler.
+
+ Args:... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/state.py |
Fill in missing docstrings in my code |
from __future__ import annotations
import dataclasses
from collections import defaultdict
from collections.abc import Mapping, Sequence
def merge_parsed_imports(
*imports: ImmutableParsedImportDict,
) -> ParsedImportDict:
all_imports: defaultdict[str, list[ImportVar]] = defaultdict(list)
for import_dict... | --- +++ @@ -1,3 +1,4 @@+"""Import operations."""
from __future__ import annotations
@@ -9,6 +10,14 @@ def merge_parsed_imports(
*imports: ImmutableParsedImportDict,
) -> ParsedImportDict:
+ """Merge multiple parsed import dicts together.
+
+ Args:
+ *imports: The list of import dicts to merge.
+... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/imports.py |
Generate consistent docstrings |
import json
import random
import re
from pathlib import Path
from reflex import constants
from reflex.compiler import templates
from reflex.config import Config, get_config
from reflex.environment import environment
from reflex.utils import console, path_ops
from reflex.utils.prerequisites import get_project_hash, ge... | --- +++ @@ -1,3 +1,4 @@+"""This module provides utility functions to initialize the frontend skeleton."""
import json
import random
@@ -17,6 +18,12 @@ gitignore_file: Path = constants.GitIgnore.FILE,
files_to_ignore: set[str] | list[str] = constants.GitIgnore.DEFAULTS,
):
+ """Initialize the template .... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/frontend_skeleton.py |
Generate docstrings with examples |
from __future__ import annotations
import copy
import importlib
import os
import sys
def attach(
package_name: str,
submodules: set[str] | None = None,
submod_attrs: dict[str, list[str]] | None = None,
**extra_mappings,
):
submod_attrs = copy.deepcopy(submod_attrs)
if submod_attrs:
f... | --- +++ @@ -1,3 +1,19 @@+"""Module to implement lazy loading in reflex.
+
+BSD 3-Clause License
+
+Copyright (c) 2022--2023, Scientific Python project All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/lazy_loader.py |
Add docstrings for internal functions |
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, Literal, get_args
if TYPE_CHECKING:
from reflex.vars import Var
ColorType = Literal[
"gray",
"mauve",
"slate",
"sage",
"olive",
"sand",
"tomato",
"red",
"ruby",
"crimson... | --- +++ @@ -1,3 +1,4 @@+"""The colors used in Reflex are a wrapper around https://www.radix-ui.com/colors."""
from __future__ import annotations
@@ -54,6 +55,16 @@ def format_color(
color: ColorType | Var[str], shade: ShadeType | Var[int], alpha: bool | Var[bool]
) -> str:
+ """Format a color as a CSS col... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/constants/colors.py |
Include argument descriptions in docstrings |
import contextlib
import functools
import inspect
import threading
from collections.abc import AsyncGenerator, Awaitable, Callable, Generator
from typing import TypeVar, overload
from reflex.config import get_config
try:
from pyleak import no_event_loop_blocking, no_task_leaks, no_thread_leaks
from pyleak.ba... | --- +++ @@ -1,3 +1,4 @@+"""PyLeak integration for monitoring event loop blocking and resource leaks in Reflex applications."""
import contextlib
import functools
@@ -24,6 +25,11 @@
def is_pyleak_enabled() -> bool:
+ """Check if PyLeak monitoring is enabled and available.
+
+ Returns:
+ True if PyLe... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/monitoring.py |
Add docstrings for utility scripts |
import asyncio
import contextlib
import dataclasses
import functools
import time
from collections.abc import AsyncIterator
from hashlib import md5
from pathlib import Path
from typing_extensions import Unpack, override
from reflex.environment import environment
from reflex.istate.manager import (
StateManager,
... | --- +++ @@ -1,3 +1,4 @@+"""A state manager that stores states on disk."""
import asyncio
import contextlib
@@ -23,6 +24,7 @@
@dataclasses.dataclass(frozen=True)
class QueueItem:
+ """An item in the write queue."""
token: str
state: BaseState
@@ -31,6 +33,7 @@
@dataclasses.dataclass
class StateM... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/istate/manager/disk.py |
Create simple docstrings for beginners |
import asyncio
import contextlib
import inspect
import sys
import threading
from collections.abc import Callable
from pathlib import Path
from typing import Any
def get_module_path(module_name: str) -> Path | None:
parts = module_name.split(".")
# Check each path in sys.path
for path in sys.path:
... | --- +++ @@ -1,3 +1,4 @@+"""Miscellaneous functions for the experimental package."""
import asyncio
import contextlib
@@ -10,6 +11,17 @@
def get_module_path(module_name: str) -> Path | None:
+ """Check if a module exists and return its path.
+
+ This function searches for a module by navigating through the... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/misc.py |
Insert docstrings into my code |
import functools
import time
from collections.abc import Callable
from typing import ParamSpec, TypeVar
from reflex.utils.decorator import once
from reflex.utils.types import Unset
from . import console
def _httpx_verify_kwarg() -> bool:
from reflex.environment import environment
return not environment.SS... | --- +++ @@ -1,3 +1,4 @@+"""Helpers for downloading files from the network."""
import functools
import time
@@ -11,6 +12,11 @@
def _httpx_verify_kwarg() -> bool:
+ """Get the value of the HTTPX verify keyword argument.
+
+ Returns:
+ True if SSL verification is enabled, False otherwise
+ """
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/net.py |
Add concise docstrings to each method |
from __future__ import annotations
import collections
import contextlib
import os
import signal
import socket
import subprocess
import sys
from collections.abc import Callable, Generator, Sequence
from concurrent import futures
from contextlib import closing
from pathlib import Path
from typing import Any, Literal, o... | --- +++ @@ -1,3 +1,4 @@+"""Process operations."""
from __future__ import annotations
@@ -25,10 +26,23 @@
def kill(pid: int):
+ """Kill a process.
+
+ Args:
+ pid: The process ID.
+ """
os.kill(pid, signal.SIGTERM)
def get_num_workers() -> int:
+ """Get the number of backend worker ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/processes.py |
Improve documentation using docstrings |
import dataclasses
from collections.abc import Mapping
from types import MappingProxyType
from typing import TYPE_CHECKING
from urllib.parse import _NetlocResultMixinStr, parse_qsl, urlsplit
from reflex import constants
from reflex.utils import console, format
from reflex.utils.serializers import serializer
@datacl... | --- +++ @@ -1,3 +1,4 @@+"""This module contains the dataclasses representing the router object."""
import dataclasses
from collections.abc import Mapping
@@ -68,9 +69,18 @@
@dataclasses.dataclass(frozen=True)
class HeaderData(_HeaderData):
+ """An object containing headers data."""
@classmethod
de... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/istate/data.py |
Generate docstrings for each module |
import functools
from collections.abc import Callable
from pathlib import Path
from typing import ParamSpec, TypeVar, cast
T = TypeVar("T")
def once(f: Callable[[], T]) -> Callable[[], T]:
unset = object()
value: object | T = unset
@functools.wraps(f)
def wrapper() -> T:
nonlocal value
... | --- +++ @@ -1,3 +1,4 @@+"""Decorator utilities."""
import functools
from collections.abc import Callable
@@ -8,6 +9,14 @@
def once(f: Callable[[], T]) -> Callable[[], T]:
+ """A decorator that calls the function once and caches the result.
+
+ Args:
+ f: The function to call.
+
+ Returns:
+ ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/decorator.py |
Generate docstrings for this script |
from pathlib import Path
from reflex.environment import environment
from reflex.utils import console, net
from reflex.utils.decorator import cache_result_in_disk, once
def latency(registry: str) -> int:
import httpx
try:
time_to_respond = net.get(registry, timeout=2).elapsed.microseconds
except... | --- +++ @@ -1,3 +1,4 @@+"""Utilities for working with registries."""
from pathlib import Path
@@ -7,6 +8,14 @@
def latency(registry: str) -> int:
+ """Get the latency of a registry.
+
+ Args:
+ registry (str): The URL of the registry.
+
+ Returns:
+ int: The latency of the registry in mi... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/registry.py |
Document functions with clear intent |
from __future__ import annotations
import asyncio
import dataclasses
import pickle
import uuid
from abc import ABC, abstractmethod
from collections.abc import AsyncIterator, Callable, Coroutine
from types import MappingProxyType
from typing import TYPE_CHECKING, ClassVar
from reflex.istate.manager.redis import State... | --- +++ @@ -1,3 +1,4 @@+"""Token manager for handling client token to session ID mappings."""
from __future__ import annotations
@@ -20,11 +21,17 @@
def _get_new_token() -> str:
+ """Generate a new unique token.
+
+ Returns:
+ A new UUID4 token string.
+ """
return str(uuid.uuid4())
@... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/token_manager.py |
Generate documentation strings for clarity |
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from urllib.parse import SplitResult
def open_browser(target_url: "SplitResult") -> None:
import webbrowser
from reflex.utils import console
if not webbrowser.open(target_url.geturl()):
console.warn(
f"Unable to automatically o... | --- +++ @@ -1,3 +1,4 @@+"""Utilities to handle redirection to browser UI."""
from typing import TYPE_CHECKING
@@ -6,6 +7,11 @@
def open_browser(target_url: "SplitResult") -> None:
+ """Open a browser window to target_url.
+
+ Args:
+ target_url: The URL to open in the browser.
+ """
import... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/redir.py |
Add docstrings to improve code quality |
from __future__ import annotations
import re
from collections.abc import Callable
from reflex import constants
from reflex.config import get_config
def verify_route_validity(route: str) -> None:
route_parts = route.removeprefix("/").split("/")
for i, part in enumerate(route_parts):
if constants.Rou... | --- +++ @@ -1,3 +1,4 @@+"""The route decorator and associated variables and functions."""
from __future__ import annotations
@@ -9,6 +10,14 @@
def verify_route_validity(route: str) -> None:
+ """Verify if the route is valid, and throw an error if not.
+
+ Args:
+ route: The route that need to be c... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/route.py |
Improve my code by adding docstrings |
import asyncio
import dataclasses
import importlib.metadata
import json
import multiprocessing
import platform
import warnings
from contextlib import suppress
from datetime import datetime, timezone
from typing import TypedDict
from reflex import constants
from reflex.environment import environment
from reflex.utils ... | --- +++ @@ -1,3 +1,4 @@+"""Anonymous telemetry for Reflex."""
import asyncio
import dataclasses
@@ -24,6 +25,7 @@
@dataclasses.dataclass(frozen=True)
class CpuInfo:
+ """Model to save cpu info."""
manufacturer_id: str | None
model_name: str | None
@@ -31,6 +33,14 @@
def format_address_width(ad... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/telemetry.py |
Create docstrings for each class method |
from __future__ import annotations
import contextlib
import copy
import dataclasses
import datetime
import functools
import inspect
import json
import re
import string
import uuid
import warnings
from abc import ABCMeta
from collections.abc import Callable, Coroutine, Iterable, Mapping, Sequence
from dataclasses impo... | --- +++ @@ -1,3 +1,4 @@+"""Collection of base classes."""
from __future__ import annotations
@@ -100,6 +101,7 @@ frozen=True,
)
class VarSubclassEntry:
+ """Entry for a Var subclass."""
var_subclass: type[Var]
to_var_subclass: type[ToOperation]
@@ -115,6 +117,7 @@ frozen=True,
)
class Va... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/vars/base.py |
Generate docstrings with parameter types |
from __future__ import annotations
import contextlib
import importlib
import importlib.metadata
import inspect
import json
import random
import re
import sys
import typing
from datetime import datetime
from os import getcwd
from pathlib import Path
from types import ModuleType
from typing import NamedTuple
from pack... | --- +++ @@ -1,3 +1,4 @@+"""Everything related to fetching or initializing build prerequisites."""
from __future__ import annotations
@@ -33,24 +34,49 @@
class AppInfo(NamedTuple):
+ """A tuple containing the app instance and module."""
app: App
module: ModuleType
def get_web_dir() -> Path:
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/prerequisites.py |
Add return value explanations in docstrings |
import asyncio
import time
from collections.abc import Callable, Coroutine
from typing import Any
from reflex.utils import console
async def _run_forever(
coro_function: Callable[..., Coroutine],
*args: Any,
suppress_exceptions: list[type[BaseException]],
exception_delay: float,
exception_limit:... | --- +++ @@ -1,3 +1,4 @@+"""Helpers for managing asyncio tasks."""
import asyncio
import time
@@ -16,6 +17,17 @@ exception_limit_window: float,
**kwargs: Any,
):
+ """Wrapper to continuously run a coroutine function, suppressing certain exceptions.
+
+ Args:
+ coro_function: The coroutine func... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/tasks.py |
Add detailed documentation for each class |
from __future__ import annotations
import ast
import contextlib
import importlib
import inspect
import json
import logging
import multiprocessing
import re
import subprocess
import sys
import typing
from collections.abc import Callable, Iterable, Mapping, Sequence
from concurrent.futures import ProcessPoolExecutor
fr... | --- +++ @@ -1,3 +1,4 @@+"""The pyi generator module."""
from __future__ import annotations
@@ -97,6 +98,15 @@
def _walk_files(path: str | Path):
+ """Walk all files in a path.
+ This can be replaced with Path.walk() in python3.12.
+
+ Args:
+ path: The path to walk.
+
+ Yields:
+ The ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/pyi_generator.py |
Write docstrings for backend logic |
from __future__ import annotations
import json
import os
import re
import shutil
import stat
from pathlib import Path
from reflex.config import get_config
from reflex.environment import environment
# Shorthand for join.
join = os.linesep.join
def chmod_rm(path: Path):
path.chmod(stat.S_IWRITE)
if path.is_... | --- +++ @@ -1,3 +1,4 @@+"""Path operations."""
from __future__ import annotations
@@ -16,6 +17,11 @@
def chmod_rm(path: Path):
+ """Remove a file or directory with chmod.
+
+ Args:
+ path: The path to the file or directory.
+ """
path.chmod(stat.S_IWRITE)
if path.is_dir():
sh... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/path_ops.py |
Document my Python code with docstrings |
from __future__ import annotations
import contextlib
import dataclasses
import dis
import enum
import importlib
import inspect
import sys
from types import CellType, CodeType, FunctionType, ModuleType
from typing import TYPE_CHECKING, Any, ClassVar, cast
from reflex.utils.exceptions import VarValueError
if TYPE_CHE... | --- +++ @@ -1,3 +1,4 @@+"""Collection of base classes."""
from __future__ import annotations
@@ -23,6 +24,14 @@
def get_cell_value(cell: CellType) -> Any:
+ """Get the value of a cell object.
+
+ Args:
+ cell: The cell object to get the value from. (func.__closure__ objects)
+
+ Returns:
+ ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/vars/dep_tracking.py |
Add docstrings to my Python code |
import dataclasses
import shutil
import tempfile
import zipfile
from pathlib import Path
from urllib.parse import urlparse
from reflex import constants
from reflex.config import get_config
from reflex.utils import console, net, path_ops, redir
@dataclasses.dataclass(frozen=True)
class Template:
name: str
d... | --- +++ @@ -1,3 +1,4 @@+"""This module provides utilities for managing Reflex app templates."""
import dataclasses
import shutil
@@ -13,6 +14,7 @@
@dataclasses.dataclass(frozen=True)
class Template:
+ """A template for a Reflex app."""
name: str
description: str
@@ -20,6 +22,11 @@
def create_c... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/templates.py |
Add docstrings that explain logic |
from __future__ import annotations
import contextlib
import dataclasses
import decimal
import functools
import inspect
import json
import warnings
from collections.abc import Callable, Mapping, Sequence
from datetime import date, datetime, time, timedelta
from enum import Enum
from importlib.util import find_spec
fro... | --- +++ @@ -1,3 +1,4 @@+"""Serializers used to convert Var types to JSON strings."""
from __future__ import annotations
@@ -55,6 +56,16 @@ to: Any = None,
overwrite: bool | None = None,
) -> SERIALIZED_FUNCTION | Callable[[SERIALIZED_FUNCTION], SERIALIZED_FUNCTION]:
+ """Decorator to add a serializer ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/serializers.py |
Document all public functions with docstrings |
import dataclasses
from reflex.constants.colors import Color
from reflex.vars.base import (
CachedVarOperation,
LiteralVar,
Var,
VarData,
cached_property_no_lock,
get_python_literal,
)
from reflex.vars.number import ternary_operation
from reflex.vars.sequence import ConcatVarOperation, Literal... | --- +++ @@ -1,3 +1,4 @@+"""Vars for colors."""
import dataclasses
@@ -15,6 +16,7 @@
class ColorVar(StringVar[Color], python_types=Color):
+ """Base class for immutable color vars."""
@dataclasses.dataclass(
@@ -23,6 +25,7 @@ slots=True,
)
class LiteralColorVar(CachedVarOperation, LiteralVar, Colo... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/vars/color.py |
Add docstrings to improve collaboration |
from __future__ import annotations
import dataclasses
from collections.abc import Callable, Sequence
from typing import Any, Concatenate, Generic, ParamSpec, Protocol, TypeVar, overload
from reflex.utils import format
from reflex.utils.types import GenericType
from .base import CachedVarOperation, LiteralVar, Var, ... | --- +++ @@ -1,3 +1,4 @@+"""Immutable function vars."""
from __future__ import annotations
@@ -21,6 +22,7 @@
class ReflexCallable(Protocol[P, R]):
+ """Protocol for a callable."""
__call__: Callable[P, R]
@@ -32,6 +34,7 @@
class FunctionVar(Var[CALLABLE_TYPE], default_type=ReflexCallable[Any, An... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/vars/function.py |
Generate docstrings for this script |
from __future__ import annotations
import dataclasses
import sys
import types
from collections.abc import Callable, Iterable, Mapping, Sequence
from enum import Enum
from functools import cached_property, lru_cache
from importlib.util import find_spec
from types import GenericAlias
from typing import ( # noqa: UP035... | --- +++ @@ -1,3 +1,4 @@+"""Contains custom types and methods to check types."""
from __future__ import annotations
@@ -163,11 +164,25 @@
class Unset:
+ """A class to represent an unset value.
+
+ This is used to differentiate between a value that is not set and a value that is set to None.
+ """
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/types.py |
Add docstrings that explain inputs and outputs |
from __future__ import annotations
import dataclasses
from datetime import date, datetime
from typing import Any, TypeVar
from reflex.utils.exceptions import VarTypeError
from reflex.vars.number import BooleanVar
from .base import (
CustomVarOperationReturn,
LiteralVar,
Var,
VarData,
var_operati... | --- +++ @@ -1,3 +1,4 @@+"""Immutable datetime and date vars."""
from __future__ import annotations
@@ -23,28 +24,66 @@
def raise_var_type_error():
+ """Raise a VarTypeError.
+
+ Raises:
+ VarTypeError: Cannot compare a datetime object with a non-datetime object.
+ """
msg = "Cannot compare... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/vars/datetime.py |
Add docstrings to make code maintainable |
from __future__ import annotations
import collections.abc
import dataclasses
import typing
from collections.abc import Mapping
from importlib.util import find_spec
from typing import (
Any,
NoReturn,
TypeVar,
get_args,
get_type_hints,
is_typeddict,
overload,
)
from rich.markup import esca... | --- +++ @@ -1,3 +1,4 @@+"""Classes for immutable object vars."""
from __future__ import annotations
@@ -81,8 +82,14 @@
class ObjectVar(Var[OBJECT_TYPE], python_types=PYTHON_TYPES):
+ """Base class for immutable object vars."""
def _key_type(self) -> type:
+ """Get the type of the keys of the o... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/vars/object.py |
Document this script properly |
from __future__ import annotations
import dataclasses
import decimal
import json
import math
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, NoReturn, TypeVar, overload
from typing_extensions import TypeVar as TypeVarExt
from reflex.constants.base import Dirs
from reflex.utils.exceptions... | --- +++ @@ -1,3 +1,4 @@+"""Immutable number vars."""
from __future__ import annotations
@@ -43,35 +44,82 @@ def raise_unsupported_operand_types(
operator: str, operands_types: tuple[type, ...]
) -> NoReturn:
+ """Raise an unsupported operand types error.
+
+ Args:
+ operator: The operator.
+ ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/vars/number.py |
Write reusable docstrings |
import pickle
import sys
from collections.abc import Callable
from typing import Any
# Errors caught during pickling of state
HANDLED_PICKLE_ERRORS = (
pickle.PicklingError,
AttributeError,
IndexError,
TypeError,
ValueError,
)
def _is_picklable(obj: Any, dumps: Callable[[object], bytes]) -> bool... | --- +++ @@ -1,3 +1,4 @@+"""This module will provide interfaces for the state."""
import pickle
import sys
@@ -24,6 +25,15 @@
def debug_failed_pickles(obj: object, dumps: Callable[[object], bytes]):
+ """Recursively check the picklability of an object and its contents.
+
+ Args:
+ obj: The object to... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/istate/__init__.py |
Document helper functions with docstrings |
from __future__ import annotations
import dataclasses
from typing import TYPE_CHECKING
from reflex import constants
from reflex.event import Event, get_hydrate_event
from reflex.middleware.middleware import Middleware
from reflex.state import BaseState, StateUpdate, _resolve_delta
if TYPE_CHECKING:
from reflex.... | --- +++ @@ -1,3 +1,4 @@+"""Middleware to hydrate the state."""
from __future__ import annotations
@@ -15,10 +16,21 @@
@dataclasses.dataclass(init=True)
class HydrateMiddleware(Middleware):
+ """Middleware to handle initial app hydration."""
async def preprocess(
self, app: App, state: BaseSta... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/middleware/hydrate_middleware.py |
Replace inline comments with docstrings |
import logging
import subprocess
import sys
from pathlib import Path
from reflex.utils.pyi_generator import PyiGenerator, _relative_to_pwd
logger = logging.getLogger("pyi_generator")
LAST_RUN_COMMIT_SHA_FILE = Path(".pyi_generator_last_run").resolve()
GENERATOR_FILE = Path(__file__).resolve()
GENERATOR_DIFF_FILE = ... | --- +++ @@ -1,3 +1,4 @@+"""The pyi generator module."""
import logging
import subprocess
@@ -15,11 +16,27 @@
def _git_diff(args: list[str]) -> str:
+ """Run a git diff command.
+
+ Args:
+ args: The args to pass to git diff.
+
+ Returns:
+ The output of the git diff command.
+ """
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/scripts/make_pyi.py |
Add structured docstrings to improve clarity |
import importlib.util
import pathlib
import subprocess
import sys
from typing import Any
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class CustomBuilder(BuildHookInterface):
PLUGIN_NAME = "custom"
def marker(self) -> pathlib.Path:
return (
pathlib.Path(self... | --- +++ @@ -1,3 +1,4 @@+"""Custom build hook for Hatch."""
import importlib.util
import pathlib
@@ -9,16 +10,28 @@
class CustomBuilder(BuildHookInterface):
+ """Custom build hook for Hatch."""
PLUGIN_NAME = "custom"
def marker(self) -> pathlib.Path:
+ """Get the marker file path.
+
+ ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/scripts/hatch_build.py |
Document functions with detailed explanations |
from __future__ import annotations
import sys
from collections import defaultdict
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Callable
from typing import Any
from reflex.event import EventType
DECORATED_PAGES: dict[str, list] = defaultdict(list)
def page(
route:... | --- +++ @@ -1,3 +1,4 @@+"""The page decorator and associated variables and functions."""
from __future__ import annotations
@@ -23,6 +24,27 @@ script_tags: list[Any] | None = None,
on_load: EventType[()] | None = None,
):
+ """Decorate a function as a page.
+
+ rx.App() will automatically call add_... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/page.py |
Create simple docstrings for beginners | # :copyright: (c) 2017-2026 Asif Saif Uddin, celery core and individual
# contributors, All rights reserved.
# :copyright: (c) 2015-2016 Ask Solem. All rights reserved.
# :copyright: (c) 2012-2014 GoPivotal, Inc., All rights reserved.
# :copyright: (c) 2009 - 2012 Ask Solem and individual contributors,... | --- +++ @@ -1,3 +1,4 @@+"""Distributed Task Queue."""
# :copyright: (c) 2017-2026 Asif Saif Uddin, celery core and individual
# contributors, All rights reserved.
# :copyright: (c) 2015-2016 Ask Solem. All rights reserved.
@@ -85,6 +86,13 @@
def _find_option_with_arg(argv, short_opts=None, long_... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/__init__.py |
Write beginner-friendly docstrings | import logging
import os
import sys
import warnings
from logging.handlers import WatchedFileHandler
from kombu.utils.encoding import set_default_encoding_file
from celery import signals
from celery._state import get_current_task
from celery.exceptions import CDeprecationWarning, CPendingDeprecationWarning
from celery... | --- +++ @@ -1,3 +1,11 @@+"""Logging configuration.
+
+The Celery instances logging section: ``Celery.log``.
+
+Sets up logging for the worker and other programs,
+redirects standard outs, colors log output, patches logging
+related compatibility fixes, and so on.
+"""
import logging
import os
import sys
@@ -22,6 +30... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/log.py |
Generate docstrings for each module |
from __future__ import annotations
from collections.abc import Mapping
from typing import Any, Literal
from reflex import constants
from reflex.components.core.breakpoints import Breakpoints, breakpoints_values
from reflex.event import EventChain, EventHandler, EventSpec, run_script
from reflex.utils import format
f... | --- +++ @@ -1,3 +1,4 @@+"""Handle styling."""
from __future__ import annotations
@@ -29,6 +30,15 @@
def _color_mode_var(_js_expr: str, _var_type: type = str) -> Var:
+ """Create a Var that destructs the _js_expr from ColorModeContext.
+
+ Args:
+ _js_expr: The name of the variable to get from Colo... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/style.py |
Generate documentation strings for clarity |
from __future__ import annotations
import re
from collections import defaultdict
from contextlib import suppress
from importlib.util import find_spec
from typing import TYPE_CHECKING, Any, ClassVar
from reflex.config import get_config
from reflex.environment import environment
from reflex.utils import console
from r... | --- +++ @@ -1,3 +1,4 @@+"""Database built into Reflex."""
from __future__ import annotations
@@ -27,6 +28,14 @@
def _safe_db_url_for_logging(url: str) -> str:
+ """Remove username and password from the database URL for logging.
+
+ Args:
+ url: The database URL.
+
+ Returns:
+ The databa... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/model.py |
Expand my code with proper documentation strings |
from typing import TYPE_CHECKING
from reflex.plugins.base import Plugin as BasePlugin
if TYPE_CHECKING:
from starlette.requests import Request
from starlette.responses import Response
from typing_extensions import Unpack
from reflex.app import App
from reflex.plugins.base import PostCompileConte... | --- +++ @@ -1,3 +1,4 @@+"""Plugin to enable screenshot functionality."""
from typing import TYPE_CHECKING
@@ -17,6 +18,14 @@
def _deep_copy(state: "BaseState") -> "BaseState":
+ """Create a deep copy of the state.
+
+ Args:
+ state: The state to copy.
+
+ Returns:
+ A deep copy of the st... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/plugins/_screenshot.py |
Write reusable docstrings |
from __future__ import annotations
import dataclasses
import re
from collections.abc import Callable
from typing import Any
from reflex import constants
from reflex.event import EventChain, EventHandler, EventSpec, run_script
from reflex.utils.imports import ImportVar
from reflex.vars import VarData, get_unique_vari... | --- +++ @@ -1,3 +1,4 @@+"""Handle client side state with `useState`."""
from __future__ import annotations
@@ -22,10 +23,26 @@
def _client_state_ref(var_name: str) -> str:
+ """Get the ref path for a ClientStateVar.
+
+ Args:
+ var_name: The name of the variable.
+
+ Returns:
+ An access... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/experimental/client_state.py |
Write Python docstrings for this snippet |
from types import SimpleNamespace
from reflex.components.datadisplay.shiki_code_block import code_block as code_block
from reflex.utils.console import warn
from reflex.utils.misc import run_in_thread
from . import hooks as hooks
from .client_state import ClientStateVar as ClientStateVar
class ExperimentalNamespace... | --- +++ @@ -1,3 +1,4 @@+"""Namespace for experimental features."""
from types import SimpleNamespace
@@ -10,8 +11,17 @@
class ExperimentalNamespace(SimpleNamespace):
+ """Namespace for experimental features."""
def __getattribute__(self, item: str):
+ """Get attribute from the namespace.
+
+ ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/experimental/__init__.py |
Fill in missing docstrings in my code | import inspect
from importlib import import_module
from celery._state import get_current_app
from celery.app.autoretry import add_autoretry_behaviour
from celery.exceptions import InvalidTaskError, NotRegistered
__all__ = ('TaskRegistry',)
class TaskRegistry(dict):
NotRegistered = NotRegistered
def __miss... | --- +++ @@ -1,3 +1,4 @@+"""Registry of available tasks."""
import inspect
from importlib import import_module
@@ -9,6 +10,7 @@
class TaskRegistry(dict):
+ """Map of registered tasks."""
NotRegistered = NotRegistered
@@ -16,6 +18,11 @@ raise self.NotRegistered(key)
def register(self, t... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/registry.py |
Write docstrings that follow conventions |
from __future__ import annotations
import collections.abc
import dataclasses
import decimal
import inspect
import json
import re
from collections.abc import Iterable, Mapping, Sequence
from typing import TYPE_CHECKING, Any, Literal, TypeVar, get_args, overload
from typing_extensions import TypeVar as TypingExtension... | --- +++ @@ -1,3 +1,4 @@+"""Collection of string classes and utilities."""
from __future__ import annotations
@@ -58,8 +59,17 @@
class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
+ """Base class for immutable array vars."""
def join(self, sep: StringVar | str = "") -> StringVar:
+ ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/vars/sequence.py |
Write docstrings for backend logic |
from __future__ import annotations
from reflex.utils.imports import ImportVar
from reflex.vars import VarData
from reflex.vars.base import Var
def _compose_react_imports(tags: list[str]) -> dict[str, list[ImportVar]]:
return {"react": [ImportVar(tag=tag) for tag in tags]}
def const(name: str | list[str], valu... | --- +++ @@ -1,3 +1,4 @@+"""Add standard Hooks wrapper for React."""
from __future__ import annotations
@@ -11,12 +12,30 @@
def const(name: str | list[str], value: str | Var) -> Var:
+ """Create a constant Var.
+
+ Args:
+ name: The name of the constant.
+ value: The value of the constant.
+... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/experimental/hooks.py |
Write docstrings for utility functions | import logging
import os
import sys
import time
from collections import namedtuple
from warnings import warn
from billiard.einfo import ExceptionInfo, ExceptionWithTraceback
from kombu.exceptions import EncodeError
from kombu.serialization import loads as loads_message
from kombu.serialization import prepare_accept_co... | --- +++ @@ -1,3 +1,8 @@+"""Trace task execution.
+
+This module defines how the task execution is traced:
+errors are recorded, handlers are applied and so on.
+"""
import logging
import os
import sys
@@ -116,10 +121,15 @@
def info(fmt, context):
+ """Log 'fmt % context' with severity 'INFO'.
+
+ 'context'... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/trace.py |
Generate NumPy-style docstrings | import fnmatch
import re
from collections import OrderedDict
from collections.abc import Mapping
from kombu import Queue
from celery.exceptions import QueueNotFound
from celery.utils.collections import lpmerge
from celery.utils.functional import maybe_evaluate, mlazy
from celery.utils.imports import symbol_by_name
t... | --- +++ @@ -1,3 +1,7 @@+"""Task Routing.
+
+Contains utilities for working with task routers, (:setting:`task_routes`).
+"""
import fnmatch
import re
from collections import OrderedDict
@@ -20,6 +24,7 @@
class MapRoute:
+ """Creates a router out of a :class:`dict`."""
def __init__(self, map):
... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/routes.py |
Document all endpoints with docstrings | from kombu.transport.azurestoragequeues import Transport as AzureStorageQueuesTransport
from kombu.utils import cached_property
from kombu.utils.encoding import bytes_to_str
from celery.exceptions import ImproperlyConfigured
from celery.utils.log import get_logger
from .base import KeyValueStoreBackend
try:
impo... | --- +++ @@ -1,3 +1,4 @@+"""The Azure Storage Block Blob backend for Celery."""
from kombu.transport.azurestoragequeues import Transport as AzureStorageQueuesTransport
from kombu.utils import cached_property
from kombu.utils.encoding import bytes_to_str
@@ -21,12 +22,20 @@
class AzureBlockBlobBackend(KeyValueStor... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/azureblockblob.py |
Help me write clear docstrings |
from __future__ import annotations
import os
from starlette.requests import Request
from starlette.responses import HTMLResponse
from reflex.components.base.script import Script
from reflex.components.component import Component
from reflex.components.core.banner import has_connection_errors
from reflex.components.c... | --- +++ @@ -1,3 +1,4 @@+"""Utilities for working with Github Codespaces."""
from __future__ import annotations
@@ -16,6 +17,11 @@
@once
def redirect_script() -> str:
+ """Get the redirect script for Github Codespaces.
+
+ Returns:
+ The redirect script as a string.
+ """
return f"""
const ... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/codespaces.py |
Create simple docstrings for beginners | import sys
import time
import warnings
from collections import namedtuple
from datetime import timedelta
from functools import partial
from weakref import WeakValueDictionary
from billiard.einfo import ExceptionInfo
from kombu.serialization import dumps, loads, prepare_accept_content
from kombu.serialization import re... | --- +++ @@ -1,3 +1,10 @@+"""Result backend base classes.
+
+- :class:`BaseBackend` defines the interface.
+
+- :class:`KeyValueStoreBackend` is a common base class
+ using K/V semantics like _get and _put.
+"""
import sys
import time
import warnings
@@ -54,10 +61,16 @@
def unpickle_backend(cls, args, kwargs):... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/base.py |
Add docstrings including usage examples |
from __future__ import annotations
import os
import zipfile
from pathlib import Path, PosixPath
from rich.progress import MofNCompleteColumn, Progress, TimeElapsedColumn
from reflex import constants
from reflex.config import get_config
from reflex.utils import console, js_runtimes, path_ops, prerequisites, processe... | --- +++ @@ -1,3 +1,4 @@+"""Building the app and initializing all prerequisites."""
from __future__ import annotations
@@ -14,6 +15,7 @@
def set_env_json():
+ """Write the upload url to a REFLEX_JSON."""
path_ops.update_json_file(
str(prerequisites.get_web_dir() / constants.Dirs.ENV_JSON),
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/build.py |
Add docstrings to improve collaboration | import errno
import os
import shlex
import signal
import sys
from collections import OrderedDict, UserList, defaultdict
from functools import partial
from subprocess import Popen
from time import sleep
from kombu.utils.encoding import from_utf8
from kombu.utils.objects import cached_property
from celery.platforms imp... | --- +++ @@ -1,3 +1,4 @@+"""Start/stop/manage workers."""
import errno
import os
import shlex
@@ -119,6 +120,7 @@
class Node:
+ """Represents a node in a cluster."""
def __init__(self, name,
cmd=None, append=None, options=None, extra_args=None):
@@ -363,6 +365,7 @@
class Cluster(Us... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/apps/multi.py |
Help me add docstrings to my project | from __future__ import annotations
import numbers
import socket
import sys
from datetime import datetime
from signal import Signals
from types import FrameType
from typing import Any
from celery import VERSION_BANNER, Celery, beat, platforms
from celery.utils.imports import qualname
from celery.utils.log import LOG_L... | --- +++ @@ -1,3 +1,11 @@+"""Beat command-line program.
+
+This module is the 'program-version' of :mod:`celery.beat`.
+
+It does everything necessary to run that module
+as an actual application, like installing signal handlers
+and so on.
+"""
from __future__ import annotations
import numbers
@@ -30,6 +38,7 @@
... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/apps/beat.py |
Write proper docstrings for these functions | import logging
from contextlib import contextmanager
from celery import states
from celery.backends.base import BaseBackend
from celery.exceptions import ImproperlyConfigured
from celery.utils.time import maybe_timedelta
from .models import Task, TaskExtended, TaskSet
from .session import SessionManager
try:
fro... | --- +++ @@ -1,3 +1,4 @@+"""SQLAlchemy result store backend."""
import logging
from contextlib import contextmanager
@@ -41,6 +42,7 @@
class DatabaseBackend(BaseBackend):
+ """The database result backend."""
# ResultSet.iterate should sleep this much between each pool,
# to not bombard the databas... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/database/__init__.py |
Add docstrings for production code | from kombu.utils.encoding import bytes_to_str, ensure_bytes
from kombu.utils.objects import cached_property
from celery.exceptions import ImproperlyConfigured
from celery.utils.functional import LRUCache
from .base import KeyValueStoreBackend
__all__ = ('CacheBackend',)
_imp = [None]
REQUIRES_BACKEND = """\
The Me... | --- +++ @@ -1,3 +1,4 @@+"""Memcached and in-memory cache result backend."""
from kombu.utils.encoding import bytes_to_str, ensure_bytes
from kombu.utils.objects import cached_property
@@ -87,6 +88,7 @@
class CacheBackend(KeyValueStoreBackend):
+ """Cache result backend."""
servers = None
supports... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/cache.py |
Add clean documentation to messy code |
import logging
import socket
import threading
import time
from collections import deque
from contextlib import contextmanager
from queue import Empty
from time import sleep
from weakref import WeakKeyDictionary
from kombu.utils.compat import detect_environment
from celery import states
from celery.exceptions import ... | --- +++ @@ -1,3 +1,4 @@+"""Async I/O backend support utilities."""
import logging
import socket
@@ -32,6 +33,10 @@
class EventletAdaptedEvent:
+ """
+ An adapted eventlet event, designed to match the API of `threading.Event` and
+ `gevent.event.Event`.
+ """
def __init__(self):
impor... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/asynchronous.py |
Generate docstrings for this script | import sys
import types
from billiard.einfo import ExceptionInfo, ExceptionWithTraceback
from kombu import serialization
from kombu.exceptions import OperationalError
from kombu.utils.uuid import uuid
from celery import current_app, states
from celery._state import _task_stack
from celery.canvas import _chain, group,... | --- +++ @@ -1,3 +1,4 @@+"""Task implementation: request context and the task base class."""
import sys
import types
@@ -69,6 +70,7 @@
class Context:
+ """Task request variables (Task.request)."""
_children = None # see property
_protected = 0
@@ -134,6 +136,7 @@ return f'<Context: {vars... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/task.py |
Generate NumPy-style docstrings | import threading
from celery import states
from celery.exceptions import ImproperlyConfigured
from celery.utils.log import get_logger
from .base import BaseBackend
try: # pragma: no cover
import cassandra
import cassandra.auth
import cassandra.cluster
import cassandra.query
except ImportError:
c... | --- +++ @@ -1,3 +1,4 @@+"""Apache Cassandra result store backend using the DataStax driver."""
import threading
from celery import states
@@ -68,6 +69,14 @@
class CassandraBackend(BaseBackend):
+ """Cassandra/AstraDB backend utilizing DataStax driver.
+
+ Raises:
+ celery.exceptions.ImproperlyConfi... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/cassandra.py |
Generate docstrings for exported functions | from kombu.utils import cached_property
from kombu.utils.encoding import bytes_to_str
from kombu.utils.url import _parse_url
from celery.exceptions import ImproperlyConfigured
from celery.utils.log import get_logger
from .base import KeyValueStoreBackend
try:
import pydocumentdb
from pydocumentdb.document_cl... | --- +++ @@ -1,3 +1,4 @@+"""The CosmosDB/SQL backend for Celery (experimental)."""
from kombu.utils import cached_property
from kombu.utils.encoding import bytes_to_str
from kombu.utils.url import _parse_url
@@ -27,6 +28,7 @@
class CosmosDBSQLBackend(KeyValueStoreBackend):
+ """CosmosDB/SQL backend for Celery.... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/cosmosdbsql.py |
Add docstrings explaining edge cases | from kombu.utils.encoding import bytes_to_str
from kombu.utils.url import parse_url
from celery.backends.base import KeyValueStoreBackend
from celery.exceptions import ImproperlyConfigured
from celery.utils.log import get_logger
try:
import consul
except ImportError:
consul = None
logger = get_logger(__name_... | --- +++ @@ -1,3 +1,8 @@+"""Consul result store backend.
+
+- :class:`ConsulBackend` implements KeyValueStoreBackend to store results
+ in the key-value store of Consul.
+"""
from kombu.utils.encoding import bytes_to_str
from kombu.utils.url import parse_url
@@ -20,6 +25,7 @@
class ConsulBackend(KeyValueStore... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/consul.py |
Generate helpful docstrings for debugging |
import sys
from collections.abc import Mapping
from importlib.util import find_spec
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from pydantic.fields import FieldInfo
async def windows_hot_reload_lifespan_hack():
import asyncio
import sys
try:
while True:
sys.stderr.w... | --- +++ @@ -1,3 +1,4 @@+"""Compatibility hacks and helpers."""
import sys
from collections.abc import Mapping
@@ -9,6 +10,17 @@
async def windows_hot_reload_lifespan_hack():
+ """[REF-3164] A hack to fix hot reload on Windows.
+
+ Uvicorn has an issue stopping itself on Windows after detecting changes in
... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/compat.py |
Document classes and their methods |
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
from reflex.event import Event
from reflex.state import BaseState, StateUpdate
if TYPE_CHECKING:
from reflex.app import App
class Middleware(ABC):
@abstractmethod
async def preprocess(
self... | --- +++ @@ -1,3 +1,4 @@+"""Base Reflex middleware."""
from __future__ import annotations
@@ -12,14 +13,36 @@
class Middleware(ABC):
+ """Middleware to preprocess and postprocess requests."""
@abstractmethod
async def preprocess(
self, app: App, state: BaseState, event: Event
) -> S... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/middleware/middleware.py |
Create simple docstrings for beginners | from datetime import datetime, timezone
import sqlalchemy as sa
from sqlalchemy.types import PickleType
from celery import states
from .session import ResultModelBase
__all__ = ('Task', 'TaskExtended', 'TaskSet')
DialectSpecificInteger = sa.Integer().with_variant(sa.BigInteger, 'mssql')
def _get_utc_now():
... | --- +++ @@ -1,3 +1,4 @@+"""Database models used by the SQLAlchemy result store backend."""
from datetime import datetime, timezone
import sqlalchemy as sa
@@ -14,10 +15,17 @@
def _get_utc_now():
+ """Return current UTC datetime.
+
+ This helper is used as a callable for SQLAlchemy column defaults
+ to ... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/database/models.py |
Improve documentation using docstrings | from collections import namedtuple
from ipaddress import ip_address
from time import sleep, time
from typing import Any, Dict
from kombu.utils.url import _parse_url as parse_url
from celery.exceptions import ImproperlyConfigured
from celery.utils.log import get_logger
from .base import KeyValueStoreBackend
try:
... | --- +++ @@ -1,3 +1,4 @@+"""AWS DynamoDB result store backend."""
from collections import namedtuple
from ipaddress import ip_address
from time import sleep, time
@@ -26,6 +27,12 @@
class DynamoDBBackend(KeyValueStoreBackend):
+ """AWS DynamoDB result backend.
+
+ Raises:
+ celery.exceptions.Improper... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/dynamodb.py |
Add clean documentation to messy code |
from __future__ import annotations
import contextlib
import datetime
import inspect
import os
import shutil
import sys
import time
from pathlib import Path
from types import FrameType
from rich.console import Console
from rich.progress import MofNCompleteColumn, Progress, TaskID, TimeElapsedColumn
from rich.prompt i... | --- +++ @@ -1,3 +1,4 @@+"""Functions to communicate to the user via console."""
from __future__ import annotations
@@ -52,6 +53,14 @@
def set_log_level(log_level: LogLevel | None):
+ """Set the log level.
+
+ Args:
+ log_level: The log level to set.
+
+ Raises:
+ TypeError: If the log le... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/console.py |
Insert docstrings into my code | import locale
import os
from datetime import datetime
from kombu.utils.encoding import ensure_bytes
from celery import uuid
from celery.backends.base import KeyValueStoreBackend
from celery.exceptions import ImproperlyConfigured
default_encoding = locale.getpreferredencoding(False)
E_NO_PATH_SET = 'You need to conf... | --- +++ @@ -1,3 +1,4 @@+"""File-system result store backend."""
import locale
import os
from datetime import datetime
@@ -22,6 +23,15 @@
class FilesystemBackend(KeyValueStoreBackend):
+ """File-system result backend.
+
+ Arguments:
+ url (str): URL to the directory we should use
+ open (Call... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/filesystem.py |
Help me add docstrings to my project | from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timedelta
from os import getpid
from threading import RLock
from kombu.utils.encoding import bytes_to_str
from kombu.utils.functional import dictfilter
from kombu.utils.url import url_to_parts
from celery.backends.base import _create_cho... | --- +++ @@ -1,3 +1,4 @@+"""Google Cloud Storage result store backend for Celery."""
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timedelta
from os import getpid
@@ -40,6 +41,7 @@
class GCSBackendBase(KeyValueStoreBackend):
+ """Google Cloud Storage task result backend."""
... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/gcs.py |
Write reusable docstrings | from datetime import datetime, timedelta, timezone
from kombu.exceptions import EncodeError
from kombu.utils.objects import cached_property
from kombu.utils.url import maybe_sanitize_url, urlparse
from celery import states
from celery.exceptions import ImproperlyConfigured
from .base import BaseBackend
try:
imp... | --- +++ @@ -1,3 +1,4 @@+"""MongoDB result store backend."""
from datetime import datetime, timedelta, timezone
from kombu.exceptions import EncodeError
@@ -33,6 +34,12 @@
class MongoBackend(BaseBackend):
+ """MongoDB result backend.
+
+ Raises:
+ celery.exceptions.ImproperlyConfigured:
+ ... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/mongodb.py |
Include argument descriptions in docstrings | import logging
import os
import platform as _platform
import sys
from datetime import datetime
from functools import partial
from billiard.common import REMAP_SIGTERM
from billiard.process import current_process
from kombu.utils.encoding import safe_str
from celery import VERSION_BANNER, _original_os_write, platforms... | --- +++ @@ -1,3 +1,11 @@+"""Worker command-line program.
+
+This module is the 'program-version' of :mod:`celery.worker`.
+
+It does everything necessary to run that module
+as an actual application, like installing signal handlers,
+platform tweaks, and so on.
+"""
import logging
import os
import platform as _platf... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/apps/worker.py |
Please document this code using docstrings | from datetime import datetime, timezone
from kombu.utils.encoding import bytes_to_str
from kombu.utils.url import _parse_url
from celery import states
from celery.exceptions import ImproperlyConfigured
from .base import KeyValueStoreBackend
try:
import elasticsearch
except ImportError:
elasticsearch = None
... | --- +++ @@ -1,3 +1,4 @@+"""Elasticsearch result store backend."""
from datetime import datetime, timezone
from kombu.utils.encoding import bytes_to_str
@@ -27,6 +28,12 @@
class ElasticsearchBackend(KeyValueStoreBackend):
+ """Elasticsearch Backend.
+
+ Raises:
+ celery.exceptions.ImproperlyConfigur... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/backends/elasticsearch.py |
Write proper docstrings for these functions |
import copy
import dbm
import errno
import heapq
import os
import shelve
import sys
import time
import traceback
from calendar import timegm
from collections import namedtuple
from functools import total_ordering
from pickle import UnpicklingError
from threading import Event, Thread
from billiard import ensure_multip... | --- +++ @@ -1,3 +1,4 @@+"""The periodic task scheduler."""
import copy
import dbm
@@ -43,9 +44,25 @@
class SchedulingError(Exception):
+ """An error occurred while scheduling a task."""
class BeatLazyFunc:
+ """A lazy function declared in 'beat_schedule' and called before sending to worker.
+
+ Ex... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/beat.py |
Write docstrings describing functionality | from functools import partial
import click
from celery.bin.base import LOG_LEVEL, CeleryDaemonCommand, CeleryOption, handle_preload_options
from celery.platforms import detached, maybe_drop_privileges
@click.command(cls=CeleryDaemonCommand, context_settings={
'allow_extra_args': True
})
@click.option('--detach'... | --- +++ @@ -1,3 +1,4 @@+"""The :program:`celery beat` command."""
from functools import partial
import click
@@ -45,6 +46,7 @@ @handle_preload_options
def beat(ctx, detach=False, logfile=None, pidfile=None, uid=None,
gid=None, umask=None, workdir=None, **kwargs):
+ """Start the beat periodic task sche... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/bin/beat.py |
Add professional docstrings to my codebase | from celery import _state
from celery._state import app_or_default, disable_trace, enable_trace, pop_current_task, push_current_task
from celery.local import Proxy
from .base import Celery
from .utils import AppPickler
__all__ = (
'Celery', 'AppPickler', 'app_or_default', 'default_app',
'bugreport', 'enable_t... | --- +++ @@ -1,3 +1,4 @@+"""Celery Application."""
from celery import _state
from celery._state import app_or_default, disable_trace, enable_trace, pop_current_task, push_current_task
from celery.local import Proxy
@@ -16,10 +17,34 @@
def bugreport(app=None):
+ """Return information useful in bug reports."""
... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/__init__.py |
Add docstrings that explain inputs and outputs |
import re
import sys
from pathlib import Path
from reflex import constants
from reflex.config import get_config
from reflex.utils import console
from reflex.utils.misc import get_module_path
def rename_path_up_tree(full_path: str | Path, old_name: str, new_name: str) -> Path:
current_path = Path(full_path)
... | --- +++ @@ -1,3 +1,4 @@+"""This module provides utilities for renaming directories and files in a Reflex app."""
import re
import sys
@@ -10,6 +11,17 @@
def rename_path_up_tree(full_path: str | Path, old_name: str, new_name: str) -> Path:
+ """Rename all instances of `old_name` in the path (file and director... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/rename.py |
Add detailed docstrings explaining each function | import json
import numbers
from collections import OrderedDict
from functools import update_wrapper
from pprint import pformat
from typing import Any
import click
from click import Context, ParamType
from kombu.exceptions import OperationalError
from kombu.utils.objects import cached_property
from celery._state impor... | --- +++ @@ -1,3 +1,4 @@+"""Click customizations for Celery."""
import json
import numbers
from collections import OrderedDict
@@ -24,6 +25,7 @@ from pygments.lexers import PythonLexer
except ImportError:
def highlight(s, *args, **kwargs):
+ """Place holder function in case pygments is missing."""
... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/bin/base.py |
Help me document legacy Python code |
import os
import sys
import threading
import weakref
from celery.local import Proxy
from celery.utils.threads import LocalStack
__all__ = (
'set_default_app', 'get_current_app', 'get_current_task',
'get_current_worker_task', 'current_app', 'current_task',
'connect_on_app_finalize',
)
#: Global default a... | --- +++ @@ -1,3 +1,10 @@+"""Internal state.
+
+This is an internal module containing thread state
+like the ``current_app``, and ``current_task``.
+
+This module shouldn't be used directly.
+"""
import os
import sys
@@ -34,6 +41,7 @@
def connect_on_app_finalize(callback):
+ """Connect callback to be called w... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/_state.py |
Improve documentation using docstrings |
from __future__ import annotations
import inspect
import json
import os
import re
from typing import TYPE_CHECKING, Any
from reflex import constants
from reflex.constants.state import FRONTEND_EVENT_STATE
from reflex.utils import exceptions
if TYPE_CHECKING:
from reflex.components.component import ComponentStyl... | --- +++ @@ -1,3 +1,4 @@+"""Formatting operations."""
from __future__ import annotations
@@ -27,6 +28,15 @@
def length_of_largest_common_substring(str1: str, str2: str) -> int:
+ """Find the length of the largest common substring between two strings.
+
+ Args:
+ str1: The first string.
+ str... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/reflex/utils/format.py |
Write docstrings for utility functions |
import sys
from . import maybe_patch_concurrency
__all__ = ('main',)
def main() -> None:
if 'multi' not in sys.argv:
maybe_patch_concurrency()
from celery.bin.celery import main as _main
sys.exit(_main())
if __name__ == '__main__': # pragma: no cover
main() | --- +++ @@ -1,3 +1,4 @@+"""Entry-point for the :program:`celery` umbrella command."""
import sys
@@ -7,6 +8,7 @@
def main() -> None:
+ """Entrypoint to the ``celery`` umbrella command."""
if 'multi' not in sys.argv:
maybe_patch_concurrency()
from celery.bin.celery import main as _main
@@ ... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/__main__.py |
Add docstrings for utility scripts |
import argparse
import socket
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
def _pid_exists(pid: int):
# Note: For windows, the pid here is really the "winpid".
import psutil
return psutil.pid_exists(pid)
def _wait_for_port(port: int, server_pid: int, timeout: float) -> t... | --- +++ @@ -1,3 +1,8 @@+"""Script to wait for ports to start listening.
+
+Replaces logic previously implemented in a shell script that needed
+tools that are not available on Windows.
+"""
import argparse
import socket
@@ -31,6 +36,7 @@
def main():
+ """Wait for ports to start listening."""
parser = ar... | https://raw.githubusercontent.com/reflex-dev/reflex/HEAD/scripts/wait_for_listening_port.py |
Write docstrings for algorithm functions | import re
from collections import Counter
from fileinput import FileInput
import click
from celery.bin.base import CeleryCommand, handle_preload_options
__all__ = ('logtool',)
RE_LOG_START = re.compile(r'^\[\d\d\d\d\-\d\d-\d\d ')
RE_TASK_RECEIVED = re.compile(r'.+?\] Received')
RE_TASK_READY = re.compile(r'.+?\] Ta... | --- +++ @@ -1,3 +1,4 @@+"""The ``celery logtool`` command."""
import re
from collections import Counter
from fileinput import FileInput
@@ -113,6 +114,7 @@ @click.pass_context
@handle_preload_options
def logtool(ctx):
+ """The ``celery logtool`` command."""
@logtool.command(cls=CeleryCommand)
@@ -152,4 +15... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/bin/logtool.py |
Create simple docstrings for beginners | import click
from celery.bin.base import COMMA_SEPARATED_LIST, CeleryCommand, CeleryOption, handle_preload_options
from celery.utils import text
@click.command(cls=CeleryCommand, context_settings={
'allow_extra_args': True
})
@click.option('-f',
'--force',
cls=CeleryOption,
... | --- +++ @@ -1,3 +1,4 @@+"""The ``celery purge`` program, used to delete messages from queues."""
import click
from celery.bin.base import COMMA_SEPARATED_LIST, CeleryCommand, CeleryOption, handle_preload_options
@@ -28,6 +29,12 @@ @click.pass_context
@handle_preload_options
def purge(ctx, force, queues, exclude_q... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/bin/purge.py |
Document my Python code with docstrings |
import os
import sys
from importlib import import_module
import click
from celery.bin.base import CeleryCommand, CeleryOption, handle_preload_options
def _invoke_fallback_shell(locals):
import code
try:
import readline
except ImportError:
pass
else:
import rlcompleter
... | --- +++ @@ -1,3 +1,4 @@+"""The ``celery shell`` program, used to start a REPL."""
import os
import sys
@@ -119,6 +120,14 @@ def shell(ctx, ipython=False, bpython=False,
python=False, without_tasks=False, eventlet=False,
gevent=False, **kwargs):
+ """Start shell session with convenient acces... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/bin/shell.py |
Add minimal docstrings for each function | import numbers
from collections import namedtuple
from collections.abc import Mapping
from datetime import timedelta
from weakref import WeakValueDictionary
from kombu import Connection, Consumer, Exchange, Producer, Queue, pools
from kombu.common import Broadcast
from kombu.utils.functional import maybe_list
from kom... | --- +++ @@ -1,3 +1,4 @@+"""Sending/Receiving Messages (Kombu integration)."""
import numbers
from collections import namedtuple
from collections.abc import Mapping
@@ -38,6 +39,22 @@
class Queues(dict):
+ """Queue name⇒ declaration mapping.
+
+ Arguments:
+ queues (Iterable): Initial list/tuple or d... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/amqp.py |
Add docstrings for internal functions | from celery.utils.functional import firstmethod, mlazy
from celery.utils.imports import instantiate
_first_match = firstmethod('annotate')
_first_match_any = firstmethod('annotate_any')
__all__ = ('MapAnnotation', 'prepare', 'resolve_all')
class MapAnnotation(dict):
def annotate_any(self):
try:
... | --- +++ @@ -1,3 +1,11 @@+"""Task Annotations.
+
+Annotations is a nice term for monkey-patching task classes
+in the configuration.
+
+This prepares and performs the annotations in the
+:setting:`task_annotations` setting.
+"""
from celery.utils.functional import firstmethod, mlazy
from celery.utils.imports import in... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/annotations.py |
Write docstrings describing each step | import logging
import os
import sys
import time
from typing import Any, Dict
from billiard.einfo import ExceptionInfo
from billiard.exceptions import WorkerLostError
from kombu.utils.encoding import safe_repr
from celery.exceptions import WorkerShutdown, WorkerTerminate, reraise
from celery.utils import timer2
from c... | --- +++ @@ -1,3 +1,4 @@+"""Base Execution Pool."""
import logging
import os
import sys
@@ -21,6 +22,7 @@ def apply_target(target, args=(), kwargs=None, callback=None,
accept_callback=None, pid=None, getpid=os.getpid,
propagate=(), monotonic=time.monotonic, **_):
+ """Apply func... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/concurrency/base.py |
Create Google-style docstrings for my code | from vine.utils import wraps
from celery.exceptions import Ignore, Retry
from celery.utils.time import get_exponential_backoff_interval
def add_autoretry_behaviour(task, **options):
autoretry_for = tuple(
options.get('autoretry_for',
getattr(task, 'autoretry_for', ()))
)
dont_... | --- +++ @@ -1,3 +1,4 @@+"""Tasks auto-retry functionality."""
from vine.utils import wraps
from celery.exceptions import Ignore, Retry
@@ -5,6 +6,7 @@
def add_autoretry_behaviour(task, **options):
+ """Wrap task's `run` method with auto-retry functionality."""
autoretry_for = tuple(
options.get... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/app/autoretry.py |
Generate docstrings with examples | import click
from celery.bin.base import CeleryCommand, CeleryOption, handle_preload_options
@click.command(cls=CeleryCommand)
@click.argument('task_id')
@click.option('-t',
'--task',
cls=CeleryOption,
help_group='Result Options',
help="Name of task (if custom ... | --- +++ @@ -1,3 +1,4 @@+"""The ``celery result`` program, used to inspect task results."""
import click
from celery.bin.base import CeleryCommand, CeleryOption, handle_preload_options
@@ -18,6 +19,7 @@ @click.pass_context
@handle_preload_options
def result(ctx, task_id, task, traceback):
+ """Print the return ... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/bin/result.py |
Generate consistent docstrings | import errno
import gc
import inspect
import os
import select
import time
from collections import Counter, deque, namedtuple
from io import BytesIO
from numbers import Integral
from pickle import HIGHEST_PROTOCOL
from struct import pack, unpack, unpack_from
from time import sleep
from weakref import WeakValueDictionary... | --- +++ @@ -1,3 +1,17 @@+"""Version of multiprocessing.Pool using Async I/O.
+
+.. note::
+
+ This module will be moved soon, so don't use it directly.
+
+This is a non-blocking version of :class:`multiprocessing.Pool`.
+
+This code deals with three major challenges:
+
+#. Starting up child processes and keeping the... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/concurrency/asynpool.py |
Document this code for team use | import click
from kombu import Connection
from celery.bin.base import CeleryCommand, CeleryOption, handle_preload_options
from celery.contrib.migrate import migrate_tasks
@click.command(cls=CeleryCommand)
@click.argument('source')
@click.argument('destination')
@click.option('-n',
'--limit',
... | --- +++ @@ -1,3 +1,4 @@+"""The ``celery migrate`` command, used to filter and move messages."""
import click
from kombu import Connection
@@ -45,6 +46,13 @@ @click.pass_context
@handle_preload_options
def migrate(ctx, source, destination, **kwargs):
+ """Migrate tasks from one broker to another.
+
+ Warning... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/bin/migrate.py |
Please document this code using docstrings | import os
import signal
import sys
from functools import wraps
import click
from kombu.utils.objects import cached_property
from celery import VERSION_BANNER
from celery.apps.multi import Cluster, MultiParser, NamespacedOptionParser
from celery.bin.base import CeleryCommand, handle_preload_options
from celery.platfor... | --- +++ @@ -1,3 +1,103 @@+"""Start multiple worker instances from the command-line.
+
+.. program:: celery multi
+
+Examples
+========
+
+.. code-block:: console
+
+ $ # Single worker with explicit name and events enabled.
+ $ celery multi start Leslie -E
+
+ $ # Pidfiles and logfiles are stored in the current... | https://raw.githubusercontent.com/celery/celery/HEAD/celery/bin/multi.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.