Skip to content

Commit

Permalink
Remove heavyweight process constance variable
Browse files Browse the repository at this point in the history
  • Loading branch information
derneuere committed Nov 10, 2024
1 parent 566ffd9 commit f50678c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 26 deletions.
3 changes: 1 addition & 2 deletions api/batch_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions api/schemas/site_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]},
Expand All @@ -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"},
Expand Down
6 changes: 3 additions & 3 deletions api/views/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions api/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
17 changes: 0 additions & 17 deletions librephotos/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit f50678c

Please sign in to comment.