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
7 changes: 5 additions & 2 deletions .github/workflows/build-container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ name: "Build applications images"

on:
push:
# paths:
# - "app/**"
branches:
- main
paths:
- "src/**"
- "dockerfiles/**"
workflow_dispatch:

concurrency:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ docker run -ti -p 5000:5000 -e HF_MODEL_ID=distilbert-base-uncased-distilled-squ

```bash
curl --request POST \
--url http://localhost:5000/predict \
--url http://localhost:5000 \
--header 'Content-Type: application/json' \
--data '{
"inputs": {
Expand Down
3 changes: 2 additions & 1 deletion src/huggingface_inference_toolkit/webservice_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def predict(request):
pred = inference_handler(deserialized_body)
# log request time
# TODO: repalce with middleware
logger.info(f"POST /predict | Duration: {(perf_counter()-start_time) *1000:.2f} ms")
logger.info(f"POST {request.url.path} | Duration: {(perf_counter()-start_time) *1000:.2f} ms")
# deserialized and resonds with json
return Response(Jsoner.serialize(pred))
except Exception as e:
Expand All @@ -86,6 +86,7 @@ async def predict(request):
routes=[
Route("/", health, methods=["GET"]),
Route("/health", health, methods=["GET"]),
Route("/", predict, methods=["POST"]),
Route("/predict", predict, methods=["POST"]),
],
on_startup=[some_startup_task],
Expand Down
8 changes: 4 additions & 4 deletions tests/integ/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def verify_task(container: DockerClient, task: str, port: int = 5000, framework:
or task == "zero-shot-image-classification"
):
prediction = requests.post(
f"{BASE_URL}/predict", data=task2input[task], headers={"content-type": "image/x-image"}
f"{BASE_URL}", data=task2input[task], headers={"content-type": "image/x-image"}
).json()
elif task == "automatic-speech-recognition" or task == "audio-classification":
prediction = requests.post(
f"{BASE_URL}/predict", data=task2input[task], headers={"content-type": "audio/x-audio"}
f"{BASE_URL}", data=task2input[task], headers={"content-type": "audio/x-audio"}
).json()
else:
prediction = requests.post(f"{BASE_URL}/predict", json=input).json()
prediction = requests.post(f"{BASE_URL}", json=input).json()
assert task2validation[task](result=prediction, snapshot=task2output[task]) is True


Expand Down Expand Up @@ -193,7 +193,7 @@ def test_cpu_container_custom_pipeline(repository_id) -> None:
BASE_URL = "http://localhost:5000"
wait_for_container_to_be_ready(BASE_URL)
payload = {"inputs": "this is a test"}
prediction = requests.post(f"{BASE_URL}/predict", json=payload).json()
prediction = requests.post(f"{BASE_URL}", json=payload).json()
assert prediction == payload
# time.sleep(5)
container.stop()
Expand Down