From f50678c4fead41232c0341fe58f53632df79003f Mon Sep 17 00:00:00 2001 From: Niaz Date: Sun, 10 Nov 2024 23:08:51 +0100 Subject: [PATCH] Remove heavyweight process constance variable --- api/batch_jobs.py | 3 +-- api/schemas/site_settings.py | 2 -- api/views/upload.py | 6 +++--- api/views/views.py | 2 -- librephotos/settings/production.py | 17 ----------------- 5 files changed, 4 insertions(+), 26 deletions(-) diff --git a/api/batch_jobs.py b/api/batch_jobs.py index d5afea51ce..6eebfb0158 100644 --- a/api/batch_jobs.py +++ b/api/batch_jobs.py @@ -3,7 +3,6 @@ from datetime import datetime import pytz -from constance import config as site_config from django.db.models import Q import api.util as util @@ -31,7 +30,7 @@ def batch_calculate_clip_embedding(user): lrj.progress_target = count lrj.save() if not torch.cuda.is_available(): - num_threads = max(1, site_config.HEAVYWEIGHT_PROCESS) + num_threads = 1 torch.set_num_threads(num_threads) os.environ["OMP_NUM_THREADS"] = str(num_threads) else: diff --git a/api/schemas/site_settings.py b/api/schemas/site_settings.py index 4d90bf6fe1..e74375d50e 100644 --- a/api/schemas/site_settings.py +++ b/api/schemas/site_settings.py @@ -4,7 +4,6 @@ {"required": ["allow_registration"]}, {"required": ["allow_upload"]}, {"required": ["skip_patterns"]}, - {"required": ["heavyweight_process"]}, {"required": ["map_api_provider"]}, {"required": ["map_api_key"]}, {"required": ["captioning_model"]}, @@ -14,7 +13,6 @@ "allow_registration": {"type": "boolean"}, "allow_upload": {"type": "boolean"}, "skip_patterns": {"type": "string"}, - "heavyweight_process": {"type": "number"}, "map_api_provider": {"type": "string"}, "map_api_key": {"type": "string"}, "captioning_model": {"type": "string"}, diff --git a/api/views/upload.py b/api/views/upload.py index d6a20214cf..f9b17e901f 100644 --- a/api/views/upload.py +++ b/api/views/upload.py @@ -45,7 +45,7 @@ def check_permissions(self, request): jwt = request.COOKIES.get("jwt") if jwt is not None: try: - token=AccessToken(jwt) + token = AccessToken(jwt) except TokenError: raise ChunkedUploadError( status=http_status.HTTP_403_FORBIDDEN, @@ -88,7 +88,7 @@ def check_permissions(self, request): jwt = request.COOKIES.get("jwt") if jwt is not None: try: - token=AccessToken(jwt) + token = AccessToken(jwt) except TokenError: raise ChunkedUploadError( status=http_status.HTTP_403_FORBIDDEN, @@ -110,7 +110,7 @@ def on_completion(self, uploaded_file, request): jwt = request.COOKIES.get("jwt") if jwt is not None: try: - token=AccessToken(jwt) + token = AccessToken(jwt) except TokenError: raise ChunkedUploadError( status=http_status.HTTP_403_FORBIDDEN, diff --git a/api/views/views.py b/api/views/views.py index 9d05cba48d..65c486060c 100644 --- a/api/views/views.py +++ b/api/views/views.py @@ -103,8 +103,6 @@ def post(self, request, format=None): site_config.ALLOW_UPLOAD = request.data["allow_upload"] if "skip_patterns" in request.data.keys(): site_config.SKIP_PATTERNS = request.data["skip_patterns"] - if "heavyweight_process" in request.data.keys(): - site_config.HEAVYWEIGHT_PROCESS = 0 if "map_api_provider" in request.data.keys(): site_config.MAP_API_PROVIDER = request.data["map_api_provider"] if "map_api_key" in request.data.keys(): diff --git a/librephotos/settings/production.py b/librephotos/settings/production.py index 700415f411..9d356577b7 100644 --- a/librephotos/settings/production.py +++ b/librephotos/settings/production.py @@ -74,17 +74,8 @@ "django_q", ] -# Defaults to number of cores of the host system -HEAVYWEIGHT_PROCESS_ENV = os.environ.get("HEAVYWEIGHT_PROCESS", None) -HEAVYWEIGHT_PROCESS = ( - int(HEAVYWEIGHT_PROCESS_ENV) - if (HEAVYWEIGHT_PROCESS_ENV and HEAVYWEIGHT_PROCESS_ENV.isnumeric()) - else 0 -) - Q_CLUSTER = { "name": "DjangORM", - "workers": HEAVYWEIGHT_PROCESS, "queue_limit": 50, "recycle": 50, "timeout": 10000000, @@ -146,14 +137,6 @@ "Comma delimited list of patterns to ignore (e.g. '@eaDir,#recycle' for synology devices)", str, ), - "HEAVYWEIGHT_PROCESS": ( - HEAVYWEIGHT_PROCESS, - """ - Number of workers, when scanning pictures. This setting can dramatically affect the ram usage. - Each worker needs 800MB of RAM. Change at your own will. Default is 1. - """, - int, - ), "MAP_API_PROVIDER": ( os.environ.get("MAP_API_PROVIDER", "photon"), "Map Provider",