Skip to content

Commit

Permalink
Merge branch 'EsupPortail:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbild authored Mar 5, 2024
2 parents e902cc6 + 6a190f0 commit 9ed995f
Show file tree
Hide file tree
Showing 58 changed files with 1,588 additions and 623 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/pod_encoding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Pod Encoding Full Docker
run-name: ${{ github.actor }} is testing Pod encoding 🚀

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 to wait run server on pod back
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 coverage run --source='.' manage.py test_encode_transcript
- name: Stop containers
if: always()
run: docker-compose -f ./docker-compose-full-dev-with-volumes.yml down
- run: echo "END"
24 changes: 22 additions & 2 deletions CONFIGURATION_FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Voici les configurations des applications tierces utilisées par Esup-Pod.<br>
>> Mise en place du mode PWA grâce à l'application Django-pwa <br>
>> Voici la configuration par défaut pour Pod, vous pouvez surcharger chaque variable dans votre fichier de configuration. <br>
>> PWA_APP_NAME = "Pod" <br>
>> PWA_APP_DESCRIPTION = _( <br>
>> PWA_APP_DESCRIPTION = ( <br>
>> "Pod is aimed at users of our institutions, by allowing the publication of " <br>
>> "videos in the fields of research (promotion of platforms, etc.), training " <br>
>> "(tutorials, distance training, student reports, etc.), institutional life (video " <br>
Expand Down Expand Up @@ -1164,6 +1164,12 @@ Vous pouvez tout à fait rajouter des langues comme vous le souhaitez. Il faudra
- `OIDC_CLAIM_PREFERRED_USERNAME`
> valeur par défaut : `preferred_username`
>> Noms des Claim permettant de récupérer l'attribut login mais dépendant de l'attribut du client dans l'IDP <br>
- `OIDC_CLAIM_GIVEN_NAME`
> valeur par défaut : `given_name`
Expand Down Expand Up @@ -2683,13 +2689,27 @@ Attention, il faut configurer Celery pour l’envoi des instructions pour l'enco
>>
>> ```
- `USE_DISTANT_ENCODING_TRANSCODING`
- `USE_REMOTE_ENCODING_TRANSCODING`
> valeur par défaut : `False`
>> Si True, active l'encodage et la transcription sur un environnement distant via redis+celery <br>
- `POD_API_URL`
> valeur par défaut : ``
>> Adresse de l'API rest a appeler en fin d'encodage distant ou de transcription à distance. <br>
>> Exemple : https://pod.univ.fr/rest/ <br>
- `POD_API_TOKEN`
> valeur par défaut : ``
>> Token d'authentification utilisé pour l'appel en fin d'encodage distant ou de transcription à distance. <br>
>> Pour le créer, il faut aller dans la partie Admin > Jeton d'authentification > token. <br>
- `VIDEO_RENDITIONS`
> valeur par défaut : `[]`
Expand Down
2 changes: 1 addition & 1 deletion dockerfile-dev-with-volumes/README.adoc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
5 changes: 5 additions & 0 deletions pod/authentication/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def update_owner_params(user, params):
# #changing-how-django-users-are-created
OIDC_CLAIM_GIVEN_NAME = getattr(settings, "OIDC_CLAIM_GIVEN_NAME", "given_name")
OIDC_CLAIM_FAMILY_NAME = getattr(settings, "OIDC_CLAIM_FAMILY_NAME", "family_name")
OIDC_CLAIM_PREFERRED_USERNAME = getattr(
settings, "OIDC_CLAIM_PREFERRED_USERNAME", "preferred_username"
)
OIDC_DEFAULT_AFFILIATION = getattr(
settings, "OIDC_DEFAULT_AFFILIATION", DEFAULT_AFFILIATION
)
Expand All @@ -87,6 +90,7 @@ def create_user(self, claims):

user.first_name = claims.get(OIDC_CLAIM_GIVEN_NAME, "")
user.last_name = claims.get(OIDC_CLAIM_FAMILY_NAME, "")
user.username = claims.get(OIDC_CLAIM_PREFERRED_USERNAME, "")
user.owner.affiliation = OIDC_DEFAULT_AFFILIATION
for code_name in OIDC_DEFAULT_ACCESS_GROUP_CODE_NAMES:
try:
Expand All @@ -105,6 +109,7 @@ def update_user(self, user, claims):
"""Update OIDC user."""
user.first_name = claims.get(OIDC_CLAIM_GIVEN_NAME, "")
user.last_name = claims.get(OIDC_CLAIM_FAMILY_NAME, "")
user.username = claims.get(OIDC_CLAIM_PREFERRED_USERNAME, "")
user.save()

user.owner.auth_type = "OIDC"
Expand Down
75 changes: 75 additions & 0 deletions pod/custom/settings_local_docker_full_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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_TRANSCRIPTION = True
TRANSCRIPTION_TYPE = "WHISPER"
TRANSCRIPTION_MODEL_PARAM = {
'WHISPER': {
'fr': {
'model': "small",
'download_root': "/usr/src/app/transcription/whisper/",
},
'en': {
'model': "small",
'download_root': "/usr/src/app/transcription/whisper/",
}
}
}

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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 9ed995f

Please sign in to comment.