Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DONE] Fix remote encoding and other stuff #1056

Merged
merged 61 commits into from Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b7b3f64
add test for video search utils
ptitloup Feb 15, 2024
5e72e28
test_index_and_delete_es
ptitloup Feb 15, 2024
d5c5331
replace USE_DISTANT_ENCODING_TRANSCODING by USE_REMOTE_ENCODING_TRANS…
ptitloup Feb 16, 2024
cf742c5
remove import dressing in encode module to use it without django
ptitloup Feb 19, 2024
8992213
remove unused import
ptitloup Feb 19, 2024
0bcff67
remove unused import - fix pep8 compliance
ptitloup Feb 19, 2024
a7e2936
move json calling to prevent none objeect
ptitloup Feb 19, 2024
db7f62f
fix pep8
ptitloup Feb 19, 2024
90ded7e
create rest view to importing transcript - call it from task - remove…
ptitloup Feb 20, 2024
db0210f
fix transcritping
ptitloup Feb 20, 2024
096d964
fix import transcript error
ptitloup Feb 21, 2024
91dd821
add new configuration
ptitloup Feb 21, 2024
de206d0
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
ptitloup Feb 21, 2024
7fe669f
fix access token link
ptitloup Feb 21, 2024
879b631
fix download file in main view
ptitloup Feb 21, 2024
677b55a
add test to remote encoding
ptitloup Feb 22, 2024
32fa355
update docker
ptitloup Feb 22, 2024
8612930
add wait docker and show running container
ptitloup Feb 22, 2024
a4a2b2f
add env file
ptitloup Feb 22, 2024
5cdd9c1
split env and start container
ptitloup Feb 22, 2024
4a4b1e9
start container on one line
ptitloup Feb 22, 2024
8ae9e83
start container on one line remove bracket
ptitloup Feb 22, 2024
364e5bc
split build and run container
ptitloup Feb 22, 2024
c2e5b0a
add env to up container
ptitloup Feb 22, 2024
b6ec82e
add elasticsearch verion
ptitloup Feb 22, 2024
5069da3
export elasticsearch version
ptitloup Feb 22, 2024
d9f8215
move env
ptitloup Feb 22, 2024
d9ebafe
use make to try
ptitloup Feb 22, 2024
485830a
add setting local
ptitloup Feb 22, 2024
2e84cdb
remove touch
ptitloup Feb 22, 2024
a5dd7f7
fix file
ptitloup Feb 22, 2024
701275d
fix setting local
ptitloup Feb 22, 2024
b32e323
remove unused dot
ptitloup Feb 22, 2024
4956b47
remove brace
ptitloup Feb 22, 2024
420b962
use settings_local_docker_full_test file
ptitloup Feb 22, 2024
242d6a3
add detach to docker and add setting to xapi
ptitloup Feb 22, 2024
239195b
add docker exec to test
ptitloup Feb 22, 2024
2dfce05
remove -p and add detach
ptitloup Feb 22, 2024
ff4a289
remove unused option for docker up
ptitloup Feb 22, 2024
e1f35b0
replace healthy by wait
ptitloup Feb 22, 2024
4614b77
add test_encode_transcode command, use form to fix download view and …
ptitloup Feb 23, 2024
88abeb2
simple test to try
ptitloup Feb 23, 2024
c8ffb57
fix test for download file, add encode video
ptitloup Feb 23, 2024
5518040
fix pep8 and increase delay to encode
ptitloup Feb 23, 2024
1c868b2
fix unit test and improve code after review
ptitloup Feb 23, 2024
49a24bf
change test remote encode in unit test
ptitloup Feb 23, 2024
a487adf
change command to run test, add print
ptitloup Feb 23, 2024
8511cc2
call encode to prevent thread - check if run test and pod back run on…
ptitloup Feb 23, 2024
3a047b6
work on local - try on GH
ptitloup Feb 23, 2024
7f54b4a
Add token and specify url to call back at the end of encoding
ptitloup Feb 23, 2024
1b3f718
change ES version and fix pep8
ptitloup Feb 23, 2024
a60d3ad
fix token
ptitloup Feb 23, 2024
0690d35
add staff status for user
ptitloup Feb 23, 2024
1320798
Add some translations
AymericJak Mar 1, 2024
f0c4e36
use covergae to run test
ptitloup Mar 1, 2024
33ee61c
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
ptitloup Mar 1, 2024
639a7f9
fix conflict - fix pep8
ptitloup Mar 1, 2024
eb2978f
add transcripting in test - change setting to do it - improve transcr…
ptitloup Mar 1, 2024
9c6d19f
change transcode by transcript !
ptitloup Mar 1, 2024
cf6f654
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
ptitloup Mar 1, 2024
e3b9513
fix pep8 in test settings
ptitloup Mar 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/pod_encoding.yml
@@ -0,0 +1,87 @@
name: Pod Encoding Full Docker
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀

on:
push:
branches:
- main
- master
- develop
- features/**
- dependabot/**
pull_request:
branches:
- main
- master
- develop
env:
DJANGO_SUPERUSER_USERNAME: "admin"
DJANGO_SUPERUSER_PASSWORD: "passwd"
DJANGO_SUPERUSER_EMAIL: "noreplay@uni.fr"
ELASTICSEARCH_TAG: "elasticsearch:7.17.18"
ELASTICSEARCH_VERION: "elasticsearch:7.17.18"
NODE_TAG: "node:19"
PYTHON_TAG: "python:3.9-buster"
REDIS_TAG: "redis:alpine3.16"
DOCKER_ENV: "full"
GECKODRIVER_VER: "v0.29.0"
FIREFOX_VER: "87.0"

jobs:
Pod-Docker-Encoding-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
- name: Create settings local file
run: |
mv pod/custom/settings_local_docker_full_test.py pod/custom/settings_local.py
- name: cat settings local
run: cat pod/custom/settings_local.py
- name: Create env file containers
run: |
touch .env.dev
echo DJANGO_SUPERUSER_USERNAME=$DJANGO_SUPERUSER_USERNAME >> .env.dev
echo DJANGO_SUPERUSER_PASSWORD=$DJANGO_SUPERUSER_PASSWORD >> .env.dev
echo DJANGO_SUPERUSER_EMAIL=$DJANGO_SUPERUSER_EMAIL >> .env.dev
echo ELASTICSEARCH_TAG=$ELASTICSEARCH_TAG >> .env.dev
echo ELASTICSEARCH_VERSION=$ELASTICSEARCH_TAG >> .env.dev
echo NODE_TAG=$NODE_TAG >> .env.dev
echo PYTHON_TAG=$PYTHON_TAG >> .env.dev
echo REDIS_TAG=$REDIS_TAG >> .env.dev
echo DOCKER_ENV=full >> .env.dev
echo GECKODRIVER_VER=v0.29.0
echo FIREFOX_VER=87.0
- name: cat env
run: cat .env.dev
- name: make Build container
run: |
sudo rm -rf ./pod/log
sudo rm -rf ./pod/static
sudo rm -rf ./pod/node_modules
docker-compose -f ./docker-compose-full-dev-with-volumes.yml -p esup-pod build --build-arg ELASTICSEARCH_VERSION=$ELASTICSEARCH_TAG --build-arg NODE_VERSION=$NODE_TAG --build-arg PYTHON_VERSION=$PYTHON_TAG --no-cache
docker-compose -f ./docker-compose-full-dev-with-volumes.yml up --detach --force-recreate --always-recreate-deps
- name: Sleep for 60 seconds
uses: jakejarvis/wait-action@master
with:
time: '60s'
- name: show running container
run: docker ps
- run: |
echo "🍏 Docker is UP ${{ job.status }}."
docker exec pod-back-with-volumes ps auxf
- name: run test in docker
run: docker exec pod-back-with-volumes python manage.py test_encode_transcode
- name: Stop containers
if: always()
run: docker-compose -f ./docker-compose-full-dev-with-volumes.yml down
- run: echo "END"
2 changes: 1 addition & 1 deletion dockerfile-dev-with-volumes/README.adoc
Expand Up @@ -102,7 +102,7 @@ SESSION_REDIS = {
MIGRATION_MODULES = {'flatpages': 'pod.db_migrations'}

# Si DOCKER_ENV = full il faut activer l'encodage et la transcription distante
# USE_DISTANT_ENCODING_TRANSCODING = True
# USE_REMOTE_ENCODING_TRANSCODING = True
# ENCODING_TRANSCODING_CELERY_BROKER_URL = "redis://redis:6379/7"

# pour avoir le maximum de log sur la console
Expand Down
2 changes: 1 addition & 1 deletion dockerfile-dev-with-volumes/pod-back/Dockerfile
Expand Up @@ -32,7 +32,7 @@ RUN mkdir /tmp/node_modules/
COPY --from=source-build-js /tmp/pod/node_modules/ /tmp/node_modules/
# TODO remove ES version - move it into env var
RUN pip3 install --no-cache-dir -r requirements-conteneur.txt \
&& pip3 install elasticsearch==8.9.0
&& pip3 install elasticsearch==7.17.7

# ENTRYPOINT :
COPY ./dockerfile-dev-with-volumes/pod-back/my-entrypoint-back.sh /tmp/my-entrypoint-back.sh
Expand Down
2 changes: 0 additions & 2 deletions dockerfile-dev-with-volumes/pod-back/my-entrypoint-back.sh
Expand Up @@ -25,7 +25,5 @@ fi
# Le serveur de développement permet de tester vos futures modifications facilement.
# N'hésitez pas à lancer le serveur de développement pour vérifier vos modifications au fur et à mesure.
# À ce niveau, vous devriez avoir le site en français et en anglais et voir l'ensemble de la page d'accueil.
celery -A pod.video_encode_transcript.importing_tasks worker -l INFO -Q importing --concurrency 1 --detach -n import_encode
celery -A pod.video_encode_transcript.importing_transcript_tasks worker -l INFO -Q importing_transcript --concurrency 1 --detach -n import_transcript
python3 manage.py runserver 0.0.0.0:8080 --insecure
sleep infinity
60 changes: 60 additions & 0 deletions pod/custom/settings_local_docker_full_test.py
AymericJak marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1,60 @@
DEBUG = True

TEST_REMOTE_ENCODE = True
TEST_SETTINGS = True

ALLOWED_HOSTS = ["*"]

ADMINS = (
('Nicolas', 'nicolas@univ.fr'),
)

USE_PODFILE = True
USE_NOTIFICATIONS = False
EMAIL_ON_ENCODING_COMPLETION = False
SECRET_KEY = 'A_CHANGER'

# We specify here that we're using ES version 7\n
ES_VERSION = 7
ES_URL = ['http://elasticsearch:9200/']
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://redis:6379/3',
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
},
'KEY_PREFIX': 'pod'
},
'select2': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://redis:6379/2',
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
},
},
}
SESSION_ENGINE = 'redis_sessions.session'
SESSION_REDIS = {
'host': 'redis',
'port': 6379,
'db': 4,
'prefix': 'session',
'socket_timeout': 1,
'retry_on_timeout': False,
}

# Only in containerized environments
MIGRATION_MODULES = {'flatpages': 'pod.db_migrations'}

# If DOCKER_ENV = full: activate encoding, transcription and remote xapi
USE_REMOTE_ENCODING_TRANSCODING = True
ENCODING_TRANSCODING_CELERY_BROKER_URL = 'redis://redis:6379/7'
POD_API_URL = "http://pod-back:8080/rest"
POD_API_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

USE_XAPI_VIDEO = False
XAPI_CELERY_BROKER_URL = "redis://redis:6379/6"

# for maximum console logging\n
LOGGING = {}
18 changes: 1 addition & 17 deletions pod/dressing/tests/test_utils.py
Expand Up @@ -5,29 +5,13 @@
from unittest.mock import patch
from django.contrib.auth.models import User
from pod.authentication.models import AccessGroup
from pod.dressing.utils import get_dressings, get_position_value, get_dressing_input
from pod.dressing.utils import get_dressings, get_dressing_input
from pod.dressing.models import Dressing


class DressingUtilitiesTests(unittest.TestCase):
"""TestCase for Esup-Pod dressing utilities."""

def test_get_position_value(self):
"""Test for the get_position_value function."""
result = get_position_value("top_right", "720")
self.assertEqual(result, "overlay=main_w-overlay_w-36.0:36.0")

result = get_position_value("top_left", "720")
self.assertEqual(result, "overlay=36.0:36.0")

result = get_position_value("bottom_right", "720")
self.assertEqual(result, "overlay=main_w-overlay_w-36.0:main_h-overlay_h-36.0")

result = get_position_value("bottom_left", "720")
self.assertEqual(result, "overlay=36.0:main_h-overlay_h-36.0")

print(" ---> test_get_position_value: OK! --- DressingUtilsTest")

def test_get_dressing_input(self):
"""Test for the get_dressing_input function."""
dressing = Dressing(watermark=None, opening_credits=None, ending_credits=None)
Expand Down
22 changes: 0 additions & 22 deletions pod/dressing/utils.py
Expand Up @@ -6,28 +6,6 @@
from django.db.models import Q


def get_position_value(position: str, height: str) -> str:
"""
Obtain dimensions proportional to the video format.

Args:
position (str): proprerty "position" of the dressing object.
height (str): height of the source video.

Returns:
str: params for the ffmpeg command.
"""
height = str(float(height) * 0.05)
if position == "top_right":
return "overlay=main_w-overlay_w-" + height + ":" + height
elif position == "top_left":
return "overlay=" + height + ":" + height
elif position == "bottom_right":
return "overlay=main_w-overlay_w-" + height + ":main_h-overlay_h-" + height
elif position == "bottom_left":
return "overlay=" + height + ":main_h-overlay_h-" + height


def get_dressing_input(dressing: Dressing, FFMPEG_DRESSING_INPUT: str) -> str:
"""
Obtain the files necessary for encoding a dressed video.
Expand Down
36 changes: 33 additions & 3 deletions pod/main/configuration.json
AymericJak marked this conversation as resolved.
Show resolved Hide resolved
Expand Up @@ -3029,7 +3029,7 @@
"pod_version_end": "",
"pod_version_init": "3.1.0"
},
"USE_DISTANT_ENCODING_TRANSCODING": {
"USE_REMOTE_ENCODING_TRANSCODING": {
"default_value": false,
"description": {
"en": [
Expand All @@ -3041,7 +3041,37 @@
]
},
"pod_version_end": "",
"pod_version_init": "3.4.0"
"pod_version_init": "3.5.1"
},
"POD_API_URL": {
"default_value": "",
"description": {
"en": [
"Address of API rest to be called at the end of remote encoding or remote transcription.",
"Example : https://pod.univ.fr/rest/"
],
"fr": [
"Adresse de l'API rest a appeler en fin d'encodage distant ou de transcription à distance.",
"Exemple : https://pod.univ.fr/rest/"
]
},
"pod_version_end": "",
"pod_version_init": "3.5.1"
},
"POD_API_TOKEN": {
"default_value": "",
"description": {
"en": [
"Authentication token used for the call at the end of remote encoding or remote transcription.",
"To create it, go to Admin > Authentication token > token."
],
"fr": [
"Token d'authentification utilisé pour l'appel en fin d'encodage distant ou de transcription à distance.",
"Pour le créer, il faut aller dans la partie Admin > Jeton d'authentification > token."
]
},
"pod_version_end": "",
"pod_version_init": "3.5.1"
},
"VIDEO_RENDITIONS": {
"default_value": "[]",
Expand Down Expand Up @@ -5052,7 +5082,7 @@
"Mise en place du mode PWA grâce à l'application Django-pwa",
"Voici la configuration par défaut pour Pod, vous pouvez surcharger chaque variable dans votre fichier de configuration.",
"PWA_APP_NAME = \"Pod\"",
"PWA_APP_DESCRIPTION = _(",
"PWA_APP_DESCRIPTION = (",
" \"Pod is aimed at users of our institutions, by allowing the publication of \"",
" \"videos in the fields of research (promotion of platforms, etc.), training \"",
" \"(tutorials, distance training, student reports, etc.), institutional life (video \"",
Expand Down
15 changes: 15 additions & 0 deletions pod/main/forms.py
Expand Up @@ -21,6 +21,21 @@
)


class DownloadFileForm(forms.Form):
"""Manage "Download File" form."""
filename = forms.FilePathField(
required=True,
path=settings.MEDIA_ROOT,
recursive=True,
allow_files=True,
allow_folders=False
)

def __init__(self, *args, **kwargs):
"""Init download file form."""
super(DownloadFileForm, self).__init__(*args, **kwargs)


class ContactUsForm(forms.Form):
"""Manage "Contact us" form."""

Expand Down
7 changes: 6 additions & 1 deletion pod/main/rest_router.py
Expand Up @@ -75,7 +75,7 @@
urlpatterns = [
url(r"dublincore/$", video_views.DublinCoreView.as_view(), name="dublincore"),
url(
r"launch_encode_view/$",
r"^launch_encode_view/$",
encode_views.launch_encode_view,
name="launch_encode_view",
),
Expand All @@ -84,6 +84,11 @@
encode_views.store_remote_encoded_video,
name="store_remote_encoded_video",
),
url(
r"store_remote_transcripted_video/$",
encode_views.store_remote_transcripted_video,
name="store_remote_transcripted_video",
),
url(
r"accessgroups_set_users_by_name/$",
auth_views.accessgroups_set_users_by_name,
Expand Down
3 changes: 1 addition & 2 deletions pod/main/settings.py
Expand Up @@ -5,7 +5,6 @@
"""

import os
from django.utils.translation import gettext_lazy as _

##
# flatpages
Expand Down Expand Up @@ -312,7 +311,7 @@
# PWA

PWA_APP_NAME = "Pod"
PWA_APP_DESCRIPTION = _(
PWA_APP_DESCRIPTION = (
ptitloup marked this conversation as resolved.
Show resolved Hide resolved
"Pod is aimed at users of our institutions, by allowing the publication of "
"videos in the fields of research (promotion of platforms, etc.), training "
"(tutorials, distance training, student reports, etc.), institutional life (video "
Expand Down
Binary file not shown.
4 changes: 4 additions & 0 deletions pod/main/test_settings.py
Expand Up @@ -21,9 +21,13 @@
)
USE_DOCKER = True
path = "pod/custom/settings_local.py"
ES_URL = ["http://127.0.0.1:9200/"]
ptitloup marked this conversation as resolved.
Show resolved Hide resolved
ES_VERSION = 6
if os.path.exists(path):
_temp = __import__("pod.custom", globals(), locals(), ["settings_local"])
USE_DOCKER = getattr(_temp.settings_local, "USE_DOCKER", True)
ES_URL = getattr(_temp.settings_local, "ES_URL", ["http://127.0.0.1:9200/"])
ES_VERSION = getattr(_temp.settings_local, "ES_VERSION", 6)

for application in INSTALLED_APPS:
if application.startswith("pod"):
Expand Down