Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/cr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Code Review
permissions:
contents: read
pull-requests: write
models: true # if you choose use github models, set this to be true

on:
pull_request:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# test
Test Repository for various GitHub actions

# Github Actions tested on this repository
Here is a list of Github Actions tested on this repo:
- Code reviewer using [NRPs LLMs](https://nrp.ai/documentation/userdocs/ai/llm-managed/#api-access-to-llms-via-envoy-gateway): https://github.com/marketplace/actions/chatgpt-codereviewer
21 changes: 21 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.9

RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt install -y \
git \
htop \
make \
tzdata \
vim \
&& \
rm -rf /var/lib/apt/lists/*

# set time zone
ENV TZ America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /api
COPY app.py app.py
COPY requirements.txt requirements.txt

RUN pip install -r requirements.txt
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000", "app:app"]
70 changes: 70 additions & 0 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from fastapi import FastAPI, HTTPException, Query
from pydantic import BaseModel, Field
from typing import List, Optional
from uuid import uuid4

app = FastAPI(title="Example Items API", version="1.0.0")

class ItemBase(BaseModel):
name: str = Field(..., min_length=1, max_length=100)
description: Optional[str] = None
price: float = Field(..., gt=0)
in_stock: bool = True

class ItemCreate(ItemBase):
pass

class Item(ItemBase):
id: str

items_db: dict[str, Item] = {}

@app.get("/")
def root():
return {"message": "Welcome to the Items API"}

@app.get("/health")
def health_check():
return {"status": "ok"}

@app.post("/items", response_model=Item, status_code=201)
def create_item(item: ItemCreate):
item_id = str(uuid4())
new_item = Item(id=item_id, **item.dict())
items_db[item_id] = new_item
return new_item

@app.get("/items", response_model=List[Item])
def list_items(
min_price: Optional[float] = Query(None, gt=0),
in_stock: Optional[bool] = None,
):
results = list(items_db.values())
if min_price is not None:
results = [i for i in results if i.price >= min_price]
if in_stock is not None:
results = [i for i in results if i.in_stock == in_stock]
return results

@app.get("/items/{item_id}", response_model=Item)
def get_item(item_id: str):
if item_id not in items_db:
raise HTTPException(status_code=404, detail="Item not found")
return items_db[item_id]

@app.put("/items/{item_id}", response_model=Item)
def update_item(item_id: str, updated_item: ItemCreate):
if item_id not in items_db:
raise HTTPException(status_code=404, detail="Item not found")

item = Item(id=item_id, **updated_item.dict())
items_db[item_id] = item
return item

@app.delete("/items/{item_id}", status_code=204)
def delete_item(item_id: str):
if item_id not in items_db:
raise HTTPException(status_code=404, detail=f"Item not found: {item_id}")

del items_db[item_id]
return
4 changes: 4 additions & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fastapi==0.129.0
gunicorn==20.1.0
requests==2.27.1
uvicorn==0.16.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrading fastapi from 0.71.0 to 0.129.0 is a significant jump in versions. This carries a substantial risk of breaking changes. While newer versions often include bug fixes and performance improvements, it's critical to thoroughly test this upgrade. Consider a phased upgrade or carefully review the release notes for breaking changes between 0.71.0 and 0.129.0 (especially those impacting dependency injection, request handling, or middleware). It's also important to verify compatibility with the other listed dependencies (gunicorn, uvicorn, requests) after the upgrade.