Skip to main content

orchestrator_from_str

Create a reusable sandboxed task from a code string.

def orchestrator_from_str(
source: str,
inputs: Dict[str, type],
output: type = type(None),
tasks: Optional[List[Any]] = None,
name: str = "sandboxed-code",
timeout_ms: int = 30_000,
cache: CacheRequest = "disable",
retries: int = 0,
image: Optional[Any] = None
) - > CodeTaskTemplate

Create a reusable sandboxed task from a code string. The returned CodeTaskTemplate can be passed to flyte.run() just like a decorated task. The last expression in source becomes the return value.

Parameters

NameTypeDescription
sourcestrPython code string to execute in the sandbox.
inputsDict[str, type]Mapping of input names to their types.
outputtype = type(None)The return type (default NoneType).
tasksOptional[List[Any]] = NoneList of external functions (tasks, durable ops) available inside the sandbox. Each item's __name__ is used as the key.
namestr = "sandboxed-code"Task name (default "sandboxed-code").
timeout_msint = 30_000Sandbox execution timeout in milliseconds.
cacheCacheRequest = "disable"Cache policy for the task.
retriesint = 0Number of retries on failure.
imageOptional[Any] = NoneDocker image to use. If not provided, a default Debian image with pydantic-monty is created automatically.

Returns

TypeDescription
CodeTaskTemplate