Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.56 KB

File metadata and controls

42 lines (29 loc) · 1.56 KB

Docker test execution

docker pull python:3.11-slim

docker run -it  -w /var/plus -v $(pwd):/var/plus python:3.11-slim bash -c "pip install -r requirements.txt && pip install pytest pytest-mock && pytest -v"

Local execution

Setup: pip install -r requirements.txt pip install pytest pytest-mock

Execution: pytest

Docker Web API Execution

To simply start an instance of the Web API

docker pull python:3.11-slim

docker run -it -p 8000:8000 -w /var/plus -v $(pwd):/var/plus python:3.11-slim bash -c "pip install -r requirements.txt && fastapi dev main.py --host 0.0.0.0"

Code changes from original application code

  • Fix requirements for fastapi : fastapi[standard]
  • Refactor POST - /predict to not wait for a response and return the job_id :
    • Remove return typing
    • Change code to not make the job function call back predict function (infinite loop)
    • Move the "await asyncio.sleep(random.random() * 3)" to the predict function.

Work done

Tests

  • Basic tests for each endpoint - 200
  • Check for basic invalid parameters (Json payload non good, bad or missing path ID)
  • Check prediction result status based on the execution state
  • Use mocking to prevent call to the prediction system, to prevent dependencies on unstable system and to remove waiting for the execution to complete.
  • Also use mocking to prevent the execution of prediction system to control if a job is completed or pending.

GitHub

  • Setup a Git Hub action to execute test when a PR is created.
  • Also add basic reporting of the test in the Git Hub Action job summary