# Validate and profile an environment

Check that an environment version runs, and measure what it needs, so you can train on it.

**Validation** builds your entrypoint class in an isolated sandbox and runs a list of tests against it: that the class loads, that its spaces are consistent, and that `reset` and `step` behave. By default it also plays a few random episodes and records their scores. **Profiling** runs after a successful validation and measures the CPU and RAM each copy of the environment uses, so Arena can size the training job.

You can launch an experiment on a version once it is validated and profiled.

## Prerequisites

- An environment you uploaded from your own code. See [Upload an environment](upload-an-environment.md).

## Check a version

### Web app

Open **Environments** in the sidebar and click the environment. Pick a version from the version dropdown at the top left. Beside it, the page shows when the version was **Created** and **Validated**, and its **State**.

| State                  | Meaning                                                          |
|------------------------|------------------------------------------------------------------|
| **Pending validation** | Validation hasn’t finished yet.                                  |
| **Validated**          | All tests passed.                                                |
| **Failed validation**  | A test failed. The **Validation failed** banner shows the error. |
| **Edited**             | You changed the code since it was validated. Validate again.     |

The results appear as cards:

- **Resource Usage**: CPU and memory over time, with steps per second, from profiling.
- **Random episode score distribution**: scores from the random episodes.
- **Environment summary**: the observation and action spaces Arena found.

The **Tests** list on the left shows each check and whether it passed.

When the version is ready, the rocket button at the top right is enabled. Click it to start an experiment on this version. While it is disabled, its tooltip says what is missing: validation, profiling still running, or no resource estimate yet.

### CLI

```bash
arena env list --name guess-the-number
```

lists the environment’s versions and whether each one is validated. To validate a registered version again, this time with random episodes:

```bash
arena env validate guess-the-number --version v1 --do-rollouts
```

Flags are in the [command reference](../cli/command-reference.md).

## Fix or change the code

### Web app

1. Click the code button beside the rocket (**Switch to editor**). The editor opens with your files, the **Entrypoint**, **Requirements** and **Configuration** on the left.
2. Edit the files. The state changes to **Edited**.
3. Click **Validate**. To skip the random episodes, which is faster but tells you less, open the arrow beside **Validate** and clear **Run with random episodes**.
4. When validation passes, click **Save**. In **Save version**, keep the version’s name to overwrite it, or enter a new name to save the changes as a new version. Click **Undo** instead to throw the changes away.

Arena profiles the saved version. The rocket button stays disabled until profiling finishes.

To start a new version from scratch, click **New Version**. To copy, rename or delete the selected version, use the **⋮** menu at the top right: **Duplicate version**, **Rename version** and **Delete version**.

### CLI

Upload the changed code as a new version and validate it:

```bash
arena env validate guess-the-number --version v2 --source ./guess_the_number.tar.gz
```

The new version is the changed copy; the versions you already have stay as they are. To copy a version without changing it, for example to keep a backup under another name:

```bash
arena env duplicate guess-the-number v1-backup --version v1
```

## When validation fails

- **A test fails.** The banner and the **Tests** list name the check. Fix the code or the entrypoint, then validate again.
- **Requirements fail to install.** **Validate** stays disabled and its tooltip shows the install error. Fix the package list under **Requirements**.
- **Profiling fails.** The version stays without a resource estimate. Fix the environment and validate again to rerun profiling.
