Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 11 additions & 58 deletions temporalio/worker/_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ class FixedSizeSlotSupplier:

@dataclass(frozen=True)
class ResourceBasedTunerConfig:
"""Options for a :py:class:`ResourceBasedTuner` or a :py:class:`ResourceBasedSlotSupplier`.

.. warning::
The resource based tuner is currently experimental.
"""
"""Options for a :py:class:`ResourceBasedTuner` or a :py:class:`ResourceBasedSlotSupplier`."""

target_memory_usage: float
"""A value between 0 and 1 that represents the target (system) memory usage. It's not recommended
Expand All @@ -44,11 +40,7 @@ class ResourceBasedTunerConfig:

@dataclass(frozen=True)
class ResourceBasedSlotConfig:
"""Options for a specific slot type being used with a :py:class:`ResourceBasedSlotSupplier`.

.. warning::
The resource based tuner is currently experimental.
"""
"""Options for a specific slot type being used with a :py:class:`ResourceBasedSlotSupplier`."""

minimum_slots: Optional[int] = None
"""Amount of slots that will be issued regardless of any other checks. Defaults to 5 for workflows and 1 for
Expand All @@ -65,11 +57,7 @@ class ResourceBasedSlotConfig:

@dataclass(frozen=True)
class ResourceBasedSlotSupplier:
"""A slot supplier that will dynamically adjust the number of slots based on resource usage.

.. warning::
The resource based tuner is currently experimental.
"""
"""A slot supplier that will dynamically adjust the number of slots based on resource usage."""

slot_config: ResourceBasedSlotConfig
tuner_config: ResourceBasedTunerConfig
Expand All @@ -81,21 +69,14 @@ class SlotPermit:
"""A permit to use a slot for a workflow/activity/local activity task.

You can inherit from this class to add your own data to the permit.

.. warning::
Custom slot suppliers are currently experimental.
"""

pass


# WARNING: This must match Rust worker::SlotReserveCtx
class SlotReserveContext(Protocol):
"""Context for reserving a slot from a :py:class:`CustomSlotSupplier`.

.. warning::
Custom slot suppliers are currently experimental.
"""
"""Context for reserving a slot from a :py:class:`CustomSlotSupplier`."""

slot_type: Literal["workflow", "activity", "local-activity"]
"""The type of slot trying to be reserved. Always one of "workflow", "activity", or "local-activity"."""
Expand All @@ -118,11 +99,7 @@ class SlotReserveContext(Protocol):
# WARNING: This must match Rust worker::WorkflowSlotInfo
@runtime_checkable
class WorkflowSlotInfo(Protocol):
"""Info about a workflow task slot usage.

.. warning::
Custom slot suppliers are currently experimental.
"""
"""Info about a workflow task slot usage."""

workflow_type: str
is_sticky: bool
Expand All @@ -131,35 +108,23 @@ class WorkflowSlotInfo(Protocol):
# WARNING: This must match Rust worker::ActivitySlotInfo
@runtime_checkable
class ActivitySlotInfo(Protocol):
"""Info about an activity task slot usage.

.. warning::
Custom slot suppliers are currently experimental.
"""
"""Info about an activity task slot usage."""

activity_type: str


# WARNING: This must match Rust worker::LocalActivitySlotInfo
@runtime_checkable
class LocalActivitySlotInfo(Protocol):
"""Info about a local activity task slot usage.

.. warning::
Custom slot suppliers are currently experimental.
"""
"""Info about a local activity task slot usage."""

activity_type: str


# WARNING: This must match Rust worker::NexusSlotInfo
@runtime_checkable
class NexusSlotInfo(Protocol):
"""Info about a nexus task slot usage.

.. warning::
Custom slot suppliers are currently experimental.
"""
"""Info about a nexus task slot usage."""

service: str
operation: str
Expand All @@ -173,11 +138,7 @@ class NexusSlotInfo(Protocol):
# WARNING: This must match Rust worker::SlotMarkUsedCtx
@dataclass(frozen=True)
class SlotMarkUsedContext(Protocol):
"""Context for marking a slot used from a :py:class:`CustomSlotSupplier`.

.. warning::
Custom slot suppliers are currently experimental.
"""
"""Context for marking a slot used from a :py:class:`CustomSlotSupplier`."""

slot_info: SlotInfo
"""Info about the task that will be using the slot."""
Expand All @@ -188,11 +149,7 @@ class SlotMarkUsedContext(Protocol):
# WARNING: This must match Rust worker::SlotReleaseCtx
@dataclass(frozen=True)
class SlotReleaseContext:
"""Context for releasing a slot from a :py:class:`CustomSlotSupplier`.

.. warning::
Custom slot suppliers are currently experimental.
"""
"""Context for releasing a slot from a :py:class:`CustomSlotSupplier`."""

slot_info: Optional[SlotInfo]
"""Info about the task that will be using the slot. May be None if the slot was never used."""
Expand All @@ -201,11 +158,7 @@ class SlotReleaseContext:


class CustomSlotSupplier(ABC):
"""This class can be implemented to provide custom slot supplier behavior.

.. warning::
Custom slot suppliers are currently experimental.
"""
"""This class can be implemented to provide custom slot supplier behavior."""

@abstractmethod
async def reserve_slot(self, ctx: SlotReserveContext) -> SlotPermit:
Expand Down
2 changes: 0 additions & 2 deletions temporalio/worker/_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ def __init__(

Defaults to fixed-size 100 slots for each slot kind if unset and none of the
max_* arguments are provided.

WARNING: This argument is experimental
max_concurrent_workflow_task_polls: Maximum number of concurrent
poll workflow task requests we will perform at a time on this worker's task queue.
Must be set to at least two if ``max_cached_workflows`` is nonzero.
Expand Down