-
Notifications
You must be signed in to change notification settings - Fork 0
Initial Test of Github Actions #1
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
263b898
Update README
iperezx a045987
Add api
iperezx 2d06d0a
Turn off github models
iperezx 203ddd9
Remove github models param
iperezx 56f169f
Update api to include more endpoints and better example
iperezx 871d360
Return item not found for more details of the error
iperezx eca3ab3
Bump up version for fast api
iperezx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading
fastapifrom 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.