Skip to content

Commit 152e167

Browse files
committed
KIT-2531 Adjust project structure according to template
1 parent 87615d2 commit 152e167

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+876
-521
lines changed

.devcontainer/Dockerfile

+7-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
1-
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/python-3/.devcontainer/base.Dockerfile
1+
# https://github.com/devcontainers/images/tree/main/src/python
2+
FROM mcr.microsoft.com/devcontainers/python:3.8-bullseye
23

3-
# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
4-
ARG VARIANT="3.8"
5-
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}-bullseye
4+
# Uninstall pre-installed formatting and linting tools
5+
# They would conflict with our pinned versions
6+
RUN pipx uninstall flake8
7+
RUN pipx uninstall mypy
68

7-
# [Option] Install Node.js
8-
ARG INSTALL_NODE="true"
9-
ARG NODE_VERSION="lts/*"
10-
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
11-
12-
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
13-
# COPY requirements.txt /tmp/pip-tmp/
14-
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
15-
# && rm -rf /tmp/pip-tmp
16-
17-
# [Optional] Uncomment this section to install additional OS packages.
18-
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
19-
# && apt-get -y install --no-install-recommends <your-package-list-here>
209
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
2110
RUN curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list
2211
RUN apt update
2312
ENV ACCEPT_EULA=Y
2413
RUN apt-get update && apt-get install -y build-essential git libgdiplus libx11-dev python3-opencv tesseract-ocr tesseract-ocr-deu && \
2514
apt-get autoremove -y && \
26-
rm -rf /var/lib/apt/lists/*
27-
28-
# [Optional] Uncomment this line to install global node packages.
29-
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
15+
rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

+52-44
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/python-3
31
{
4-
"name": "Python 3",
2+
"name": "ai_data_preprocessing_queue",
53
"build": {
64
"dockerfile": "Dockerfile",
7-
"context": "..",
8-
"args": {
9-
// Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9
10-
"VARIANT": "3.8",
11-
// Options
12-
"INSTALL_NODE": "true",
13-
"NODE_VERSION": "lts/*"
14-
}
5+
"context": ".."
156
},
16-
17-
// Set *default* container specific settings.json values on container create.
18-
"settings": {
19-
"python.pythonPath": "/usr/local/bin/python",
20-
"python.languageServer": "Pylance",
21-
"python.linting.enabled": true,
22-
"python.linting.pylintEnabled": false,
23-
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
24-
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
25-
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
26-
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
27-
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
28-
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
29-
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
30-
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
31-
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
7+
"customizations": {
8+
"vscode": {
9+
"settings": {
10+
"python.pythonPath": "/usr/local/bin/python",
11+
"python.defaultInterpreterPath": "/usr/local/bin/python",
12+
"python.languageServer": "Pylance",
13+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
14+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
15+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
16+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
17+
"python.linting.flake8Path": "/home/vscode/.local/bin/flake8",
18+
"flake8.importStrategy": "fromEnvironment",
19+
"python.linting.mypyPath": "/home/vscode/.local/bin/mypy",
20+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
21+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
22+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
23+
},
24+
"extensions": [
25+
"ms-python.python",
26+
"ms-python.vscode-pylance",
27+
"ms-python.flake8",
28+
"matangover.mypy",
29+
"ms-python.isort",
30+
"usernamehw.errorlens",
31+
"sourcery.sourcery",
32+
"njqdev.vscode-python-typehint",
33+
"njpwerner.autodocstring",
34+
"redhat.vscode-yaml",
35+
"visualstudioexptteam.vscodeintellicode",
36+
"kaih2o.python-resource-monitor",
37+
"geeebe.duplicate",
38+
"oderwat.indent-rainbow",
39+
"shardulm94.trailing-spaces",
40+
"streetsidesoftware.code-spell-checker",
41+
"ryanluker.vscode-coverage-gutters",
42+
"spmeesseman.vscode-taskexplorer",
43+
"eamodio.gitlens",
44+
"tamasfe.even-better-toml",
45+
"AykutSarac.jsoncrack-vscode",
46+
"yzhang.markdown-all-in-one",
47+
"Gruntfuggly.todo-tree"
48+
]
49+
}
3250
},
33-
34-
// Add the IDs of extensions you want installed when the container is created.
35-
"extensions": [
36-
"ms-python.python",
37-
"ms-python.vscode-pylance",
38-
"forbeslindesay.forbeslindesay-taskrunner"
39-
],
40-
41-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
42-
// "forwardPorts": [],
43-
44-
// Use 'postCreateCommand' to run commands after the container is created.
45-
"postCreateCommand": "pip3 install -r ./requirements.txt",
46-
47-
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
48-
"remoteUser": "vscode"
49-
}
51+
"initializeCommand": "powershell.exe .\\.devcontainer\\initialize.ps1",
52+
"postCreateCommand": "pip3 install -r ${containerWorkspaceFolder}/requirements-dev.txt",
53+
"remoteUser": "vscode",
54+
"mounts": [
55+
"source=${localEnv:USERPROFILE}/_devcontainer/cache,target=/home/vscode/.cache,type=bind"
56+
]
57+
}

.devcontainer/initialize.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
md -Force "$($env:USERPROFILE)\_devcontainer\cache"

.flake8

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Used by cli and vscode
2+
[flake8]
3+
max-line-length=120
4+
max-complexity = 10
5+
exclude =
6+
venv,
7+
build,
8+
dist
9+
per-file-ignores =
10+
__init__.py: F401
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "flake8-error",
5+
"severity": "error",
6+
"pattern": [
7+
{
8+
"regexp": "^([^:]+):(\\d+):(\\d+):\\s+(E\\d+\\s+.+)$",
9+
"file": 1,
10+
"line": 2,
11+
"column": 3,
12+
"message": 4
13+
}
14+
]
15+
}
16+
]
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "flake8-warning",
5+
"severity": "warning",
6+
"pattern": [
7+
{
8+
"regexp": "^([^:]+):(\\d+):(\\d+):\\s+([CFNW]\\d+\\s+.+)$",
9+
"file": 1,
10+
"line": 2,
11+
"column": 3,
12+
"message": 4
13+
}
14+
]
15+
}
16+
]
17+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "mypy-error",
5+
"severity": "error",
6+
"pattern": [
7+
{
8+
"regexp": "^([^:]+):([^:]+): error: ([^:]+)$",
9+
"file": 1,
10+
"line": 2,
11+
"message": 3
12+
}
13+
]
14+
}
15+
]
16+
}

.github/workflows/ci.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: ci
2+
run-name: CI ${{ github.ref }}
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
paths-ignore:
8+
- README.md
9+
- LICENSE.txt
10+
- .gitignore
11+
- .vscode/**
12+
- .devcontainer/**
13+
14+
jobs:
15+
build_python:
16+
name: Python | build
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 5
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.8"
24+
- name: Add linting matchers
25+
run: |
26+
echo "::add-matcher::.github/flake8-error-problem-matcher.json"
27+
echo "::add-matcher::.github/flake8-warning-problem-matcher.json"
28+
echo "::add-matcher::.github/mypy-error-problem-matcher.json"
29+
- name: Lint
30+
uses: py-actions/flake8@v2
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -r requirements-dev.txt
35+
- name: Lint typing
36+
# Must run with installed dependencies
37+
run: |
38+
mypy --config-file .mypy.ini --show-column-numbers .
39+
- name: Run tests
40+
run: python -m pytest --cov=ai_data_preprocessing_queue --cov-report=xml tests
41+
- name: Prepare coverage file
42+
run: coverage-lcov
43+
- name: Coveralls upload
44+
uses: coverallsapp/github-action@master
45+
with:
46+
github-token: ${{ secrets.GITHUB_TOKEN }}
47+
path-to-lcov: lcov.info

.github/workflows/publish.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: publish
2+
run-name: Build and/or Publish ${{ github.ref }}
3+
on:
4+
push:
5+
6+
jobs:
7+
build-n-publish:
8+
name: Build and/or publish Python 🐍 distributions 📦 to PyPI
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-python@v4
13+
with:
14+
python-version: "3.8"
15+
- run: >-
16+
python -m
17+
pip install
18+
build
19+
--user
20+
- run: >-
21+
python -m
22+
build
23+
--sdist
24+
--wheel
25+
--outdir dist/
26+
.
27+
- if: startsWith(github.ref, 'refs/tags')
28+
uses: pypa/gh-action-pypi-publish@release/v1
29+
with:
30+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)