Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golem-Workers fixes after beta tests #326

Merged
merged 15 commits into from
Oct 8, 2024
Merged
17 changes: 10 additions & 7 deletions src/pages/docs/creators/golem-workers/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ This doesn't require a Python environment whatsoever. It is enough to have `dock

Make sure that [Docker](https://docker.com) is running on your machine and that your current user has access to it.

The instructions below have been tested with `Docker Compose V2`.

### 2. Clone the repository

Create a folder on your computer, navigate into it from the terminal, and then clone the repository using the command:
Expand Down Expand Up @@ -123,22 +125,23 @@ yagna app-key create <your-token-name>

And put the generated app-key into the `.env` file in the current directory:

```
YAGNA_APPKEY=<your-application-token>
```bash
echo 'YAGNA_APPKEY=<your-application-token>' >> .env
```

This will allow `golem-node` to know your `golem-workers` instance.

### 5. Use Golem Reputation (optional)
### 5. Use Golem Reputation

If you want to use the Golem Reputation service (to use only nodes with a record of good behavior)
put a new entry in the `.env` file in the current directory:
Golem Reputation service (prioritizing nodes with a record of good behavior)
requires putting a new entry in the `.env` file in the current directory:

```
GLOBAL_CONTEXTS=["golem_reputation.ReputationService"]
```bash
echo 'GLOBAL_CONTEXTS=["golem_reputation.ReputationService"]' >> .env
```

Note that, the [examples](/docs/creators/golem-workers/hello-example) in this documentation require the above to work properly.
You can skip this step if you don't use Golem Reputation in your jsons.

### 6. Start Golem-Workers

Expand Down
114 changes: 16 additions & 98 deletions src/pages/docs/creators/golem-workers/hello-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ the [Stable Diffusion tutorial](/docs/creators/golem-workers/sd-example) availab

## Prerequisites

We will be using **`curl`** to interact with the Golem-Workers API, which runs on **localhost:8000**
We will be using **`curl`** (for Windows users consider PowerShell command `Invoke-WebRequest` instead)
to interact with the Golem-Workers API, which runs on **localhost:8000**
(see [Getting started](/docs/creators/golem-workers/getting-started) if it is not).
All API requests will use **JSON data** to configure and manage the Golem-Workers service.

Expand All @@ -36,48 +37,10 @@ curl --location 'http://localhost:8000/create-cluster' \

This is the json file you have just used (also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/create-cluster.json)):
```json
{
"cluster_id": "example",
"budget_types": {
"default": {
"budget": {
"golem_workers.budgets.AveragePerCpuUsageLinearModelBudget": {
"average_cpu_load": 1,
"average_duration_hours": 0.5,
"average_max_cost": 1.5
}
},
"scope": "cluster"
}
},
"network_types": {
"default": {
"ip": "192.168.0.1/16"
}
},
"node_types": {
"default": {
"market_config": {
"filters": [
{
"golem_reputation.ProviderBlacklistPlugin": {
"payment_network": "holesky"
}
}
],
"sorters": [
{
"golem_reputation.ReputationScorer": {
"payment_network": "holesky"
}
}
]
}
}
}
}
```
{% codefromgithub url="https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/create-cluster.json" language="json" %}

{% /codefromgithub %}


### `create-cluster` JSON explained

Expand All @@ -100,54 +63,13 @@ curl --location 'http://localhost:8000/create-node' \

This is the json file you have just used (also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/create-node.json)):
```json
{
"cluster_id": "example",
"node_networks": {
"default": {}
},
"node_config": {
"market_config": {
"demand": {
"payloads": [
{
"golem_workers.payloads.ClusterNodePayload": {
"image_tag": "scalepointai/echo-test:2"
}
}
]
}
},
"on_start_commands": [
{
"golem_workers.work.deploy_and_start_activity": {
"deploy_timeout_minutes": 60
}
},
{
"golem_workers.work.run_in_shell": [
[
"nginx"
]
]
}
],
"sidecars": [
{
"golem_workers.sidecars.WebsocatPortTunnelSidecar": {
"network_name": "default",
"local_port": "8080",
"remote_port": "80"
}
}
]
}
}
```
{% codefromgithub url="https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/create-node.json" language="json" %}

{% /codefromgithub %}

### `create-node` JSON explained

- **Image**: The node runs the **Hello Service** image `scalepointai/echo-test:2`,
- **Image**: The node runs the **Hello Service** image `modelserve/echo-test:2`,
which is a simple NGINX-based service that returns "Hello" on port **80**.
- **Commands**: We deploy the node and start the service using NGINX.
- **Port Forwarding**: We forward port **80** on the node to **localhost:8080** on your machine,
Expand All @@ -166,11 +88,9 @@ curl --location 'http://localhost:8000/get-cluster' \

This is the json file you have just used (also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/get-cluster.json)):
```json
{
"cluster_id": "example",
}
```
{% codefromgithub url="https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/get-cluster.json" language="json" %}

{% /codefromgithub %}

## 4. Access the Hello Service

Expand All @@ -189,11 +109,9 @@ curl --location 'http://localhost:8000/delete-cluster' \

This is the json file you have just used (also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/delete-cluster.json)):
```json
{
"cluster_id": "example"
}
```
{% codefromgithub url="https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/delete-cluster.json" language="json" %}

{% /codefromgithub %}

---

Expand Down
139 changes: 20 additions & 119 deletions src/pages/docs/creators/golem-workers/sd-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ In this example, we’ll show you how to run a sample [Automatic1111](https://gi

## Prerequisites

We will be using **`curl`** to interact with the Golem-Workers API, which runs on **localhost:8000**
We will be using **`curl`** (for Windows users consider PowerShell command `Invoke-WebRequest` instead)
to interact with the Golem-Workers API, which runs on **localhost:8000**
(see [Getting started](/docs/creators/golem-workers/getting-started) if it is not).
All API requests will use **JSON data** to configure and manage the Golem-Workers service.

Expand Down Expand Up @@ -53,51 +54,9 @@ curl --location 'http://localhost:8000/create-cluster' \

This is the json file you have just used (also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/sd-example/create-cluster.json)):
```json
{
"cluster_id": "example",
"payment_config": {
"network": "polygon"
},
"budget_types": {
"default": {
"budget": {
"golem_workers.budgets.AveragePerCpuUsageLinearModelBudget": {
"average_cpu_load": 1,
"average_duration_hours": 0.5,
"average_max_cost": 1.5
}
},
"scope": "cluster"
}
},
"network_types": {
"default": {
"ip": "192.168.0.1/16"
}
},
"node_types": {
"default": {
"market_config": {
"filters": [
{
"golem_reputation.ProviderBlacklistPlugin": {
"payment_network": "polygon"
}
}
],
"sorters": [
{
"golem_reputation.ReputationScorer": {
"payment_network": "polygon"
}
}
]
}
}
}
}
```
{% codefromgithub url="https://github.com/golemfactory/golem-workers/raw/main/examples/sd-example/create-cluster.json" language="json" %}

{% /codefromgithub %}

### `create-cluster` JSON explained

Expand Down Expand Up @@ -177,7 +136,7 @@ will be considered when selecting a provider.
## 3. Create a node

Next, create a node based on the image
[scalepointai/automatic1111:4](https://registry.golem.network/explore/scalepointai/automatic1111)
[modelserve/automatic1111:4](https://registry.golem.network/explore/modelserve/automatic1111)
and specify the path to the model
(e.g. a precached on Golem Network proxy SD model `https://gpu-provider.dev.golem.network/models/v1-5-pruned-emaonly.safetensors` ).

Expand All @@ -189,63 +148,9 @@ curl --location 'http://localhost:8000/create-node' \

This is the json file you have just used (also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/sd-example/create-node.json)):
```json
{
"cluster_id": "example",
"node_networks": {
"default": {}
},
"node_config": {
"market_config": {
"demand": {
"payloads": [
{
"golem_workers.payloads.ClusterNodePayload": {
"runtime": "vm-nvidia",
"image_tag": "scalepointai/automatic1111:4",
"outbound_urls": [
"https://gpu-provider.dev.golem.network"
]
}
}
]
}
},
"on_start_commands": [
{
"golem_workers.work.deploy_and_start_activity": {
"deploy_timeout_minutes": 60
}
},
{
"golem_workers.work.prepare_and_run_ssh_server": {
"ssh_private_key_path": "/tmp/ssh_key"
}
},
{
"golem_workers.work.run_in_shell": [
"cd /usr/src/app/ && ./start.sh --model_url https://gpu-provider.dev.golem.network/models/v1-5-pruned-emaonly.safetensors > /usr/src/app/output/log 2>&1 &"
]
}
],
"sidecars": [
{
"golem_workers.sidecars.WebsocatPortTunnelSidecar": {
"network_name": "default",
"local_port": "8080",
"remote_port": "8000"
}
},
{
"golem_workers.sidecars.WebsocatPortTunnelSidecar": {
"network_name": "default",
"local_port": "8081",
"remote_port": "8001"
}
}
]
}
}
{% codefromgithub url="https://github.com/golemfactory/golem-workers/raw/main/examples/sd-example/create-node.json" language="json" %}

{% /codefromgithub %}

### `create-node` JSON explained

Expand All @@ -257,7 +162,7 @@ This is the json file you have just used (also available on
{
"golem_workers.payloads.ClusterNodePayload": {
"runtime": "vm-nvidia",
"image_tag": "scalepointai/automatic1111:4",
"image_tag": "modelserve/automatic1111:4",
"subnet_tag": "gpu-test",
"outbound_urls": [
"https://gpu-provider.dev.golem.network"
Expand All @@ -272,7 +177,7 @@ This is the json file you have just used (also available on
In this example, we are using the `vm-nvidia` runtime to obtain nodes with GPUs.
Additionally, we configure the node to allow downloading images from **Hugging Face** (which is available only on the testnet)
and our own **gpu-provider.dev.golem.network** proxy. The node will use the image
published to Golem Registry as [scalepointai/automatic1111](https://registry.golem.network/explore/scalepointai/automatic1111)
published to Golem Registry as [modelserve/automatic1111](https://registry.golem.network/explore/modelserve/automatic1111)
in version `4`.

This image includes a `start.sh` script that automatically downloads a model and starts the **Automatic1111 Web UI**.
Expand Down Expand Up @@ -356,13 +261,10 @@ curl --location 'http://localhost:8000/get-node' \

This is the json file you have just used (also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/sd-example/get-node.json)):
```json
{
"cluster_id": "example",
"node_id": "node0"
}
```

{% codefromgithub url="https://github.com/golemfactory/golem-workers/raw/main/examples/sd-example/get-node.json" language="json" %}

{% /codefromgithub %}
It returns the node’s state:

- `provisioning` means you have to wait a bit more for the negotiations with the available nodes to finish
Expand All @@ -385,8 +287,10 @@ To generate some images using the Automatic1111 GUI, you can either enter your p

#### Alternatively, use the automatic1111 API directly

Copy and run the following Python code (directly in the terminal or using a Jupyter Notebook).
The code is also availabla on
Copy and run the following Python code (directly in the terminal or using a Jupyter Notebook).
Note it requires `PIL` library (get it with `pip install Pillow`).

The code is also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/sd-example/sd-inference.py).

```python
Expand Down Expand Up @@ -434,9 +338,6 @@ curl --location 'http://localhost:8000/delete-cluster' \

This is the json file you have just used (also available on
[GitHub](https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/delete-cluster.json)):
```json
{
"cluster_id": "example"
}
```
{% codefromgithub url="https://github.com/golemfactory/golem-workers/raw/main/examples/hello-example/delete-cluster.json" language="json" %}

{% /codefromgithub %}
Loading
Loading