Skip to content

Commit 70a1591

Browse files
authored
Dev Tools: Add Bacalhau (protocol#479)
1 parent 0c78b82 commit 70a1591

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: "Bacalhau"
3+
description: "A Computer Over Data Framework for IPFS"
4+
draft: false
5+
menu:
6+
curriculum:
7+
parent: "curriculum-devtools"
8+
category: lecture
9+
weight: 80
10+
level:
11+
- shallow
12+
- deep
13+
---
14+
15+
Bacalhau is a framework that allows you to perform distributed computations on IPFS.
16+
These computations are executed in the form of Docker containers or WASM programs.
17+
18+
The **Bacalhau network is a set of computers (nodes) working ready to perform computations**.
19+
You can send your computation (Docker container or WASM) to the Bacalhau network and then read the results.
20+
Every computation has an _input_ and an _output_.
21+
In Bacalhau, the main idea is that the **input is taken from IPFS, and the output is published to IPFS**.
22+
23+
For example, consider that you have a Python script stored on IPFS, with CID `QmR1...`.
24+
This script prints numbers from 0 to 100, and you want to execute it on the Bacalhau network.
25+
26+
![Bacalhau Overview](bacalhau-overview.png)
27+
28+
First, you provide the CID of the Python script to the Bacalhau network.
29+
The script is fetched from IPFS, and is executed by one or several Bacalhau nodes.
30+
After the computation is finished, the results (the numbers printed) are published to IPFS, with a new CID, `QmFH...`.
31+
32+
## Architecture
33+
34+
Every node in the Bacalhau network can act as a _requester node_ or a _compute node_.
35+
Requester nodes are responsible for receiving the computations (in technical terms, called **jobs**) and delegating them to one or several compute nodes.
36+
Compute nodes are responsible for performing the actual computation.
37+
38+
![Bacalhau High Level Architecture](bacalhau-architecture.png)
39+
40+
The lifecycle of a job in Bacalhau is a complex task that includes several steps and verifications.
41+
You can read everything about the Bacalhau architecture in the [official documentation](https://docs.bacalhau.org/about-bacalhau/architecture).
42+
43+
## The Bacalhau CLI
44+
45+
Sending your computations and communicating with the Bacalhau network is pretty easy by using the Bacalhau CLI.
46+
The `bacalhau` command installed on your computer allows you to send a new job (computation), retrieve its status, or get its results.
47+
48+
```bash
49+
> bacalhau docker run ubuntu echo Hello World
50+
```
51+
52+
The previous command creates a new job in Bacalhau network by using a Docker image.
53+
Specifically, it runs an Ubuntu container and executes `echo Hello World` inside the container.
54+
55+
You can then verify the status of the job by executing the following command.
56+
57+
```bash
58+
> bacalhau list --id-filter=${JOB_ID}
59+
```
60+
61+
If you are familiar with Docker, you should identify the `docker run` command, which allows you to execute Docker containers.
62+
The Bacalhau CLI adds several options on top of this command.
63+
64+
```bash
65+
> bacalhau docker run \
66+
-v QmfKJT13h5k1b23ja3ZCVg5nFL9oKz2bVXc8oXgtwiwhjz:/files \
67+
ubuntu cat /files/read_csv.py
68+
```
69+
70+
In the previous example, the command `cat /files/read_csv.py` is executed inside an Ubuntu container.
71+
The `-v` (volume) option allows you to mount an IPFS file or folder to a directory inside the Docker container.
72+
The IPFS folder with CID `QmfKJT13h5k1b23ja3ZCVg5nFL9oKz2bVXc8oXgtwiwhjz` is mounted to the `/files` directory inside the container. Therefore:
73+
1. An Ubuntu Docker container is created
74+
2. The `QmfKJT13h5k1b23ja3ZCVg5nFL9oKz2bVXc8oXgtwiwhjz` IPFS folder is mounted to the `/files` directory inside the container.
75+
3. The file is read by using the `cat` command.
76+
77+
Now that you understand the basics of Bacalhau, check out the great examples in the [official documentation](https://docs.bacalhau.org/examples/).

0 commit comments

Comments
 (0)