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

Clean up the sdk a bit #51

Merged
merged 8 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name: CI

on: [push]

defaults:
run:
working-directory: sdk

jobs:
lint_and_test:
lint_and_test_python_sdk:
defaults:
run:
working-directory: sdk

runs-on: ubuntu-latest
strategy:
max-parallel: 4
Expand Down Expand Up @@ -53,3 +54,25 @@ jobs:
env:
CI: true
run: make tests

lint_and_test_go_pkg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Run Tests
run: |
make test-internal
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ k3d-down:
k3d cluster delete --config hack/k3d.yaml

beam:
docker build . --target build --secret id=github-token,src=<(echo -n ${GITHUB_TOKEN}) -f ./docker/Dockerfile.beam -t localhost:5000/beam:$(imageVersion)
docker build . --target build -f ./docker/Dockerfile.beam -t localhost:5000/beam:$(imageVersion)
docker push localhost:5000/beam:$(imageVersion)

beam-worker:
docker build . --target final --build-arg BASE_STAGE=dev --secret id=github-token,src=<(echo -n ${GITHUB_TOKEN}) -f ./docker/Dockerfile.worker -t localhost:5000/beam-worker:$(imageVersion)
docker build . --target final --build-arg BASE_STAGE=dev -f ./docker/Dockerfile.worker -t localhost:5000/beam-worker:$(imageVersion)
docker push localhost:5000/beam-worker:latest
bin/delete_workers.sh

beam-runner:
for target in py312 py311 py310 py39 py38; do \
docker build . --target $$target --platform=linux/amd64 --secret id=github-token,src=<(echo -n ${GITHUB_TOKEN}) -f ./docker/Dockerfile.runner -t localhost:5000/beam-runner:$$target-latest; \
docker build . --target $$target --platform=linux/amd64 -f ./docker/Dockerfile.runner -t localhost:5000/beam-runner:$$target-latest; \
docker push localhost:5000/beam-runner:$$target-latest; \
done

Expand All @@ -39,3 +39,6 @@ stop:

protocol:
cd proto && ./gen.sh

test-internal:
go test -v ./internal/... -bench=./internal/..
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
<a href="https://twitter.com/beam_cloud">
<img alt="Twitter" src="https://img.shields.io/twitter/follow/beam_cloud.svg?style=social&logo=twitter">
</a>
<a href="https://github.com/beam-cloud/beam/actions">
<img alt="Tests Passing" src="https://github.com/beam-cloud/beam/workflows/tests/badge.svg?branch=master">
</a>
<img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-ff69b4"/>
</p>


<h3 align="center">
The distributed container runtime
The distributed Python container runtime
</h3>

---
Expand Down
5 changes: 1 addition & 4 deletions docker/Dockerfile.beam
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ WORKDIR /workspace
RUN apt install -y libfuse3-dev && \
go install github.com/cosmtrek/air@latest

ENV GOPRIVATE=github.com/beam-cloud/*
COPY go.mod go.sum ./
RUN --mount=type=secret,id=github-token,required=true \
echo "machine github.com login beam-cloud password $(cat /run/secrets/github-token)" > /root/.netrc && \
go mod download && go mod verify
RUN go mod download && go mod verify

COPY . .

Expand Down
6 changes: 2 additions & 4 deletions docker/Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ ARG BASE_STAGE=dev

FROM golang:1.21-bullseye AS golang

RUN --mount=type=secret,id=github-token,required=true <<EOT
RUN <<EOT
set -eux
apt-get update
apt-get install -y --no-install-recommends curl git
echo "machine github.com login beam-cloud password $(cat /run/secrets/github-token)" > /root/.netrc
EOT


Expand Down Expand Up @@ -58,8 +57,7 @@ COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN GOPRIVATE=github.com/beam-cloud/* \
go build -o /usr/local/bin/worker ./cmd/worker/main.go
RUN go build -o /usr/local/bin/worker ./cmd/worker/main.go


# NVIDIA CUDA - Final Stage
Expand Down
2 changes: 1 addition & 1 deletion internal/abstractions/function/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (g *functionGroup) FunctionInvoke(ctx echo.Context) error {
args, err := json.Marshal(payload)
if err != nil {
return ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
"error": "error marshaling function payload",
"error": "error marshalling function payload",
})
}

Expand Down
1 change: 1 addition & 0 deletions internal/abstractions/taskqueue/taskqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ func (tq *RedisTaskQueue) handleContainerEvents() {
Change: -1,
}
}

case <-tq.ctx.Done():
return
}
Expand Down
28 changes: 0 additions & 28 deletions sdk/src/beam/clients/bucket.py

This file was deleted.

55 changes: 9 additions & 46 deletions sdk/src/beam/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class PythonVersion(str, Enum):
```
"""

Python37 = "python3.7"
Python38 = "python3.8"
Python39 = "python3.9"
Python310 = "python3.10"
Expand All @@ -49,15 +48,18 @@ class GpuType(str, Enum):
"""
An enum that defines types of GPUs.

<Info>
GPUs L4 and A100 are coming soon. Email us at [email protected] to learn more.
</Info>

Example:
```python
from beam import Runtime, GpuType
from beam import GpuType, function

@function(gpu=GpuType.T4)
def some_func()
print("I will run on a T4 gpu!")

r = Runtime(gpu=GpuType.T4)
# This is equivalent to the above ^
@function(gpu="T4")
def some_other_func()
print("I will run on a T4 gpu!")
```
"""

Expand All @@ -68,42 +70,3 @@ class GpuType(str, Enum):
A10G = "A10G"
A100_40 = "A100-40"
A100_80 = "A100-80"


class VolumeType(str, Enum):
"""
An enum that defines types of volumes.

Example:
```python
from beam import Volume, VolumeType

pv = Volume(
name='my-persistent-data',
path='./my-persistent-volume'
volume_type=VolumeType.Persistent,
)
```
"""

Persistent = "persistent"
Shared = "shared"


class AutoscalingType(str, Enum):
"""
An enum that defines types of autoscaling.

<Warning>
This is deprecated. Please see the [RequestLatencyAutoscaler](#requestlatencyautoscaler).
</Warning>

Example:
```python
from beam import Autoscaling, AutoscalingType

a = Autoscaling(autoscaling_type=AutoscalingType.MaxRequestLatency)
```
"""

MaxRequestLatency = "max_request_latency"