A Function is a portable code block that can be sent to remote hardware to run as a subroutine or service. It is comprised of the entrypoint, system (Cluster), and requirements necessary to run it.
Builds an instance of
fn (Optional[str or Callable]) – The function to execute on the remote system when the function is called.
name (Optional[str]) – Name of the Function to create or retrieve. This can be either from a local config or from the RNS.
system (Optional[str or Cluster]) – Hardware (cluster) on which to execute the Function. This can be either the string name of a Cluster object, or a Cluster object.
env (Optional[List[str] or Env or str]) – List of requirements to install on the remote cluster, or path to the requirements.txt file, or Env object or string name of an Env object.
resources (Optional[dict]) – Optional number (int) of resources needed to run the Function on the Cluster.
Keys must be
dryrun (bool) – Whether to create the Function if it doesn’t exist, or load the Function object as a dryrun.
load_secrets (bool) – Whether or not to send secrets; only applicable if dryrun is set to
serialize_notebook_fn (bool) – If function is of a notebook setting, whether or not to serialized the function.
The resulting Function object.
- __init__(fn_pointers: Tuple | None = None, name: str | None = None, system: Cluster | None = None, env: Env | None = None, dryrun: bool = False, access: str | None = None, resources: dict | None = None, **kwargs)
Runhouse Function object. It is comprised of the entrypoint, system/cluster, and dependencies necessary to run the service.
To create a Function, please use the factory method
Create a Function object from a config dictionary.
Get the result of a Function call that was submitted as async using run.
run_key – A single or list of runhouse run_key strings returned by a Function.remote() call. The ObjectRefs must be from the cluster that this Function is running on.
Check if object already exists on cluster or rns, and if so return the result. If not, run the function. Keep in mind this can be called with any of the usual method call modifiers - remote=True, run_async=True, stream_logs=False, etc.
run_name (Optional[str]) – Name of a particular run for this function. If not provided will use the function’s name.
load (bool) – Whether to load the name from the RNS if it exists.
*args – Arguments to pass to the function for the run (relevant if creating a new run).
**kwargs – Keyword arguments to pass to the function for the run (relevant if creating a new run).
Result of the Run
Return the endpoint needed to run the Function on the remote cluster, or provide the curl command if requested.
Keep the system warm for autostop_mins. If autostop_mins is
None or -1, keep warm indefinitely.
Tunnel into and launch notebook from the system.
Helper property to allow for access to remote properties, both public and private. Returning functions is not advised.
map() except that the elements of the iterable are expected to be iterables
that are unpacked as arguments. An iterable of [(1,2), (3, 4)] results in [func(1,2), func(3,4)].