nodus.functions
View MarkdownFunctions, FunctionCalls and @app.cls classes (resources.md §3.10, §3.11, ADR-047, ADR-110).
.remote(), .spawn() and .map() all create FunctionCall objects, the one fan-out mechanism of R3. Arguments are
cloudpickled (nodus._serialize), results come back through a watch on the call, and a remote exception is re-raised
as its own type when that type is importable here.
class Cls(fn: _Function) -> NoneAn @app.cls class: Embedder() gives an object whose @nodus.method()s have .remote, .map, .spawn.
Cls.from_name
Section titled “Cls.from_name”from_name(app: str, name: str, project: str | None = None) -> _ClsClsObject
Section titled “ClsObject”class ClsObject(fn: _Function) -> NoneFunction
Section titled “Function”class Function(*, raw: Callable[..., Any] | None = None, app: _App | None = None, options: FunctionOptions | None = None, user_cls: type | None = None, method: str | None = None, deployed: str | None = None, deployed_app: str | None = None, project: str | None = None, instance: _Obj | None = None) -> NoneA Function defined with @app.function, a method of an @app.cls class, or a deployed one by name.
Function.estimate
Section titled “Function.estimate”estimate(*args: Any, **kwargs: Any) -> ViewDry-run one call: cold and warm start ETAs and the rate; .etag binds a reviewed launch.
Function.for_each
Section titled “Function.for_each”for_each(*iterables: Iterable[Any], ignore_exceptions: bool = False) -> NoneRun the function over the inputs and discard the results.
Function.from_name
Section titled “Function.from_name”from_name(app: str, name: str, project: str | None = None) -> _FunctionA deployed Function: <app>-<name> in the project (Function.lookup is an alias).
Function.get_raw_f
Section titled “Function.get_raw_f”get_raw_f() -> Callable[..., Any]The undecorated function (for a class method, the class).
Function.local
Section titled “Function.local”local(*args: Any, **kwargs: Any) -> AnyRun in this process, without Nodus.
Function.lookup
Section titled “Function.lookup”Function.map
Section titled “Function.map”map(*iterables: Iterable[Any], kwargs: dict[str, Any] | None = None, order_outputs: bool = True, return_exceptions: bool = False) -> AsyncIterator[Any]One FunctionCall per input, created in batches (≤1,000 calls, ≤8 MiB); results stream back as they finish.
Function.member
Section titled “Function.member”Function.remote
Section titled “Function.remote”remote(*args: Any, **kwargs: Any) -> AnyOne FunctionCall: block until it finishes and return its result, or raise its exception.
Function.spawn
Section titled “Function.spawn”spawn(*args: Any, **kwargs: Any) -> _FunctionCallStart one FunctionCall and return its handle without waiting.
Function.starmap
Section titled “Function.starmap”starmap(iterable: Iterable[Iterable[Any]], order_outputs: bool = True, return_exceptions: bool = False) -> AsyncIterator[Any]FunctionCall
Section titled “FunctionCall”class FunctionCall(name: str, function: str | None = None, project: str | None = None) -> NoneA handle on one FunctionCall: .get(timeout=None), .cancel(), .status(), .logs().
FunctionCall.cancel
Section titled “FunctionCall.cancel”cancel() -> NoneFunctionCall.from_name
Section titled “FunctionCall.from_name”from_name(name: str, project: str | None = None) -> _FunctionCallFunctionCall.function
Section titled “FunctionCall.function”Type: str | None
FunctionCall.get
Section titled “FunctionCall.get”get(timeout: float | None = None) -> AnyWait for the result; raises the remote exception, or TimeoutError after timeout seconds.
FunctionCall.logs
Section titled “FunctionCall.logs”logs(follow: bool = False) -> AsyncIterator[str]Log lines of the Function’s workers.
FunctionCall.name
Section titled “FunctionCall.name”Type: str
FunctionCall.status
Section titled “FunctionCall.status”status() -> str | NoneThe call’s phase: Queued, Running, Recovering, Succeeded, Failed, Cancelling or Cancelled.
FunctionOptions
Section titled “FunctionOptions”class FunctionOptions(name: str | None = None, gpu: Any = None, cpu: Any = None, memory: Any = None, ephemeral_disk: Any = None, image: Any = None, secrets: list[Any] = list(), volumes: dict[str, Any] = dict(), env: dict[str, str] | None = None, network: Any = None, timeout: Any = None, retries: Any = None, checkpoint: Any = None, interruptible: Any = None, region: Any = None, profile: Any = None, max_cost: Any = None, min_workers: int | None = None, max_workers: int | None = None, scaledown_window: Any = None, target_concurrency: int | None = None) -> NoneThe @app.function / @app.cls arguments, mapped to Function spec fields by spec().
FunctionOptions.checkpoint
Section titled “FunctionOptions.checkpoint”Type: Any
FunctionOptions.cpu
Section titled “FunctionOptions.cpu”Type: Any
FunctionOptions.env
Section titled “FunctionOptions.env”Type: dict[str, str] | None
FunctionOptions.ephemeral_disk
Section titled “FunctionOptions.ephemeral_disk”Type: Any
FunctionOptions.gpu
Section titled “FunctionOptions.gpu”Type: Any
FunctionOptions.image
Section titled “FunctionOptions.image”Type: Any
FunctionOptions.interruptible
Section titled “FunctionOptions.interruptible”Type: Any
FunctionOptions.max_cost
Section titled “FunctionOptions.max_cost”Type: Any
FunctionOptions.max_workers
Section titled “FunctionOptions.max_workers”Type: int | None
FunctionOptions.memory
Section titled “FunctionOptions.memory”Type: Any
FunctionOptions.min_workers
Section titled “FunctionOptions.min_workers”Type: int | None
FunctionOptions.name
Section titled “FunctionOptions.name”Type: str | None
FunctionOptions.network
Section titled “FunctionOptions.network”Type: Any
FunctionOptions.profile
Section titled “FunctionOptions.profile”Type: Any
FunctionOptions.region
Section titled “FunctionOptions.region”Type: Any
FunctionOptions.retries
Section titled “FunctionOptions.retries”Type: Any
FunctionOptions.scaledown_window
Section titled “FunctionOptions.scaledown_window”Type: Any
FunctionOptions.secrets
Section titled “FunctionOptions.secrets”Type: list[Any]
FunctionOptions.target_concurrency
Section titled “FunctionOptions.target_concurrency”Type: int | None
FunctionOptions.timeout
Section titled “FunctionOptions.timeout”Type: Any
FunctionOptions.volumes
Section titled “FunctionOptions.volumes”Type: dict[str, Any]
clustered
Section titled “clustered”clustered(size: int, launcher: str = 'Plain', network: str = 'Colocated', transport: str = 'Direct') -> Callable[[Callable[..., Any]], Callable[..., Any]]Run each .remote() or .spawn() as one gang of size nodes; rank 0’s return value is the result (Beta).
Apply it below @app.function. nodus.cluster.info() gives each member its rank and the gang’s addresses.