Skip to content

Commit

Permalink
[DONE] Add optionnal proxy URL for request coming from Aristote (Esup…
Browse files Browse the repository at this point in the history
…Portail#1218)

Aristote IA as an infrastructure based on Kubernetes in order to automaticaly générate or delete backends servers adaptatively to the current load.
Those backends servers are directly requesting the POD server : Once to retrieve the URL of the audio file (witch is the base data for the IA treatment) and in second time to notify POD that the treatment is achieved.
So if the POD server not accessible from the all the WWW, the Aristote backend's will not be able to retrieve the audio file for treatment. That can be a problem on POD test servers that are not open to all the web for security reasons.
This code allow to specify a proxy URL (accessible from all the web) in order to catch Aristote backend's requests and redirect them to the POD test server (via the internal institution network)
  • Loading branch information
gcondess authored Oct 24, 2024
1 parent ff91b02 commit 706901a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
38 changes: 19 additions & 19 deletions CONFIGURATION_EN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
#

##
##

* `CAS`
> default value: `1.5.2`
Expand Down Expand Up @@ -29,7 +29,7 @@
* `tagging`
> default value: `0.5.0`
##
##

### Database

Expand Down Expand Up @@ -381,7 +381,7 @@
> default value: `False`
>>
##
##

### AI Enhancement application configuration

Expand Down Expand Up @@ -415,7 +415,7 @@ Set `USE_AI_ENHANCEMENT` to True to activate this application.<br>
> default value: `False`
>> Activation of artificial intelligence enhancements. Allows users to use it.<br>
###
###

* `AFFILIATION`
> default value: ``
Expand Down Expand Up @@ -559,10 +559,10 @@ Set `USE_AI_ENHANCEMENT` to True to activate this application.<br>
> default value: `False`
>>
###
###


###
###

* `ACTIVE_MODEL_ENRICH`
> default value: `False`
Expand Down Expand Up @@ -619,7 +619,7 @@ Set `USE_DRESSING` to True to activate this application.<br>
> default value: `True`
>> Activation of dressings. Allows users to customize a video with watermark & credits.<br>
###
###


### Seaker application configuration
Expand Down Expand Up @@ -659,7 +659,7 @@ Set `USE_IMPORT_VIDEO` to True to activate this application.<br>
> default value: `True`
>> Directory that will contain the video files generated by bbb-recorder.<br>
###
###

* `AFFILIATION_EVENT`
> default value: `['faculty', 'employee', 'staff']`
Expand Down Expand Up @@ -717,7 +717,7 @@ Set `USE_IMPORT_VIDEO` to True to activate this application.<br>
> default value: `60`
>>
###
###

* `LTI_ENABLED`
> default value: `False`
Expand All @@ -737,7 +737,7 @@ Set `USE_IMPORT_VIDEO` to True to activate this application.<br>
>> ```
>>
###
###
* `HOMEPAGE_VIEW_VIDEOS_FROM_NON_VISIBLE_CHANNELS`
> default value: `False`
Expand All @@ -764,7 +764,7 @@ Set `USE_IMPORT_VIDEO` to True to activate this application.<br>
> default value: `False`
>> Webtv mode allows you to switch POD into a webtv application removing the connection buttons for example<br>
###
###
Expand Down Expand Up @@ -864,7 +864,7 @@ Set `USE_PLAYLIST` to True to activate this application.<br>
> default value: `True`
>> Activation of promoted playlists. Allows users to use the promoted playlists.<br>
###
###
* `FILES_DIR`
> default value: `files`
Expand All @@ -879,7 +879,7 @@ Set `USE_PLAYLIST` to True to activate this application.<br>
> default value: `('jpg', 'jpeg', 'bmp', 'png', 'gif', 'tiff', 'webp')`
>> Allowed extensions for images uploaded in the file manager (must be lowercase).<br>
###
###
* `USE_NOTIFICATIONS`
> default value: `True`
Expand All @@ -906,7 +906,7 @@ Set `USE_QUIZ` to True to activate this application.<br>
> default value: `True`
>> Activation of quizzes. Allows users to create, respond and use quizzes in videos.<br>
###
###

* `ALLOW_MANUAL_RECORDING_CLAIMING`
> default value: `False`
Expand Down Expand Up @@ -968,7 +968,7 @@ Set `USE_QUIZ` to True to activate this application.<br>
> default value: `False`
>> If True, displays the video preview icon in the "Claim a recording" page.<br>
###
###

* `ACTIVE_VIDEO_COMMENT`
> default value: `False`
Expand Down Expand Up @@ -1076,7 +1076,7 @@ Set `USE_QUIZ` to True to activate this application.<br>
> default value: `False`
>>
###
###



Expand Down Expand Up @@ -1125,7 +1125,7 @@ Set `USE_QUIZ` to True to activate this application.<br>
> default value: `[]`
>>
###
###

* `ES_INDEX`
> default value: `pod`
Expand All @@ -1146,7 +1146,7 @@ Set `USE_QUIZ` to True to activate this application.<br>
> default value: `{}`
>>
###
###

Application for sending xAPI statements to an LRS.<br>
No statements persist in Pod, they are all sent to the configured LRS.<br>
Expand Down
13 changes: 8 additions & 5 deletions pod/ai_enhancement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
settings, "AI_ENHANCEMENT_CLIENT_SECRET", "mocked_secret"
)
AI_ENHANCEMENT_TO_STAFF_ONLY = getattr(settings, "AI_ENHANCEMENT_TO_STAFF_ONLY", True)
AI_ENHANCEMENT_PROXY_URL = getattr(settings, "AI_ENHANCEMENT_PROXY_URL", "")
LANG_CHOICES = getattr(
settings,
"LANG_CHOICES",
Expand Down Expand Up @@ -95,14 +96,16 @@ def send_enhancement_creation_request(
+ request.user.username
).encode("utf-8")
).hexdigest()
if AI_ENHANCEMENT_PROXY_URL:
base_url = AI_ENHANCEMENT_PROXY_URL
else:
base_url = url_scheme + "://" + get_current_site(request).domain

creation_response = aristote.create_enhancement_from_url(
url_scheme + "://" + get_current_site(request).domain + mp3_url,
base_url + mp3_url,
["video/mp3"],
end_user_identifier + "@%s" % get_current_site(request).domain,
url_scheme
+ "://"
+ get_current_site(request).domain
+ reverse("ai_enhancement:webhook"),
base_url + reverse("ai_enhancement:webhook"),
)
if creation_response:
if creation_response["status"] == "OK":
Expand Down
15 changes: 15 additions & 0 deletions pod/main/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@
},
"pod_version_end": "",
"pod_version_init": "3.7.0"
},
"AI_ENHANCEMENT_PROXY_URL": {
"default_value": "",
"description": {
"en": [
"URL of proxy server for request coming from Aristote.",
"Exemple : '<https://proxy_aristote.univ.fr>'"
],
"fr": [
"L’URL du serveur proxy pour les requêtes venant d'Aristote.",
"Exemple : '<https://proxy_aristote.univ.fr>'"
]
},
"pod_version_end": "",
"pod_version_init": "3.8.2"
}
},
"title": {
Expand Down
4 changes: 1 addition & 3 deletions pod/video/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ def get_theme_children_as_list(channel: Channel, theme_children: QuerySet) -> li
return children


def _regroup_videos_by_theme(
request, videos, page, full_path, channel, theme=None
): # noqa: C901
def _regroup_videos_by_theme(request, videos, page, full_path, channel, theme=None): # noqa: C901
"""Regroup videos by theme.
Args:
Expand Down

0 comments on commit 706901a

Please sign in to comment.