Skip to content

Commit 4f7f6fb

Browse files
authored
fix: ctx_arg on function pod + empty-opts ray.remote (ITL-544) (#235)
1 parent 7cba467 commit 4f7f6fb

5 files changed

Lines changed: 1280 additions & 4 deletions

File tree

src/orcapod/core/function_pod.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,33 @@ def side_effect_function_pod(
12281228
) -> "FunctionPod | Callable":
12291229
"""Decorator wrapping a callable as a ctx-aware ``FunctionPod``.
12301230
1231+
Note:
1232+
This decorator is superseded by ``@function_pod(ctx_arg=<arg_name>)``,
1233+
which is now the preferred way to author side-effect pods. The two
1234+
forms are equivalent in computational behaviour but differ in the type
1235+
of the decorated object: ``@function_pod(...)`` returns a plain callable
1236+
with a ``.pod`` attribute, whereas this decorator returns the
1237+
``FunctionPod`` directly.
1238+
1239+
Preferred form (use this instead)::
1240+
1241+
@function_pod(output_keys=["result"], ctx_arg="ctx")
1242+
def my_fn(value: int, ctx: InvocationContext) -> str:
1243+
...
1244+
1245+
assert callable(my_fn) # still a plain callable
1246+
assert isinstance(my_fn.pod, FunctionPod)
1247+
1248+
Legacy form (this decorator)::
1249+
1250+
@side_effect_function_pod(output_keys=["result"])
1251+
def my_fn(value: int, ctx: InvocationContext) -> str:
1252+
...
1253+
1254+
assert isinstance(my_fn, FunctionPod) # decorated object IS the pod
1255+
1256+
Full removal of this decorator is tracked separately.
1257+
12311258
Equivalent to ``FunctionPod.from_fn(fn, output_keys=..., ctx_arg_name=...)``.
12321259
The decorated object is the ``FunctionPod`` itself (not a wrapper function),
12331260
so it can be called directly as a pod.

0 commit comments

Comments
 (0)