Skip to main content

Function decorator + map()

@anycloud.function() runs a Python function on a cloud GPU with your repo synced from git at run time — change the code, commit, push, and rerun without rebuilding the image. .map() fans the function out across inputs in parallel.

import anycloud
from anycloud.types import CloudConfig

@anycloud.function(
image="ghcr.io/<your-github-user>/base:latest", # must have git installed
gpu="h100:8",
cloud_config=CloudConfig(
credentials="my-aws",
spot=True,
input_bucket="eval-data",
output_bucket="eval-results",
),
)
def relax(structure_index: str, fmax: float = 0.01):
# Arguments must be JSON-serializable; return values are discarded —
# write results to /mnt/output.
...

# One job
job = relax.submit("0:10", fmax=0.005, id="relax-0to10")
job.wait()
print(job.logs())

# Fan out in parallel with custom IDs
args = [f"{i}:{i+10}" for i in range(0, 270, 10)]
ids = [f"relax-{i}to{i+10}" for i in range(0, 270, 10)]
jobs = relax.map(args, ids=ids)
jobs.wait()

Each item in args becomes one positional argument. For multi-argument calls, pass tuples and unpack inside the function, or call submit() in a loop.

Requirements: your code committed and pushed to GitHub, and git installed in the image. See Function Decorator and Deploying Jobs.