# kosa8 cloud code

Run Python in a stateful interpreter in a cloud sandbox; charts come back as images

## Usage

```
kosa8 cloud code ID [CODE]
```

Runs a Python cell in a context whose globals last between calls (like a
notebook). The code is the argument, else --file, else stdin. Charts
(matplotlib) come back as PNGs, saved with --save DIR. It needs a persistent
sandbox: kosa8 cloud sandbox create --persistent.

## Flags

| Flag | Type | What it does | Default |
|---|---|---|---|
| `--context` | string | the context to run in (default: default) |  |
| `--file, -f` | string | read the code from this file |  |
| `--save` | string | save returned images (charts) into this folder |  |
| `--timeout` | duration | stop the cell after this long | `1m0s` |

## Example

```
  kosa8 cloud code sbx_abc 'x = 21'
  kosa8 cloud code sbx_abc 'print(x * 2)'
  kosa8 cloud code sbx_abc -f plot.py --save ./charts
  kosa8 cloud code contexts sbx_abc
```

## Subcommands

- [`kosa8 cloud code contexts`](https://docs.kosa8.com/reference/cloud-code-contexts.md): List a sandbox's interpreter contexts (or --create one)
- [`kosa8 cloud code reset`](https://docs.kosa8.com/reference/cloud-code-reset.md): Clear a context's globals
- [`kosa8 cloud code rm`](https://docs.kosa8.com/reference/cloud-code-rm.md): Delete a context

---
Source: https://docs.kosa8.com/reference/cloud-code/
