Skip to content

Commit

Permalink
Update hexkit, use Pydantic V2 and refactor DI (GSI-443) (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored Oct 27, 2023
1 parent aec6df4 commit a9a8cbd
Show file tree
Hide file tree
Showing 37 changed files with 1,021 additions and 659 deletions.
1 change: 1 addition & 0 deletions .deprecated_files
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ setup.cfg

.pylintrc
.flake8
.editorconfig
2 changes: 1 addition & 1 deletion .devcontainer/.dev_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cors_allowed_headers: []
db_connection_str: "mongodb://mongodb:27017"
db_name: "dev-db"

service_instance_id: 001
service_instance_id: 'wps_1'
kafka_servers: ["kafka:9092"]

download_access_url: "http://127.0.0.1:8080/download-access"
Expand Down
36 changes: 16 additions & 20 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,35 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/python-3-postgres
// Update the VARIANT arg in docker-compose.yml to pick a Python version: 3, 3.8, 3.7, 3.6
{
"name": "work-package-service",
"name": "${localWorkspaceFolderBasename}",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"files.eol": "\n",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
},
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.formatting.provider": "black",
"python.analysis.typeCheckingMode": "basic",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.testing.pytestPath": "/usr/local/py-utils/bin/pytest",
"python.testing.pytestArgs": [
"--profile"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"editor.renderWhitespace": "all",
"editor.rulers": [
88
],
"editor.defaultFormatter": "ms-python.black-formatter",
"licenser.license": "Custom",
"licenser.customHeaderFile": "/workspace/.devcontainer/license_header.txt"
},
Expand All @@ -45,7 +39,6 @@
"mikestead.dotenv",
"ms-azuretools.vscode-docker",
"ms-python.python",
"ms-python.isort",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"njpwerner.autodocstring",
Expand All @@ -58,7 +51,9 @@
"yzhang.markdown-all-in-one",
"visualstudioexptteam.vscodeintellicode",
"ymotongpoo.licenser",
"editorconfig.editorconfig"
"charliermarsh.ruff",
"ms-python.black-formatter",
"ms-python.mypy-type-checker"
]
}
},
Expand All @@ -68,12 +63,13 @@
"postCreateCommand": "dev_install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"containerEnv": {
// for testcontainers to connect to the docker host:
"TC_HOST": "host.docker.internal",
"DOCKER_HOST": "unix:///var/run/docker.sock"
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"enableNonRootDocker": "true",
"moby": true,
"azureDnsAutoDetection": false
}
// details can be found here: https://github.com/devcontainers/features/tree/main/src/docker-outside-of-docker
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
}
}
14 changes: 0 additions & 14 deletions .editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion .mandatory_files
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# may differ from that of the template repository.

.devcontainer/dev_launcher
.devcontainer/devcontainer.json
.devcontainer/docker-compose.yml
.devcontainer/Dockerfile

Expand Down
21 changes: 13 additions & 8 deletions .readme_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $summary
$description

## Installation

We recommend using the provided Docker container.

A pre-build version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/$name):
Expand Down Expand Up @@ -42,6 +43,7 @@ $shortname --help
```

## Configuration

### Parameters

The service requires the following configuration parameters:
Expand Down Expand Up @@ -77,19 +79,20 @@ $openapi_doc
$design_description

## Development

For setting up the development environment, we rely on the
[devcontainer feature](https://code.visualstudio.com/docs/remote/containers) of vscode
[devcontainer feature](https://code.visualstudio.com/docs/remote/containers) of VS Code
in combination with Docker Compose.

To use it, you have to have Docker Compose as well as vscode with its "Remote - Containers"
To use it, you have to have Docker Compose as well as VS Code with its "Remote - Containers"
extension (`ms-vscode-remote.remote-containers`) installed.
Then open this repository in vscode and run the command
`Remote-Containers: Reopen in Container` from the vscode "Command Palette".
Then open this repository in VS Code and run the command
`Remote-Containers: Reopen in Container` from the VS Code "Command Palette".

This will give you a full-fledged, pre-configured development environment including:
- infrastructural dependencies of the service (databases, etc.)
- all relevant vscode extensions pre-installed
- pre-configured linting and auto-formating
- all relevant VS Code extensions pre-installed
- pre-configured linting and auto-formatting
- a pre-configured debugger
- automatic license-header insertion

Expand All @@ -101,9 +104,11 @@ if you update dependencies in the [`./pyproject.toml`](./pyproject.toml) or the
[`./requirements-dev.txt`](./requirements-dev.txt), please run it again.

## License

This repository is free to use and modify according to the
[Apache 2.0 License](./LICENSE).

## Readme Generation
This readme is autogenerate, please see [`readme_generation.md`](./readme_generation.md)
## README Generation

This README file is auto-generated, please see [`readme_generation.md`](./readme_generation.md)
for details.
2 changes: 1 addition & 1 deletion .static_files
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
.devcontainer/dev_install
.devcontainer/license_header.txt
.devcontainer/Dockerfile
.devcontainer/devcontainer.json

scripts/script_utils/__init__.py
scripts/script_utils/cli.py
Expand Down Expand Up @@ -39,7 +40,6 @@ scripts/README.md
example_data/README.md

.coveragerc
.editorconfig
.gitattributes
.gitignore
.mypy.ini
Expand Down
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

## creating building container
FROM python:3.10-slim AS builder
FROM python:3.10.9-slim-bullseye AS builder
# update and install dependencies
RUN apt update
RUN apt upgrade -y
Expand All @@ -26,14 +26,18 @@ WORKDIR /service
RUN python -m build

# creating running container
FROM python:3.10-slim
FROM python:3.10.9-slim-bullseye
# update and install dependencies
RUN apt update
RUN apt upgrade -y
# copy and install wheel
# copy and install requirements and wheel
WORKDIR /service
COPY --from=builder /service/requirements.txt /service
RUN pip install --no-deps -r requirements.txt
RUN rm requirements.txt
COPY --from=builder /service/dist/ /service
RUN pip install *.whl
RUN pip install --no-deps *.whl
RUN rm *.whl
# create new user and execute as that user
RUN useradd --create-home appuser
WORKDIR /home/appuser
Expand Down
Loading

0 comments on commit a9a8cbd

Please sign in to comment.