From 3a94462bd6683a98378df9c12583c29c517e3fe4 Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Sat, 21 Jul 2018 12:57:48 +0200 Subject: [PATCH] Removed django-cacheops dependency --- .env.dev | 1 - .gitlab-ci.yml | 1 - api/config/settings/common.py | 10 ---------- api/config/settings/production.py | 6 ------ .../music/management/commands/fix_track_files.py | 2 -- api/funkwhale_api/playlists/serializers.py | 7 ------- api/requirements/base.txt | 1 - api/setup.cfg | 1 - changes/changelog.d/cacheops.enhancement | 12 ++++++++++++ 9 files changed, 12 insertions(+), 29 deletions(-) create mode 100644 changes/changelog.d/cacheops.enhancement diff --git a/.env.dev b/.env.dev index 7037b1dbd4..5b68656006 100644 --- a/.env.dev +++ b/.env.dev @@ -10,5 +10,4 @@ PYTHONDONTWRITEBYTECODE=true WEBPACK_DEVSERVER_PORT=8080 MUSIC_DIRECTORY_PATH=/music BROWSABLE_API_ENABLED=True -CACHEOPS_ENABLED=False FORWARDED_PROTO=http diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8d579c9635..57e258e938 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -143,7 +143,6 @@ test_api: DJANGO_ALLOWED_HOSTS: "localhost" DATABASE_URL: "postgresql://postgres@postgres/postgres" FUNKWHALE_URL: "https://funkwhale.ci" - CACHEOPS_ENABLED: "false" DJANGO_SETTINGS_MODULE: config.settings.local only: - branches diff --git a/api/config/settings/common.py b/api/config/settings/common.py index 03ce8a9c82..4a68f80f28 100644 --- a/api/config/settings/common.py +++ b/api/config/settings/common.py @@ -92,7 +92,6 @@ THIRD_PARTY_APPS = ( "rest_auth.registration", "dynamic_preferences", "django_filters", - "cacheops", "django_cleanup", "versatileimagefield", ) @@ -421,15 +420,6 @@ PROTECT_FILES_PATH = env("PROTECT_FILES_PATH", default="/_protected") # use this setting to tweak for how long you want to cache # musicbrainz results. (value is in seconds) MUSICBRAINZ_CACHE_DURATION = env.int("MUSICBRAINZ_CACHE_DURATION", default=300) -CACHEOPS_REDIS = env("CACHE_URL", default=CACHE_DEFAULT) -CACHEOPS_ENABLED = env.bool("CACHEOPS_ENABLED", default=True) -CACHEOPS = { - "music.artist": {"ops": "all", "timeout": 60 * 60}, - "music.album": {"ops": "all", "timeout": 60 * 60}, - "music.track": {"ops": "all", "timeout": 60 * 60}, - "music.trackfile": {"ops": "all", "timeout": 60 * 60}, - "taggit.tag": {"ops": "all", "timeout": 60 * 60}, -} # Custom Admin URL, use {% url 'admin:index' %} ADMIN_URL = env("DJANGO_ADMIN_URL", default="^api/admin/") diff --git a/api/config/settings/production.py b/api/config/settings/production.py index 72b08aa3c8..26def9fd03 100644 --- a/api/config/settings/production.py +++ b/api/config/settings/production.py @@ -51,12 +51,6 @@ CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS # END SITE CONFIGURATION -# STORAGE CONFIGURATION -# ------------------------------------------------------------------------------ -# Uploaded Media Files -# ------------------------ -DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage" - # Static Assets # ------------------------ STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage" diff --git a/api/funkwhale_api/music/management/commands/fix_track_files.py b/api/funkwhale_api/music/management/commands/fix_track_files.py index 988f9bed36..c61972db87 100644 --- a/api/funkwhale_api/music/management/commands/fix_track_files.py +++ b/api/funkwhale_api/music/management/commands/fix_track_files.py @@ -1,4 +1,3 @@ -import cacheops from django.core.management.base import BaseCommand from django.db import transaction from django.db.models import Q @@ -24,7 +23,6 @@ class Command(BaseCommand): self.fix_mimetypes(**options) self.fix_file_data(**options) self.fix_file_size(**options) - cacheops.invalidate_model(models.TrackFile) @transaction.atomic def fix_mimetypes(self, dry_run, **kwargs): diff --git a/api/funkwhale_api/playlists/serializers.py b/api/funkwhale_api/playlists/serializers.py index 5bb31f63e9..a60a349387 100644 --- a/api/funkwhale_api/playlists/serializers.py +++ b/api/funkwhale_api/playlists/serializers.py @@ -107,13 +107,6 @@ class PlaylistSerializer(serializers.ModelSerializer): covers = [] max_covers = 5 for plt in plts: - if not hasattr(plt.track.album.cover, "crop"): - # In some rare situations, we end up with the following stack strace: - # AttributeError: 'VersatileImageFieldFile' object has no attribute 'crop' - # I tend to thing our complex prefetch logic is troubling for versatile - # image field, so wi initialize the missing attribute by hand, cf - # https://github.com/respondcreate/django-versatileimagefield/blob/1.9/versatileimagefield/mixins.py#L108 - plt.track.album.cover.build_filters_and_sizers((0.5, 0, 5), False) url = plt.track.album.cover.crop["200x200"].url if url in covers: continue diff --git a/api/requirements/base.txt b/api/requirements/base.txt index ed179a8978..e4a85d99fa 100644 --- a/api/requirements/base.txt +++ b/api/requirements/base.txt @@ -58,7 +58,6 @@ python-magic==0.4.15 ffmpeg-python==0.1.10 channels>=2,<2.1 channels_redis>=2.1,<2.2 -django-cacheops>=4,<4.1 daphne==2.0.4 cryptography>=2,<3 diff --git a/api/setup.cfg b/api/setup.cfg index 18e34bc354..aa9a57abb8 100644 --- a/api/setup.cfg +++ b/api/setup.cfg @@ -18,5 +18,4 @@ env = EMAIL_CONFIG=consolemail:// CELERY_BROKER_URL=memory:// CELERY_TASK_ALWAYS_EAGER=True - CACHEOPS_ENABLED=False FEDERATION_HOSTNAME=test.federation diff --git a/changes/changelog.d/cacheops.enhancement b/changes/changelog.d/cacheops.enhancement new file mode 100644 index 0000000000..7d5ea65fd9 --- /dev/null +++ b/changes/changelog.d/cacheops.enhancement @@ -0,0 +1,12 @@ +Removed django-cacheops dependency + +Removed Cacheops dependency +--------------------------- + +We removed one of our dependency named django-cacheops. It was unly used in a few places, +and not playing nice with other dependencies. + +You can safely remove this dependency in your environment with ``pip uninstall django-cacheops`` if you're +not using docker. + +You can also safely remove any ``CACHEOPS_ENABLED`` setting from your environment file. -- GitLab