diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..9801e58 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +exclude = .git,__pycache__,venv,.venv +max-line-length = 120 \ No newline at end of file diff --git a/.github/actions/lint-python-app/action.yml b/.github/actions/lint-python-app/action.yml index a12beb0..a246d92 100644 --- a/.github/actions/lint-python-app/action.yml +++ b/.github/actions/lint-python-app/action.yml @@ -20,7 +20,7 @@ runs: - name: Install app dependencies shell: bash working-directory: ${{ inputs.python-app-path }} - run: pip3 install -r requirements.txt -r requirements-all.txt + run: pip3 install flake8 - name: Lint Python code shell: bash diff --git a/.github/workflows/image-resize.yml b/.github/workflows/image-resize.yml index fd778e5..54fc511 100644 --- a/.github/workflows/image-resize.yml +++ b/.github/workflows/image-resize.yml @@ -12,24 +12,6 @@ on: branches: - main - prod - paths: - - .github/actions/build-and-push-docker-image-to-github/action.yml - - .github/actions/execute-command-on-kubernetes-cluster/action.yml - - .github/actions/lint-python-app/action.yml - - .github/actions/test-python-app/action.yml - - .github/workflows/image-resize.yml - - common-code/**/* - - services/image-resize/**/* - - pull_request: - paths: - - .github/actions/build-and-push-docker-image-to-github/action.yml - - .github/actions/execute-command-on-kubernetes-cluster/action.yml - - .github/actions/lint-python-app/action.yml - - .github/actions/test-python-app/action.yml - - .github/workflows/image-resize.yml - - common-code/**/* - - services/image-resize/**/* # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -44,7 +26,7 @@ jobs: - name: Lint Python app uses: ./.github/actions/lint-python-app with: - python-app-path: ./services/image-resize + python-app-path: . test: needs: review @@ -56,7 +38,7 @@ jobs: - name: Test Python app uses: ./.github/actions/test-python-app with: - python-app-path: ./services/image-resize + python-app-path: . token: ${{ secrets.GITHUB_TOKEN }} release: @@ -75,7 +57,7 @@ jobs: docker-registry-username: ${{ github.actor }} docker-registry-password: ${{ secrets.GITHUB_TOKEN }} docker-image-name: swiss-ai-center/image-resize - docker-image-context: ./services/image-resize + docker-image-context: . outputs: docker-image-tags: ${{ steps.build-and-push-docker-image-to-github.outputs.docker-image-tags }} @@ -90,11 +72,11 @@ jobs: - name: Prepare configuration files shell: bash - working-directory: services/image-resize/kubernetes + working-directory: ./kubernetes env: ENVIRONMENT: production LOG_LEVEL: info - ENGINE_URLS: "'[\"https://core-engine-swiss-ai-center.kube.isc.heia-fr.ch\"]'" + ENGINE_URLS: "'[\"https://backend-core-engine-swiss-ai-center.kube.isc.heia-fr.ch\"]'" SERVICE_URL: https://image-resize-swiss-ai-center.kube.isc.heia-fr.ch run: | # Set image-resize version @@ -114,7 +96,7 @@ jobs: with: kube-config: ${{ secrets.KUBE_CONFIG_DEV }} kube-namespace: swiss-ai-center-dev - kubectl-context: ./services/image-resize/kubernetes + kubectl-context: ./kubernetes kubectl-args: | apply \ -f image-resize.config-map.yml \ @@ -133,11 +115,11 @@ jobs: - name: Prepare configuration files shell: bash - working-directory: services/image-resize/kubernetes + working-directory: ./kubernetes env: ENVIRONMENT: production LOG_LEVEL: info - ENGINE_URLS: "'[\"https://core-engine-swiss-ai-center.kube.isc.heia-fr.ch\"]'" + ENGINE_URLS: "'[\"https://backend-core-engine-swiss-ai-center.kube.isc.heia-fr.ch\"]'" SERVICE_URL: https://image-resize-swiss-ai-center.kube.isc.heia-fr.ch run: | # Set image-resize version @@ -157,7 +139,7 @@ jobs: with: kube-config: ${{ secrets.KUBE_CONFIG_PROD }} kube-namespace: swiss-ai-center-prod - kubectl-context: ./services/image-resize/kubernetes + kubectl-context: ./kubernetes kubectl-args: | apply \ -f image-resize.config-map.yml \ diff --git a/.gitignore b/.gitignore index eaa992f..7d3aa59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,3 @@ -## Material for MkDocs - -# Cache -.cache - -# Output directory -/public - ## Python # Environments diff --git a/LICENSE b/COPYING similarity index 100% rename from LICENSE rename to COPYING diff --git a/README.md b/README.md index ada8ada..4aa38d0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # image-resize -_Check the [related documentation](https://swiss-ai-center.github.io/swiss-ai-center/reference/image-resize) for more information._ +_Check the [related documentation](https://docs.swiss-ai-center.ch/reference/services/image-resize) for more information._ diff --git a/requirements.txt b/requirements.txt index 084017f..c8dc006 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ aiofile==3.8.7 -common-code[test] @ git+https://github.com/swiss-ai-center/core-engine.git@main#subdirectory=common-code +common-code[test] @ git+https://github.com/swiss-ai-center/common-code.git@main flake8==5.0.4 numpy==1.21.4 opencv-python==4.7.0.68 diff --git a/src/main.py b/src/main.py index 6bb6bc1..4076e8b 100644 --- a/src/main.py +++ b/src/main.py @@ -34,6 +34,7 @@ class MyService(Service): # Any additional fields must be excluded for Pydantic to work model: object = Field(exclude=True) + logger: object = Field(exclude=True) def __init__(self): super().__init__( @@ -58,6 +59,7 @@ def __init__(self): ], has_ai=False ) + self.logger = get_logger(settings) def process(self, data): raw = data["image"].data