Skip to content

Update examples #2234

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

Merged
merged 3 commits into from
Jun 8, 2021
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
16 changes: 10 additions & 6 deletions docs/workloads/async/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
# main.py

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class Data(BaseModel):
msg: str

@app.post("/")
def hello_world():
return {"msg": "hello world"}
def handle_async(data: Data):
return data
```

### Create a `Dockerfile`
Expand All @@ -28,19 +32,19 @@ CMD uvicorn --host 0.0.0.0 --port 8080 main:app
### Build an image

```bash
docker build . --tag hello-world
docker build . -t hello-world
```

### Run a container locally

```bash
docker run --port 8080:8080 hello-world
docker run -p 8080:8080 hello-world
```

### Make a request

```bash
curl --request POST --header "Content-Type: application/json" localhost:8080
curl -X POST -H "Content-Type: application/json" -d '{"msg": "hello world"}' localhost:8080
```

### Login to ECR
Expand Down Expand Up @@ -101,7 +105,7 @@ cortex get hello-world
### Make a request

```bash
curl --request POST --header "Content-Type: application/json" http://***.amazonaws.com/hello-world
curl -X POST -H "Content-Type: application/json" -d '{"msg": "hello world"}' http://***.amazonaws.com/hello-world
```

### Get the response
Expand Down
9 changes: 5 additions & 4 deletions docs/workloads/batch/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def on_job_complete():
FROM python:3.8-slim

RUN pip install --no-cache-dir fastapi uvicorn

COPY main.py /

CMD uvicorn --host 0.0.0.0 --port 8080 main:app
Expand All @@ -33,19 +34,19 @@ CMD uvicorn --host 0.0.0.0 --port 8080 main:app
### Build an image

```bash
docker build . --tag hello-world
docker build . -t hello-world
```

### Run a container locally

```bash
docker run --port 8080:8080 hello-world
docker run -p 8080:8080 hello-world
```

### Make a request

```bash
curl --request POST --header "Content-Type: application/json" --data '[1,2,3,4]' localhost:8080
curl -X POST -H "Content-Type: application/json" -d '[1,2,3,4]' localhost:8080
```

### Login to ECR
Expand Down Expand Up @@ -101,7 +102,7 @@ cortex get hello-world
### Make a request

```bash
curl --request POST --header "Content-Type: application/json" --data '{"workers": 2, "item_list": {"items": [1,2,3,4], "batch_size": 2}}' http://***.amazonaws.com/hello-world
curl -X POST -H "Content-Type: application/json" -d '{"workers": 2, "item_list": {"items": [1,2,3,4], "batch_size": 2}}' http://***.amazonaws.com/hello-world
```

### View the logs
Expand Down
19 changes: 12 additions & 7 deletions docs/workloads/realtime/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
# main.py

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

@app.get("/")
def hello_world():
return {"msg": "hello world"}
class Data(BaseModel):
msg: str

@app.post("/")
def handle_post(data: Data):
return data
```

### Create a `Dockerfile`
Expand All @@ -20,6 +24,7 @@ def hello_world():
FROM python:3.8-slim

RUN pip install --no-cache-dir fastapi uvicorn

COPY main.py /

CMD uvicorn --host 0.0.0.0 --port 8080 main:app
Expand All @@ -28,19 +33,19 @@ CMD uvicorn --host 0.0.0.0 --port 8080 main:app
### Build an image

```bash
docker build . --tag hello-world
docker build . -t hello-world
```

### Run a container locally

```bash
docker run --port 8080:8080 hello-world
docker run -p 8080:8080 hello-world
```

### Make a request

```bash
curl --request POST localhost:8080
curl -X POST -H "Content-Type: application/json" -d '{"msg": "hello world"}' localhost:8080
```

### Login to ECR
Expand Down Expand Up @@ -101,5 +106,5 @@ cortex get hello-world
### Make a request

```bash
curl --request POST http://***.amazonaws.com/hello-world
curl -X POST -H "Content-Type: application/json" -d '{"msg": "hello world"}' http://***.amazonaws.com/hello-world
```
4 changes: 2 additions & 2 deletions docs/workloads/task/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CMD exec python main.py
### Build an image

```bash
docker build . --tag hello-world
docker build . -t hello-world
```

### Run a container locally
Expand Down Expand Up @@ -83,7 +83,7 @@ cortex get hello-world
### Make a request

```bash
curl --request POST --header "Content-Type: application/json" --data '{}' http://***.amazonaws.com/hello-world
curl -X POST -H "Content-Type: application/json" -d '{}' http://***.amazonaws.com/hello-world
```

### View the logs
Expand Down