Skip to content
Draft
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
14 changes: 14 additions & 0 deletions temporalio/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,20 @@ def must_from_callable(fn: Callable) -> _Definition:
f"Activity {fn_name} missing attributes, was it decorated with @activity.defn?"
)

@classmethod
def get_name_and_result_type(
cls, name_or_run_fn: Union[str, Callable[..., Any]]
) -> Tuple[str, Optional[Type]]:
if isinstance(name_or_run_fn, str):
return name_or_run_fn, None
elif callable(name_or_run_fn):
defn = cls.must_from_callable(name_or_run_fn)
if not defn.name:
raise ValueError(f"Activity {name_or_run_fn} definition has no name")
return defn.name, defn.ret_type
else:
raise TypeError("Activity must be a string or callable")

@staticmethod
def _apply_to_callable(
fn: Callable,
Expand Down
10 changes: 9 additions & 1 deletion temporalio/api/activity/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from .message_pb2 import ActivityOptions
from .message_pb2 import (
ActivityExecutionInfo,
ActivityListInfo,
ActivityOptions,
OnConflictOptions,
)

__all__ = [
"ActivityExecutionInfo",
"ActivityListInfo",
"ActivityOptions",
"OnConflictOptions",
]
94 changes: 91 additions & 3 deletions temporalio/api/activity/v1/message_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading