Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • arkindex/workers/thumbnails
1 result
Show changes
Commits on Source (2)
...@@ -6,7 +6,7 @@ workers: ...@@ -6,7 +6,7 @@ workers:
name: Thumbnails Generator name: Thumbnails Generator
type: Utils type: Utils
docker: docker:
build: Dockerfile command: worker-thumbnails-generator
configuration: configuration:
width: 900 width: 900
height: 400 height: 400
......
...@@ -14,7 +14,7 @@ variables: ...@@ -14,7 +14,7 @@ variables:
DEBIAN_FRONTEND: non-interactive DEBIAN_FRONTEND: non-interactive
test: test:
image: python:slim image: python:3.12-slim
stage: test stage: test
cache: cache:
...@@ -41,7 +41,7 @@ test: ...@@ -41,7 +41,7 @@ test:
- tox -- --junitxml=test-report.xml --durations=50 - tox -- --junitxml=test-report.xml --durations=50
lint: lint:
image: python:slim image: python:3.12-slim
cache: cache:
paths: paths:
...@@ -105,7 +105,7 @@ bump-python-deps: ...@@ -105,7 +105,7 @@ bump-python-deps:
- schedules - schedules
script: script:
- devops python-deps requirements.txt - devops python-deps pyproject.toml
publish-worker: publish-worker:
stage: release stage: release
......
repos: repos:
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version. # Ruff version.
rev: v0.3.1 rev: v0.8.2
hooks: hooks:
# Run the linter. # Run the linter.
- id: ruff - id: ruff
...@@ -9,7 +9,7 @@ repos: ...@@ -9,7 +9,7 @@ repos:
# Run the formatter. # Run the formatter.
- id: ruff-format - id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 rev: v5.0.0
hooks: hooks:
- id: check-ast - id: check-ast
- id: check-docstring-first - id: check-docstring-first
...@@ -25,12 +25,21 @@ repos: ...@@ -25,12 +25,21 @@ repos:
args: ['--django'] args: ['--django']
- id: check-json - id: check-json
- id: check-toml - id: check-toml
- id: requirements-txt-fixer
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
rev: v2.2.6 rev: v2.3.0
hooks: hooks:
- id: codespell - id: codespell
args: ['--write-changes'] args: ['--write-changes']
- repo: meta - repo: meta
hooks: hooks:
- id: check-useless-excludes - id: check-useless-excludes
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
- repo: https://gitlab.teklia.com/tools/pre-commit-hooks
rev: 0.1.0
hooks:
- id: long-test-files
args: ['1000']
files: '^tests\/(.*\/)?test_[^\/]*\.py$'
FROM python:3.11-slim FROM python:3.12-slim
WORKDIR /src WORKDIR /src
# Install curl
ENV DEBIAN_FRONTEND=non-interactive
RUN apt-get update -q -y && apt-get install -q -y --no-install-recommends curl
# Install worker as a package # Install worker as a package
COPY worker_thumbnails_generator worker_thumbnails_generator COPY worker_thumbnails_generator worker_thumbnails_generator
COPY requirements.txt setup.py pyproject.toml ./ COPY pyproject.toml ./
RUN pip install . --no-cache-dir RUN pip install . --no-cache-dir
# Add archi local CA
RUN curl https://assets.teklia.com/teklia_dev_ca.pem > /usr/local/share/ca-certificates/arkindex-dev.crt && update-ca-certificates
ENV REQUESTS_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
CMD ["worker-thumbnails-generator"]
include requirements.txt
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
# Will automatically login to a registry if CI_REGISTRY, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD are set. # Will automatically login to a registry if CI_REGISTRY, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD are set.
# Will only push an image if $CI_REGISTRY is set. # Will only push an image if $CI_REGISTRY is set.
if [ -z "$VERSION" -o -z "$CI_PROJECT_DIR" -o -z "$CI_REGISTRY_IMAGE" ]; then if [ -z "$VERSION" ] || [ -z "$CI_PROJECT_DIR" ] || [ -z "$CI_REGISTRY_IMAGE" ]; then
echo Missing environment variables echo Missing environment variables
exit 1 exit 1
fi fi
IMAGE_TAG="$CI_REGISTRY_IMAGE:$VERSION" IMAGE_TAG="$CI_REGISTRY_IMAGE:$VERSION"
cd $CI_PROJECT_DIR cd "$CI_PROJECT_DIR"
docker build -f Dockerfile . -t "$IMAGE_TAG" docker build -f Dockerfile . -t "$IMAGE_TAG"
if [ -n "$CI_REGISTRY" -a -n "$CI_REGISTRY_USER" -a -n "$CI_REGISTRY_PASSWORD" ]; then if [ -n "$CI_REGISTRY" ] && [ -n "$CI_REGISTRY_USER" ] && [ -n "$CI_REGISTRY_PASSWORD" ]; then
echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
docker push $IMAGE_TAG docker push "$IMAGE_TAG"
else else
echo "Missing environment variables to log in to the container registry…" echo "Missing environment variables to log in to the container registry…"
fi fi
...@@ -7,7 +7,9 @@ name = "worker_thumbnails_generator" ...@@ -7,7 +7,9 @@ name = "worker_thumbnails_generator"
license = { file = "LICENSE" } license = { file = "LICENSE" }
version = "0.1.0" version = "0.1.0"
description = "Worker to generate thumbnails for Arkindex elements" description = "Worker to generate thumbnails for Arkindex elements"
dynamic = ["dependencies"] dependencies = [
"arkindex-base-worker==0.4.0",
]
authors = [ authors = [
{ name = "Teklia", email = "contact@teklia.com" }, { name = "Teklia", email = "contact@teklia.com" },
] ]
...@@ -22,16 +24,18 @@ classifiers = [ ...@@ -22,16 +24,18 @@ classifiers = [
"Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
] ]
[project.scripts] [project.scripts]
worker-thumbnails-generator = "worker_thumbnails_generator.worker:main" "worker-thumbnails-generator" = "worker_thumbnails_generator.worker:main"
[tool.setuptools.dynamic] [tool.setuptools.packages]
dependencies = { file = ["requirements.txt"] } find = {}
[tool.ruff] [tool.ruff]
exclude = [".git", "__pycache__"] exclude = [".git", "__pycache__"]
target-version = "py312"
[tool.ruff.lint] [tool.ruff.lint]
ignore = ["E501"] ignore = ["E501"]
......
#!/usr/bin/env python
from setuptools import find_packages, setup
setup(packages=find_packages())
...@@ -45,7 +45,7 @@ def _setup_environment(responses, monkeypatch) -> None: ...@@ -45,7 +45,7 @@ def _setup_environment(responses, monkeypatch) -> None:
monkeypatch.setattr(BaseWorker, "setup_api_client", mock_setup_api_client) monkeypatch.setattr(BaseWorker, "setup_api_client", mock_setup_api_client)
@pytest.fixture() @pytest.fixture
def mock_worker() -> ThumbnailsGenerator: def mock_worker() -> ThumbnailsGenerator:
worker = ThumbnailsGenerator() worker = ThumbnailsGenerator()
worker.args = Namespace(dev=False) worker.args = Namespace(dev=False)
...@@ -63,7 +63,7 @@ def mock_worker() -> ThumbnailsGenerator: ...@@ -63,7 +63,7 @@ def mock_worker() -> ThumbnailsGenerator:
return worker return worker
@pytest.fixture() @pytest.fixture
def page_1_payload() -> dict: def page_1_payload() -> dict:
return { return {
"id": "page_1", "id": "page_1",
...@@ -89,7 +89,7 @@ def page_1_payload() -> dict: ...@@ -89,7 +89,7 @@ def page_1_payload() -> dict:
} }
@pytest.fixture() @pytest.fixture
def page_2_payload() -> dict: def page_2_payload() -> dict:
return { return {
"id": "page_2", "id": "page_2",
...@@ -115,7 +115,7 @@ def page_2_payload() -> dict: ...@@ -115,7 +115,7 @@ def page_2_payload() -> dict:
} }
@pytest.fixture() @pytest.fixture
def page_3_payload() -> dict: def page_3_payload() -> dict:
return { return {
"id": "page_3", "id": "page_3",
...@@ -141,7 +141,7 @@ def page_3_payload() -> dict: ...@@ -141,7 +141,7 @@ def page_3_payload() -> dict:
} }
@pytest.fixture() @pytest.fixture
def pages_payload( def pages_payload(
page_1_payload: dict, page_2_payload: dict, page_3_payload: dict page_1_payload: dict, page_2_payload: dict, page_3_payload: dict
) -> list[dict]: ) -> list[dict]:
......
...@@ -9,4 +9,3 @@ commands = ...@@ -9,4 +9,3 @@ commands =
deps = deps =
pytest pytest
pytest-responses pytest-responses
-rrequirements.txt
...@@ -14,18 +14,11 @@ class ThumbnailsGenerator(ElementsWorker): ...@@ -14,18 +14,11 @@ class ThumbnailsGenerator(ElementsWorker):
def configure(self) -> None: def configure(self) -> None:
super().configure() super().configure()
if self.user_configuration:
logger.info("Loading user_configuration")
self.config.update(self.user_configuration)
self.thumbnail_width: int = self.config["width"] self.thumbnail_width: int = self.config["width"]
self.thumbnail_height: int = self.config["height"] self.thumbnail_height: int = self.config["height"]
self.first_n: int = self.config.get("first_n") self.first_n: int = self.config.get("first_n")
corpus = self.request("RetrieveCorpus", id=self.corpus_id) self.list_corpus_types()
self.corpus_types = {
element_type["slug"]: element_type for element_type in corpus["types"]
}
def _list_folder_elements(self, folder): def _list_folder_elements(self, folder):
""" """
......