Skip to content

Commit

Permalink
Simplify getting started page
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Nov 27, 2024
1 parent 4bc8517 commit aff5c77
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 78 deletions.
61 changes: 61 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Getting Started

We'll start with a simple example that runs locally.

## Installation

Install Cubed with pip:

```shell
pip install cubed
```

This installs a minimal set of dependencies for running Cubed, which is sufficient for the demo below. You can also install the `diagnostics` extra package, which is needed for later examples to provide things like progress bars and visualizations of the computation:

```shell
pip install "cubed[diagnostics]"
```

Alternatively, you can install Cubed with Conda (note that this doesn't include the packages for diagnostics):

```shell
conda install -c conda-forge cubed
```

## Demo

First, we'll create a small array `a`:

```python
import cubed
import cubed.array_api as xp
spec = cubed.Spec(work_dir="tmp", allowed_mem="100kB")
a = xp.asarray([[1, 2, 3], [4, 5, 6], [7, 8, 9]], chunks=(2, 2), spec=spec)
```

Cubed implements the [Python Array API standard](https://data-apis.org/array-api/latest/), which is essentially a subset of NumPy, and is imported as `xp` by convention.

Notice that we also specify chunks, just like in Dask Array, and a {py:class}`Spec <cubed.Spec>` object that describes the resources available to run computations.

Next we create another array `b` and add to two array together to get `c`.

```python
b = xp.asarray([[1, 1, 1], [1, 1, 1], [1, 1, 1]], chunks=(2, 2), spec=spec)
c = xp.add(a, b)
```

Cubed uses lazy evaluation, so nothing has been computed yet.

```python
c.compute()
```

This runs the computation using the (default) local Python executor and prints the result (if run interactively):

```
array([[ 2, 3, 4],
[ 5, 6, 7],
[ 8, 9, 10]])
```

That's it! For your next step you can read the [user guide](user-guide/index.md), have a look at [configuration](configuration.md) options, or see more [examples](https://github.com/cubed-dev/cubed/blob/main/examples/README.md) to run locally or in the cloud.
35 changes: 0 additions & 35 deletions docs/getting-started/demo.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/getting-started/index.md

This file was deleted.

28 changes: 0 additions & 28 deletions docs/getting-started/installation.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Cubed is horizontally scalable and stateless, and can scale to multi-TB datasets
:hidden:
:maxdepth: 2
:caption: For users
getting-started/index
getting-started
user-guide/index
Intro slides <https://cubed-dev.github.io/cubed/cubed-intro.slides.html>
Examples <https://github.com/tomwhite/cubed/tree/main/examples/README.md>
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Cubed provides a variety of tools to understand a computation before running it,
To use these features ensure that the optional dependencies for diagnostics have been installed:

```shell
python -m pip install "cubed[diagnostics]"
pip install "cubed[diagnostics]"
```

## Visualize the computation plan
Expand Down

0 comments on commit aff5c77

Please sign in to comment.