Skip to content

Commit

Permalink
Move to pydantic v2 (GSI-446) (#20)
Browse files Browse the repository at this point in the history
* Use custom pytest scope

* Update lock files

* Change service instance id value to string

* Replace deprecated .dict with .model_dump

* Apply automated changes from mig tool

* Tweak how to see config value for comparison

Accessing Config value in dict format not compatible with .json() dict

* Remove unused default test config

* Update template files

* Use commons 1.0.0 and fix minor type issue in test

* Pull in template changes

---------

Co-authored-by: TheByronHimes <[email protected]>
  • Loading branch information
TheByronHimes and TheByronHimes authored Oct 27, 2023
1 parent 639747d commit 959e328
Show file tree
Hide file tree
Showing 26 changed files with 1,641 additions and 1,256 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 @@ -13,5 +13,5 @@ searchable_classes:
resource_change_event_topic: searchable_resources
resource_deletion_event_type: searchable_resource_deleted
resource_upsertion_event_type: searchable_resource_upserted
service_instance_id: 001
service_instance_id: "001"
kafka_servers: ["kafka:9092"]
48 changes: 16 additions & 32 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +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": "metadata-artifact-search-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"
}
},
"sqltools.connections": [
{
"name": "Container database",
"driver": "PostgreSQL",
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"database": "postgres",
"username": "postgres",
"password": "postgres"
}
],
"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 @@ -57,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 @@ -70,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 @@ -80,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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ repos:
- id: debug-statements
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.1
hooks:
- id: mypy
args: [--no-warn-unused-ignores]
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
Loading

0 comments on commit 959e328

Please sign in to comment.