{"id":26522397,"url":"https://github.com/defra/ai-model-test","last_synced_at":"2026-05-10T10:01:41.828Z","repository":{"id":283520270,"uuid":"952045453","full_name":"DEFRA/ai-model-test","owner":"DEFRA","description":"Git repository for service ai-model-test","archived":false,"fork":false,"pushed_at":"2025-03-20T16:39:37.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T17:34:56.980Z","etag":null,"topics":["backend","cdp","python","service"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DEFRA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-20T16:39:21.000Z","updated_at":"2025-03-20T16:39:41.000Z","dependencies_parsed_at":"2025-03-20T17:45:10.711Z","dependency_job_id":null,"html_url":"https://github.com/DEFRA/ai-model-test","commit_stats":null,"previous_names":["defra/ai-model-test"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fai-model-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fai-model-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fai-model-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fai-model-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DEFRA","download_url":"https://codeload.github.com/DEFRA/ai-model-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244805159,"owners_count":20513227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","cdp","python","service"],"created_at":"2025-03-21T13:26:53.164Z","updated_at":"2026-05-10T10:01:41.662Z","avatar_url":"https://github.com/DEFRA.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ai-model-test\n\nThis is work-in-progress. See [To Do List](./TODO.md)\n\n- [ai-model-test](#ai-model-test)\n  - [Requirements](#requirements)\n    - [Python](#python)\n    - [Docker](#docker)\n  - [Local development](#local-development)\n    - [Setup](#setup)\n    - [Development](#development)\n    - [Testing](#testing)\n    - [Production](#production)\n  - [API endpoints](#api-endpoints)\n  - [Custom Cloudwatch Metrics](#custom-cloudwatch-metrics)\n  - [Pipelines](#pipelines)\n    - [Dependabot](#dependabot)\n    - [SonarCloud](#sonarcloud)\n  - [Licence](#licence)\n    - [About the licence](#about-the-licence)\n\n## Requirements\n\n### Python\n\nPlease install python `\u003e= 3.12` and [configure your python virtual environment](https://fastapi.tiangolo.com/virtual-environments/#create-a-virtual-environment):\n\n```python\n# create the virtual environment\npython -m venv .venv\n\n# activate the the virtual environment in the command line\nsource .venv/bin/activate\n\n# update pip\npython -m pip install --upgrade pip\n\n# install the dependencies\npip install -r requirements-dev.txt\n\n# run app\nuvicorn app.main:app --host 0.0.0.0 --port 8085 --reload\n\n```\n\nThis opinionated template uses the [`Fast API`](https://fastapi.tiangolo.com/) Python API framework.\n\nThis and all other runtime python libraries must reside in `requirements.txt`\n\nOther non-runtime dependencies used for dev \u0026 test must reside in `requirements-dev.txt`\n\n### Docker\n\nThis repository uses Docker throughput its lifecycle i.e. both for local development and the environments. A benefit of this is that environment variables \u0026 secrets are managed consistently throughout the lifecycle\n\nSee the `Dockerfile` and `compose.yml` for details\n\n### Linting and Formatting\n\nThis project uses [Ruff](https://github.com/astral-sh/ruff) for linting and formatting Python code.\n\n#### Running Ruff\n\nTo run Ruff from the command line:\n\n```bash\n# Run linting with auto-fix\nruff check . --fix\n\n# Run formatting\nruff format .\n```\n\n#### Pre-commit Hooks\n\nThis project uses [pre-commit](https://pre-commit.com/) to run linting and formatting checks automatically before each commit.\n\nThe pre-commit configuration is defined in `.pre-commit-config.yaml`\n\nTo set up pre-commit hooks:\n\n```bash\n# Set up the git hooks\npre-commit install\n\n# Alternatively, use the provided setup script\npython scripts/setup_hooks.py\n```\n\nTo run the hooks manually on all files:\n\n```bash\npre-commit run --all-files\n```\n\n#### VS Code Configuration\n\nFor the best development experience, configure VS Code to use Ruff:\n\n1. Install the [Ruff extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) for VS Code\n2. Configure your VS Code settings (`.vscode/settings.json`):\n\n```json\n{\n    \"editor.formatOnSave\": true,\n    \"editor.codeActionsOnSave\": {\n        \"source.fixAll.ruff\": \"explicit\",\n        \"source.organizeImports.ruff\": \"explicit\"\n    },\n    \"ruff.lint.run\": \"onSave\",\n    \"[python]\": {\n        \"editor.defaultFormatter\": \"charliermarsh.ruff\",\n        \"editor.formatOnSave\": true,\n        \"editor.codeActionsOnSave\": {\n            \"source.fixAll.ruff\": \"explicit\",\n            \"source.organizeImports.ruff\": \"explicit\"\n        }\n    }\n}\n```\n\nThis configuration will:\n\n- Format your code with Ruff when you save a file\n- Fix linting issues automatically when possible\n- Organize imports according to isort rules\n\n#### Ruff Configuration\n\nRuff is configured in the `.ruff.toml` file\n\n## Local development\n\n### Setup\n\nLibraries: Ensure the python virtual environment is configured and libraries are installed using `requirements-dev.txt`, [as above](#python)\n\nEnvironment variables: `compose/aws.env`\n\nSecrets: `compose/secrets.env`. You need to create this, as it's excluded from version control.\n\n### Development\n\nThe app can be run locally using Docker compose.  This template contains a local environment with:\n\n- Localstack\n- MongoDB\n- This service\n\nTo run the application in development mode:\n\n```bash\ndocker compose watch\n```\n\nAlternatively you can start it using:\n```\n uvicorn app.main:app --log-config logging-dev.json --reload\n```\n\n### Testing\n\nEnsure the python virtual environment is configured and libraries are installed using `requirements-dev.txt`, [as above](#python)\n\nTesting follows the [FastApi documented approach](https://fastapi.tiangolo.com/tutorial/testing/); using pytest \u0026 starlette.\n\nTo test the application run:\n\n```bash\npytest\n```\n\n### Production\n\nTo mimic the application running in `production mode locally run:\n\n```bash\ndocker compose up --build -d\n```\n\nStop the application with\n\n```bash\ndocker compose down\n```\n\nAlternatively you can start it using:\n\n```bash\n$ uvicorn app.main:app --host=0.0.0.0 --log-config logging.json --no-access-log\n```\n\n\n## API endpoints\n\n| Endpoint             | Description                    |\n| :------------------- | :----------------------------- |\n| `GET: /docs`         | Automatic API Swagger docs     |\n| `GET: /example`      | Simple example                 |\n\n## Custom Cloudwatch Metrics\n\nUses the [aws embedded metrics library](https://github.com/awslabs/aws-embedded-metrics-python). An example can be found in `metrics.py`\n\nIn order to make this library work in the environments, the environment variable `AWS_EMF_ENVIRONMENT=local` is set in the app config. This tells the library to use the local cloudwatch agent that has been configured in CDP, and uses the environment variables set up in CDP `AWS_EMF_AGENT_ENDPOINT`, `AWS_EMF_LOG_GROUP_NAME`, `AWS_EMF_LOG_STREAM_NAME`, `AWS_EMF_NAMESPACE`, `AWS_EMF_SERVICE_NAME`\n\n## Pipelines\n\n### Dependabot\n\nWe have added an example dependabot configuration file to the repository. You can enable it by renaming\nthe [.github/example.dependabot.yml](.github/example.dependabot.yml) to `.github/dependabot.yml`\n\n### SonarCloud\n\nInstructions for setting up SonarCloud can be found in [sonar-project.properties](./sonar-project.properties)\n\n## Licence\n\nTHIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:\n\n\u003chttp://www.nationalarchives.gov.uk/doc/open-government-licence/version/3\u003e\n\nThe following attribution statement MUST be cited in your products and applications when using this information.\n\n\u003e Contains public sector information licensed under the Open Government license v3\n\n### About the licence\n\nThe Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable\ninformation providers in the public sector to license the use and re-use of their information under a common open\nlicence.\n\nIt is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fai-model-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefra%2Fai-model-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fai-model-test/lists"}