Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bandit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[bandit]
exclude: tests
exclude: ./tests
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
43 changes: 29 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
name: Tests
name: CI

on: [push]
on:
push:
branches:
- master
pull_request:

jobs:
build:

dist:
runs-on: ubuntu-latest
steps:
- name: Install gettext
run: sudo apt-get install gettext -y
- uses: actions/setup-python@v2
- run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer
- uses: actions/checkout@v2
- run: python setup.py sdist bdist_wheel
- run: python -m twine check dist/*

pytest:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.5, 3.6, 3.7]
django-version: [1.11.*, 2.2.*]

python-version:
- "3.7"
- "3.8"
- "3.9"
django-version:
- "2.2"
- "3.1"
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install django==${{ matrix.django-version }}
python -m pip install --upgrade pip setuptools codecov
pip install django~=${{ matrix.django-version }}
- name: Test with pytest
run: python setup.py test
- name: Codecov
uses: codecov/codecov-action@v1.0.2
with:
token: ${{secrets.CODECOV_TOKEN}}
- run: codecov
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Django Field that implement the following features:
* Access thumbnails on model level, no template tags required
* Preserves original image
* Asynchronous rendering (Celery & Co)
* Multi threading and processing for optimum performance
* Restrict accepted image dimensions
* Rename files to a standardized name (using a callable upload_to)

Expand Down Expand Up @@ -195,12 +194,3 @@ The `replace` option will replace all existing files.
The `ignore-missing` option will suspend missing source file errors and keep
rendering variations for other files. Othervise command will stop on first
missing file.

### Multi processing
Since version 2 stdImage supports multiprocessing.
Every image is rendered in separate process.
It not only increased performance but the garbage collection
and therefore the huge memory footprint from previous versions.

**Note:** PyPy seems to have some problems regarding multiprocessing,
for that matter all multiprocessing is disabled in PyPy.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ classifier =
include_package_data = True
packages = stdimage
install_requires =
Django>=1.11
Django>=2.2
pillow>=2.5
progressbar2>=3.0.0
setup_requires =
setuptools_scm
pytest-runner
tests_require =
pytest>=4.0,<5.0
pytest
pytest-cov
pytest-django

Expand Down
9 changes: 2 additions & 7 deletions stdimage/management/commands/rendervariations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from concurrent.futures import ProcessPoolExecutor
from multiprocessing import cpu_count

import progressbar
from django.apps import apps
from django.core.files.storage import get_storage_class
Expand Down Expand Up @@ -75,14 +72,12 @@ def render(field, images, count, replace, ignore_missing, do_render):
)
with progressbar.ProgressBar(max_value=count, widgets=(
progressbar.RotatingMarker(),
' | CPUs: {}'.format(cpu_count()),
' | ', progressbar.AdaptiveETA(),
' | ', progressbar.Percentage(),
' ', progressbar.Bar(),
)) as bar:
with ProcessPoolExecutor() as executor:
for _ in executor.map(render_field_variations, kwargs_list):
bar += 1
for _ in map(render_field_variations, kwargs_list):
bar += 1


def render_field_variations(kwargs):
Expand Down