diff --git a/.bandit b/.bandit index fba0d25..b7df176 100644 --- a/.bandit +++ b/.bandit @@ -1,2 +1,2 @@ [bandit] -exclude: tests +exclude: ./tests diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..71607d0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 17f8f14..026496f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/README.md b/README.md index 709b586..e646511 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. diff --git a/setup.cfg b/setup.cfg index 162dda1..4255691 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/stdimage/management/commands/rendervariations.py b/stdimage/management/commands/rendervariations.py index 86a0a42..2ba3df3 100644 --- a/stdimage/management/commands/rendervariations.py +++ b/stdimage/management/commands/rendervariations.py @@ -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 @@ -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):