Skip to content

Commit

Permalink
remove TIME_INPUT_FORMATS from settings, comment redis commander from…
Browse files Browse the repository at this point in the history
… docker compose, add ENCODING_TRANSCODING_CELERY_BROKER_URL to manage distant transcript and encode, create task to transcript and import transcription
  • Loading branch information
ptitloup committed Jun 30, 2023
1 parent 4d86dee commit 01a4505
Show file tree
Hide file tree
Showing 9 changed files with 571 additions and 469 deletions.
18 changes: 9 additions & 9 deletions docker-compose-dev-with-volumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ services:
ports:
- 6379:6379

redis-commander:
container_name: redis-commander
hostname: redis-commander
image: rediscommander/redis-commander:latest
restart: always
environment:
- REDIS_HOSTS=local:redis:6379
ports:
- "8081:8081"
# redis-commander:
# container_name: redis-commander
# hostname: redis-commander
# image: rediscommander/redis-commander:latest
# restart: always
# environment:
# - REDIS_HOSTS=local:redis:6379
# ports:
# - "8081:8081"
3 changes: 0 additions & 3 deletions pod/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
import os
import importlib.util
# import django.conf.global_settings

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# will be update in pod/main/settings.py
Expand Down Expand Up @@ -457,8 +456,6 @@ def update_settings(local_settings):
for variable in the_update_settings:
locals()[variable] = the_update_settings[variable]

# TIME_INPUT_FORMATS = ["%H:%M", *django.conf.global_settings.TIME_INPUT_FORMATS]

if locals()["DEBUG"] is True and importlib.util.find_spec("debug_toolbar") is not None:
INSTALLED_APPS.append("debug_toolbar")
MIDDLEWARE = [
Expand Down
11 changes: 7 additions & 4 deletions pod/video_encode_transcript/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@

if USE_TRANSCRIPTION:
from . import transcript

TRANSCRIPT_VIDEO = getattr(settings, "TRANSCRIPT_VIDEO", "start_transcript")

CELERY_TO_ENCODE = getattr(settings, "CELERY_TO_ENCODE", False)
EMAIL_ON_ENCODING_COMPLETION = getattr(settings, "EMAIL_ON_ENCODING_COMPLETION", True)

USE_DISTANT_ENCODING = getattr(settings, "USE_DISTANT_ENCODING", False)
if USE_DISTANT_ENCODING:
USE_DISTANT_ENCODING_TRANSCODING = getattr(
settings,
"USE_DISTANT_ENCODING_TRANSCODING",
False
)
if USE_DISTANT_ENCODING_TRANSCODING:
from .encoding_tasks import start_encoding_task

# ##########################################################################
Expand Down Expand Up @@ -118,7 +121,7 @@ def encode_video(video_id):
encoding_video.remove_old_data()

change_encoding_step(video_id, 2, "start encoding")
if USE_DISTANT_ENCODING:
if USE_DISTANT_ENCODING_TRANSCODING:
start_encoding_task.delay(
encoding_video.id,
encoding_video.video_file,
Expand Down
8 changes: 6 additions & 2 deletions pod/video_encode_transcript/encoding_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@

logger = logging.getLogger(__name__)

ENCODING_CELERY_BROKER_URL = getattr(settings, "ENCODING_CELERY_BROKER_URL", "")
ENCODING_TRANSCODING_CELERY_BROKER_URL = getattr(
settings,
"ENCODING_TRANSCODING_CELERY_BROKER_URL",
""
)

encoding_app = Celery(
"encoding_tasks",
broker=ENCODING_CELERY_BROKER_URL
broker=ENCODING_TRANSCODING_CELERY_BROKER_URL
)
encoding_app.conf.task_routes = {
"pod.video_encode_transcript.encoding_tasks.*": {"queue": "encoding"}
Expand Down
8 changes: 6 additions & 2 deletions pod/video_encode_transcript/importing_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import logging
logger = logging.getLogger(__name__)

ENCODING_CELERY_BROKER_URL = getattr(settings, "ENCODING_CELERY_BROKER_URL", "")
ENCODING_TRANSCODING_CELERY_BROKER_URL = getattr(
settings,
"ENCODING_TRANSCODING_CELERY_BROKER_URL",
""
)

importing_app = Celery(
"importing_tasks",
broker=ENCODING_CELERY_BROKER_URL
broker=ENCODING_TRANSCODING_CELERY_BROKER_URL
)
importing_app.conf.task_routes = {
"pod.video_encode_transcript.importing_tasks.*": {"queue": "importing"}
Expand Down
31 changes: 31 additions & 0 deletions pod/video_encode_transcript/importing_transcript_tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from celery import Celery
from .. import settings
import logging
logger = logging.getLogger(__name__)

ENCODING_TRANSCODING_CELERY_BROKER_URL = getattr(
settings,
"ENCODING_TRANSCODING_CELERY_BROKER_URL",
""
)

importing_transcript_app = Celery(
"importing_transcript_tasks",
broker=ENCODING_TRANSCODING_CELERY_BROKER_URL
)
importing_transcript_app.conf.task_routes = {
"pod.video_encode_transcript.importing_transcript_tasks.*": {
"queue": "importing_transcript"
}
}


# celery -A pod.video_encode_transcript.importing_tasks worker -l INFO -Q importing
@importing_transcript_app.task
def start_importing_transcript_task(video_id, msg, webvtt):
"""Start the encoding of the video."""
print("Start the importing transcript of the video ID : %s" % video_id)
from pod.video.models import Video
from .transcript import save_vtt_and_notify
video_to_encode = Video.objects.get(id=video_id)
save_vtt_and_notify(video_to_encode, msg, webvtt)
Loading

0 comments on commit 01a4505

Please sign in to comment.