Skip to content

Commit

Permalink
Merge branch 'livepeer:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JJassonn69 authored Nov 7, 2024
2 parents c82d13d + f3e99e1 commit 7cac675
Show file tree
Hide file tree
Showing 93 changed files with 12,469 additions and 1,282 deletions.
78 changes: 0 additions & 78 deletions .github/ISSUE_TEMPLATE/bug_report_ai_video.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/ISSUE_TEMPLATE/feature_request_ai.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/labeler.yml

This file was deleted.

9 changes: 5 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
apt update
apt install -yqq build-essential make software-properties-common
add-apt-repository -y ppa:git-core/candidate
apt update && apt install -yqq git zip unzip zlib1g-dev zlib1g yasm
apt update && apt install -yqq git zip unzip zlib1g-dev zlib1g libzlcore-dev libz-mingw-w64-dev yasm
- name: Check out code
uses: actions/[email protected]
Expand All @@ -69,7 +69,7 @@ jobs:
id: go
uses: actions/setup-go@v5
with:
go-version: 1.20.4
go-version: 1.23.2
cache: true
cache-dependency-path: go.sum

Expand Down Expand Up @@ -100,7 +100,8 @@ jobs:
&& apt update \
&& apt -yqq install \
nasm clang-14 clang-tools-14 lld-14 build-essential pkg-config autoconf git python3 \
gcc-mingw-w64 libgcc-9-dev-arm64-cross mingw-w64-tools gcc-mingw-w64-x86-64
gcc-mingw-w64 libgcc-9-dev-arm64-cross mingw-w64-tools gcc-mingw-w64-x86-64 mingw-w64-x86-64-dev \
golang-goprotobuf-dev protobuf-compiler-grpc
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-14 30 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 30 \
Expand Down Expand Up @@ -170,7 +171,7 @@ jobs:
id: go
uses: actions/setup-go@v5
with:
go-version: 1.20.4
go-version: 1.23.2
cache: true
cache-dependency-path: go.sum

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ jobs:
build-args: |
BUILD_TAGS=${{ steps.build-tag.outputs.build-tags }}
context: .
platforms: linux/amd64, linux/arm64
# platforms: linux/amd64, linux/arm64 # NOTE: Arm64 not yet supported.
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
file: "docker/Dockerfile"
Expand Down Expand Up @@ -177,7 +178,8 @@ jobs:
build-args: |
BUILD_TAGS=${{ steps.build-tag.outputs.build-tags }}
context: .
platforms: linux/amd64, linux/arm64
# platforms: linux/amd64, linux/arm64 # NOTE: Arm64 not yet supported.
platforms: linux/amd64
push: true
tags: ${{ steps.meta-builder.outputs.tags }}
file: "docker/Dockerfile"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
id: go
uses: actions/setup-go@v5
with:
go-version: 1.20.4
go-version: 1.23.2
cache: true
cache-dependency-path: go.sum

Expand Down Expand Up @@ -94,9 +94,9 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.52.2
version: v1.61.0
skip-pkg-cache: true
args: '--disable-all --enable=gofmt --enable=vet --enable=golint --deadline=4m pm verification'
args: '--out-format=colored-line-number --disable-all --enable=gofmt --enable=govet --enable=revive --timeout=4m pm verification'

- name: Run Revive Action by building from repository
uses: docker://morphy/revive-action:v2
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
*.dll
*.so
*.dylib

# IDE files
*.vscode
*.code-workspace

# Test binary, build with `go test -c`
*.test
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ ifeq ($(BUILDOS),linux)

ifeq ($(GOOS),windows)
cc = x86_64-w64-mingw32-gcc
cgo_ldflags += -L/usr/x86_64-w64-mingw32/lib -lz
endif
endif

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
---
[![Go Report Card](https://goreportcard.com/badge/github.com/livepeer/go-livepeer)](https://goreportcard.com/report/github.com/livepeer/go-livepeer)
[![Discord](https://img.shields.io/discord/423160867534929930.svg?style=flat-square)](https://discord.gg/7wRSUGX)
[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.md)
[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg?style=flat-square)](CONTRIBUTING.md)

The Livepeer project aims to deliver a live video-streaming network protocol
Expand Down
102 changes: 102 additions & 0 deletions ai/file_worker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package ai

import (
"context"
"encoding/json"
"errors"
"os"

"github.com/livepeer/ai-worker/worker"
)

type FileWorker struct {
files map[string]string
}

func NewFileWorker(files map[string]string) *FileWorker {
return &FileWorker{files: files}
}

func (w *FileWorker) TextToImage(ctx context.Context, req worker.GenTextToImageJSONRequestBody) (*worker.ImageResponse, error) {

Check warning on line 20 in ai/file_worker.go

View workflow job for this annotation

GitHub Actions / Run tests defined for the project

parameter 'ctx' seems to be unused, consider removing or renaming it as _

Check warning on line 20 in ai/file_worker.go

View workflow job for this annotation

GitHub Actions / Run tests defined for the project

parameter 'req' seems to be unused, consider removing or renaming it as _
fname, ok := w.files["text-to-image"]
if !ok {
return nil, errors.New("text-to-image response file not found")
}

data, err := os.ReadFile(fname)
if err != nil {
return nil, err
}

var resp worker.ImageResponse
if err := json.Unmarshal(data, &resp); err != nil {
return nil, err
}

return &resp, nil
}

func (w *FileWorker) ImageToImage(ctx context.Context, req worker.GenImageToImageMultipartRequestBody) (*worker.ImageResponse, error) {

Check warning on line 39 in ai/file_worker.go

View workflow job for this annotation

GitHub Actions / Run tests defined for the project

parameter 'ctx' seems to be unused, consider removing or renaming it as _

Check warning on line 39 in ai/file_worker.go

View workflow job for this annotation

GitHub Actions / Run tests defined for the project

parameter 'req' seems to be unused, consider removing or renaming it as _
fname, ok := w.files["image-to-image"]
if !ok {
return nil, errors.New("image-to-image response file not found")
}

data, err := os.ReadFile(fname)
if err != nil {
return nil, err
}

var resp worker.ImageResponse
if err := json.Unmarshal(data, &resp); err != nil {
return nil, err
}

return &resp, nil
}

func (w *FileWorker) ImageToVideo(ctx context.Context, req worker.GenImageToVideoMultipartRequestBody) (*worker.VideoResponse, error) {
fname, ok := w.files["image-to-video"]
if !ok {
return nil, errors.New("image-to-video response file not found")
}

data, err := os.ReadFile(fname)
if err != nil {
return nil, err
}

var resp worker.VideoResponse
if err := json.Unmarshal(data, &resp); err != nil {
return nil, err
}

return &resp, nil
}

func (w *FileWorker) Upscale(ctx context.Context, req worker.GenUpscaleMultipartRequestBody) (*worker.ImageResponse, error) {
fname, ok := w.files["upscale"]
if !ok {
return nil, errors.New("upscale response file not found")
}

data, err := os.ReadFile(fname)
if err != nil {
return nil, err
}

var resp worker.ImageResponse
if err := json.Unmarshal(data, &resp); err != nil {
return nil, err
}

return &resp, nil
}

func (w *FileWorker) Warm(ctx context.Context, containerName, modelID string) error {
return nil
}

func (w *FileWorker) Stop(ctx context.Context, containerName string) error {
return nil
}
29 changes: 20 additions & 9 deletions cmd/devtool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,42 @@

An on-chain workflow testing tool that supports the following:

- Automatically submitting the necessary setup transactions for each node type
- Generating a Bash script with default CLI flags to start each node type
- Automatically submitting the necessary setup transactions for each node type
- Generating a Bash script with default CLI flags to start each node type

## Prerequisites

## Step 1: Set up a private ETH network with Livepeer protocol deployed
- [Docker](https://docs.docker.com/get-docker/)
- [Go](https://golang.org/doc/install)
- [Go-livepeer](https://github.com/livepeer/go-livepeer) build from source (see [the docs](https://docs.livepeer.org/orchestrators/guides/install-go-livepeer#build-from-source)).

```
## Setting Up an On-Chain Development Environment

### Step 1: Set up a private ETH network with Livepeer protocol deployed

```bash
docker pull livepeer/geth-with-livepeer-protocol:confluence
docker run -p 8545:8545 -p 8546:8546 --name geth-with-livepeer-protocol livepeer/geth-with-livepeer-protocol:confluence
```


## Step 2: Set up a broadcaster
### Step 2: Set up a broadcaster

`go run cmd/devtool/devtool.go setup broadcaster`

This command will submit the setup transactions for a broadcaster and generate the Bash script
`run_broadcaster_<ETH_ACCOUNT>.sh` which can be used to start a broadcaster node.

## Step 3: Set up a orchestrator/transcoder
### Step 3: Set up a orchestrator/transcoder

`go run cmd/devtool/devtool.go setup transcoder`

This command will submit the setup transactions for an orchestrator/transcoder and generate the Bash scripts:

* `run_orchestrator_with_transcoder_<ETH_ACCOUNT>.sh` which can be used to start an orchestrator node that contains a transcoder (combined OT)
* `run_orchestrator_standalone_<ETH_ACCOUNT>.sh` and `run_transcoder_<ETH_ACCOUNT>.sh` which can be used to start separate orchestrator and transcoder nodes (split O/T)
- `run_orchestrator_with_transcoder_<ETH_ACCOUNT>.sh` which can be used to start an orchestrator node that contains a transcoder (combined OT)
- `run_orchestrator_standalone_<ETH_ACCOUNT>.sh` and `run_transcoder_<ETH_ACCOUNT>.sh` which can be used to start separate orchestrator and transcoder nodes (split O/T)

## Extra Resources

### Scripts

Some helpful scripts are provided in the `scripts` directory.
Loading

0 comments on commit 7cac675

Please sign in to comment.