diff --git a/docs/google_demo/__init__.py b/docs/google_demo/__init__.py index c0c0908d9..853069434 100644 --- a/docs/google_demo/__init__.py +++ b/docs/google_demo/__init__.py @@ -34,7 +34,8 @@ https://google.github.io/styleguide/pyguide.html """ -from typing import List, Union # NOQA +from datetime import timedelta +from typing import Any, Awaitable, Callable, Concatenate, List, Mapping, Optional, Sequence, Union, overload # NOQA module_level_variable1 = 12345 @@ -298,3 +299,212 @@ class ExamplePEP526Class: attr1: str attr2: int + + +_not_in_the_demo = object() + +@overload +async def overwhelming_overload( + workflow: tuple[Any, Any], + *, + id: str, + task_queue: str, + execution_timeout: Optional[timedelta] = None, + run_timeout: Optional[timedelta] = None, + task_timeout: Optional[timedelta] = None, + id_reuse_policy: _not_in_the_demo = '_not_in_the_demo.WorkflowIDReusePolicy.ALLOW_DUPLICATE', + id_conflict_policy: _not_in_the_demo = '_not_in_the_demo.WorkflowIDConflictPolicy.UNSPECIFIED', + retry_policy: Optional[_not_in_the_demo.RetryPolicy] = None, + cron_schedule: str = "", + memo: Optional[Mapping[str, Any]] = None, + search_attributes: Optional[ + Union[ + _not_in_the_demo.TypedSearchAttributes, + _not_in_the_demo.SearchAttributes, + ] + ] = None, + start_delay: Optional[timedelta] = None, + start_signal: Optional[str] = None, + start_signal_args: Sequence[Any] = [], + rpc_metadata: Mapping[str, str] = {}, + rpc_timeout: Optional[timedelta] = None, + request_eager_start: bool = False, +) -> tuple[Any, Any]: ... + +# Overload for single-param workflow +@overload +async def overwhelming_overload( + workflow: tuple[Any, Any, Any], + arg: Any, + *, + id: str, + task_queue: str, + execution_timeout: Optional[timedelta] = None, + run_timeout: Optional[timedelta] = None, + task_timeout: Optional[timedelta] = None, + id_reuse_policy: _not_in_the_demo.WorkflowIDReusePolicy = '_not_in_the_demo.WorkflowIDReusePolicy.ALLOW_DUPLICATE', + id_conflict_policy: _not_in_the_demo.WorkflowIDConflictPolicy = '_not_in_the_demo.WorkflowIDConflictPolicy.UNSPECIFIED', + retry_policy: Optional[_not_in_the_demo.RetryPolicy] = None, + cron_schedule: str = "", + memo: Optional[Mapping[str, Any]] = None, + search_attributes: Optional[ + Union[ + _not_in_the_demo.TypedSearchAttributes, + _not_in_the_demo.SearchAttributes, + ] + ] = None, + start_delay: Optional[timedelta] = None, + start_signal: Optional[str] = None, + start_signal_args: Sequence[Any] = [], + rpc_metadata: Mapping[str, str] = {}, + rpc_timeout: Optional[timedelta] = None, + request_eager_start: bool = False, +) -> tuple[Any, Any]: ... + +# Overload for multi-param workflow +@overload +async def overwhelming_overload( + workflow: Callable[ + Concatenate[Any, Any], Awaitable[Any] + ], + *, + args: Sequence[Any], + id: str, + task_queue: str, + execution_timeout: Optional[timedelta] = None, + run_timeout: Optional[timedelta] = None, + task_timeout: Optional[timedelta] = None, + id_reuse_policy: _not_in_the_demo.WorkflowIDReusePolicy = '_not_in_the_demo.WorkflowIDReusePolicy.ALLOW_DUPLICATE', + id_conflict_policy: _not_in_the_demo.WorkflowIDConflictPolicy = '_not_in_the_demo.WorkflowIDConflictPolicy.UNSPECIFIED', + retry_policy: Optional[_not_in_the_demo.RetryPolicy] = None, + cron_schedule: str = "", + memo: Optional[Mapping[str, Any]] = None, + search_attributes: Optional[ + Union[ + _not_in_the_demo.TypedSearchAttributes, + _not_in_the_demo.SearchAttributes, + ] + ] = None, + start_delay: Optional[timedelta] = None, + start_signal: Optional[str] = None, + start_signal_args: Sequence[Any] = [], + rpc_metadata: Mapping[str, str] = {}, + rpc_timeout: Optional[timedelta] = None, + request_eager_start: bool = False, +) -> tuple[Any, Any]: ... + +# Overload for string-name workflow +@overload +async def overwhelming_overload( + workflow: str, + arg: Any = _not_in_the_demo._arg_unset, + *, + args: Sequence[Any] = [], + id: str, + task_queue: str, + result_type: Optional[type] = None, + execution_timeout: Optional[timedelta] = None, + run_timeout: Optional[timedelta] = None, + task_timeout: Optional[timedelta] = None, + id_reuse_policy: _not_in_the_demo.WorkflowIDReusePolicy = '_not_in_the_demo.WorkflowIDReusePolicy.ALLOW_DUPLICATE', + id_conflict_policy: _not_in_the_demo.WorkflowIDConflictPolicy = '_not_in_the_demo.WorkflowIDConflictPolicy.UNSPECIFIED', + retry_policy: Optional[_not_in_the_demo.RetryPolicy] = None, + cron_schedule: str = "", + memo: Optional[Mapping[str, Any]] = None, + search_attributes: Optional[ + Union[ + _not_in_the_demo.TypedSearchAttributes, + _not_in_the_demo.SearchAttributes, + ] + ] = None, + start_delay: Optional[timedelta] = None, + start_signal: Optional[str] = None, + start_signal_args: Sequence[Any] = [], + rpc_metadata: Mapping[str, str] = {}, + rpc_timeout: Optional[timedelta] = None, + request_eager_start: bool = False, +) -> tuple[Any, Any]: ... + +async def overwhelming_overload( + workflow: Union[str, Callable[..., Awaitable[Any]]], + arg: Any = _not_in_the_demo, + *, + args: Sequence[Any] = [], + id: str, + task_queue: str, + result_type: Optional[type] = None, + execution_timeout: Optional[timedelta] = None, + run_timeout: Optional[timedelta] = None, + task_timeout: Optional[timedelta] = None, + id_reuse_policy: _not_in_the_demo.WorkflowIDReusePolicy = '_not_in_the_demo.WorkflowIDReusePolicy.ALLOW_DUPLICATE', + id_conflict_policy: _not_in_the_demo.WorkflowIDConflictPolicy = '_not_in_the_demo.WorkflowIDConflictPolicy.UNSPECIFIED', + retry_policy: Optional[_not_in_the_demo.RetryPolicy] = None, + cron_schedule: str = "", + memo: Optional[Mapping[str, Any]] = None, + search_attributes: Optional[ + Union[ + _not_in_the_demo.TypedSearchAttributes, + _not_in_the_demo.SearchAttributes, + ] + ] = None, + start_delay: Optional[timedelta] = None, + start_signal: Optional[str] = None, + start_signal_args: Sequence[Any] = [], + rpc_metadata: Mapping[str, str] = {}, + rpc_timeout: Optional[timedelta] = None, + request_eager_start: bool = False, + stack_level: int = 2, +) -> tuple[Any, Any]: + """ + This is a big overload taken from the source code of temporalio sdk for Python. + The types don't make sens: it's only to showcase bigger overload. + + Start a workflow and return its handle. + + Args: + workflow: String name or class method decorated with + ``@workflow.run`` for the workflow to start. + arg: Single argument to the workflow. + args: Multiple arguments to the workflow. Cannot be set if arg is. + id: Unique identifier for the workflow execution. + task_queue: Task queue to run the workflow on. + result_type: For string workflows, this can set the specific result + type hint to deserialize into. + execution_timeout: Total workflow execution timeout including + retries and continue as new. + run_timeout: Timeout of a single workflow run. + task_timeout: Timeout of a single workflow task. + id_reuse_policy: How already-existing IDs are treated. + id_conflict_policy: How already-running workflows of the same ID are + treated. Default is unspecified which effectively means fail the + start attempt. This cannot be set if ``id_reuse_policy`` is set + to terminate if running. + retry_policy: Retry policy for the workflow. + cron_schedule: See https://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/ + memo: Memo for the workflow. + search_attributes: Search attributes for the workflow. The + dictionary form of this is deprecated, use + :py:class:`_not_in_the_demo.TypedSearchAttributes`. + start_delay: Amount of time to wait before starting the workflow. + This does not work with ``cron_schedule``. + start_signal: If present, this signal is sent as signal-with-start + instead of traditional workflow start. + start_signal_args: Arguments for start_signal if start_signal + present. + rpc_metadata: Headers used on the RPC call. Keys here override + client-level RPC metadata keys. + rpc_timeout: Optional RPC deadline to set for the RPC call. + request_eager_start: Potentially reduce the latency to start this workflow by + encouraging the server to start it on a local worker running with + this same client. + This is currently experimental. + + Returns: + A workflow handle to the started workflow. + + Raises: + temporalio.exceptions.WorkflowAlreadyStartedError: Workflow has + already been started. + RPCError: Workflow could not be started for some other reason. + """ + ... \ No newline at end of file