Skip to content

Commit

Permalink
Implemented suggestions from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
movchan74 committed Nov 2, 2023
1 parent f2fb4af commit 6303290
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "none"
"python.formatting.provider": "none",
"python.testing.pytestArgs": [
"aana"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sh install.sh
5. Run the SDK.

```bash
CUDA_VISIBLE_DEVICES=0 poetry run aana --port 8000 --host 0.0.0.0 -- target llama2
CUDA_VISIBLE_DEVICES=0 poetry run aana --port 8000 --host 0.0.0.0 --target llama2
```

The target parameter specifies the set of endpoints to deploy.
Expand Down
19 changes: 6 additions & 13 deletions aana/api/api_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,14 @@ async def route_func_body(body: str, files: Optional[List[UploadFile]] = None):
return AanaJSONResponse(content=output)

if file_upload_field:

async def route_func_files(
body: str = Form(...),
files: List[UploadFile] = File(
None, description=file_upload_field.description
),
):
return await route_func_body(body=body, files=files)

return route_func_files
files = File(None, description=file_upload_field.description)
else:
files = None

async def route_func(body: str = Form(...)):
return await route_func_body(body=body)
async def route_func(body: str = Form(...), files=files):
return await route_func_body(body=body, files=files)

return route_func
return route_func

def register(self, app: FastAPI, pipeline: Pipeline):
"""
Expand Down Expand Up @@ -344,6 +336,7 @@ def add_custom_schemas_to_openapi_schema(
File upload is that FastAPI doesn't support Pydantic models in multipart requests.
There is a discussion about it on FastAPI discussion forum.
See https://github.com/tiangolo/fastapi/discussions/8406
The topic starter suggests a workaround.
The workaround is to use Forms instead of Pydantic models in the endpoint definition and
then convert the Forms to Pydantic models in the endpoint itself
Expand Down
5 changes: 2 additions & 3 deletions aana/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import torch


def is_gpu_available() -> bool:
"""
Check if a GPU is available.
Returns:
bool: True if a GPU is available, False otherwise.
"""
import torch

# TODO: find the way to check if GPU is available without importing torch
return torch.cuda.is_available()
1 change: 1 addition & 0 deletions startup.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
# TODO: pass arguments to the docker to set target instead of environment variable
poetry run aana --port 8000 --host 0.0.0.0 --target $TARGET

0 comments on commit 6303290

Please sign in to comment.