# Open a sample OME-Zarr image in napari

## 1. Clone the course environment

Use the terminal from the Conda installation activity. You need a working `skimage-napari-tutorial` environment, a graphical desktop, and network access to the package channels and the Image Data Resource (IDR). Close any napari windows or notebooks using the environment before starting. Use an unused name for the clone and substitute it throughout if `skimage-napari-ome-zarr` already exists.

```bash
conda env list
conda create --name skimage-napari-ome-zarr --clone skimage-napari-tutorial
conda list --name skimage-napari-ome-zarr --revisions
conda list --name skimage-napari-ome-zarr "^napari-ome-zarr$"
```

Record the latest revision number in the **clone**. If the plugin already appears in the package list, use a fresh copy of the original course environment for the exercise. The baseline already includes BioIO readers installed through pip. Conda's plan covers the Conda transaction. The post-install checks below help catch problems with the Python packages.

## 2. Preview the installation and decide whether to proceed

The [conda-forge package](https://anaconda.org/conda-forge/napari-ome-zarr) adds an OME-Zarr reader to napari. The course YAML already lists `bioio-ome-zarr`, which is a reader for BioIO.

```bash
conda install --name skimage-napari-ome-zarr --override-channels -c conda-forge -c euro-bioimaging --freeze-installed --dry-run napari-ome-zarr
```

Read the target environment and the package plan. Record one proposed addition and check for removals, updates, downgrades, or channel changes, especially for Python, napari, Qt/PySide6, NumPy and Zarr. The command uses the two channels from the course YAML in the same order. `--freeze-installed` asks Conda to keep existing Conda dependency packages at their installed versions while allowing new dependencies.

If the solver reports incompatible requirements, read the dependency chain to identify the package and version bounds involved. To see which changes might resolve the conflict, repeat the preview without `--freeze-installed` and keep `--dry-run`. If the plan calls for changes you cannot justify, pause and use the fresh-environment route below with your instructor. If the error reports a missing package or a network failure, check the channel list, platform and connection before changing version constraints. Keep dependency checking enabled.

If the frozen plan is acceptable, run the same command without `--dry-run`. Compare the displayed plan with the preview before answering the confirmation prompt.

```bash
conda install --name skimage-napari-ome-zarr --override-channels -c conda-forge -c euro-bioimaging --freeze-installed napari-ome-zarr
```

**Fresh-environment route.** Copy the original `skimage_napari_env.yaml` to `skimage-napari-ome-zarr-fresh.yaml`. Set `name:` to an unused name, such as `skimage-napari-ome-zarr-fresh`. Add `- napari-ome-zarr` at the same indentation as the other Conda dependencies, before the nested `pip:` section. Create the environment with `conda env create --file skimage-napari-ome-zarr-fresh.yaml`. This solves the Conda packages together before installing the existing pip readers. Use the fresh name in the verification and export steps. The revision exercise below is for the clone.

## 3. Check both napari and the new reader

```bash
conda activate skimage-napari-ome-zarr
conda list "^napari-ome-zarr$"
python -m pip check
napari --version
```

Record the plugin version and investigate any dependency errors from `pip check` before proceeding. Run the [course installation test](install_skimage_napari_conda.md#test-the-environment) again to check that the original TIFF workflow still works. If you use Jupyter, launch it from this environment and use its Python kernel.

Then open this public [IDR image used in the napari workshop](https://napari.org/workshops/extend/code/#opening-a-remote-ome-zarr-image):

```bash
napari --plugin napari-ome-zarr "https://livingobjects.ebi.ac.uk/idr/zarr/v0.4/idr0048A/9846152.zarr/"
```

Confirm that the image displays and that you can zoom or move through the z planes. Record one observation from the viewer. If napari opens but the remote data fail to load, try a local OME-Zarr directory supplied by your instructor by replacing the URL with its quoted path. If napari itself fails to open, record the terminal error and check the graphics setup or environment with your instructor.

## 4. Record the setup and practise recovery

Once both workflows pass, save a curated copy of the course YAML with the plugin added as shown above. Record the plugin version, platform and any version bounds needed to repeat your result. You can also capture the exact Conda builds for the current platform:

```bash
conda list --explicit > skimage-napari-conda-explicit.txt
```

Close napari and any notebooks before practising recovery. Activate the original course environment to resume work immediately:

```bash
conda activate skimage-napari-tutorial
```

If you installed the plugin with Conda on the clone, practise rolling back the clone. In the example below, replace `0` with the revision you recorded before installation. Preview the rollback first and proceed only if the plan restores the expected Conda packages.

```bash
conda list --name skimage-napari-ome-zarr --revisions
conda install --name skimage-napari-ome-zarr --revision 0 --dry-run
conda install --name skimage-napari-ome-zarr --revision 0
conda list --name skimage-napari-ome-zarr "^napari-ome-zarr$"
```

The last command should show no package row if the plugin was absent at the baseline. Activate the clone again and repeat the original course test. If pip changed packages, or if Conda can no longer retrieve a build needed for rollback, use the intact original or recreate the environment from a reviewed specification.
