This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support version 2 of Flamenco Manager variables
A restructuring of the Manager variables was necessary to allow different values for users and workers. Until now both had the same paths, which is fine when both are located in the same studio. However, when deploying workers on a cloud infrastructure (Azure, AWS, etc.) this becomes cumbersome. When a Manager does not declare a `settings_version`, version 1 is assumed. This commit introduces version 2. The naming 'path replacement variable' was confusing people. Now each variable has a mandatory property 'direction' that has one of the following values: - `"one"`: unidirectional variable. `${VARIABLENAME}` is replaced by the variable value for the appropriate platform. This used to be the 'variable'. - `"two"`: bidirection variable. As described above, but also the value is replaced by `${VARIABLENAME}` by the Blender Cloud add-on when sending a job to Flamenco Server. This used to be the 'path replacement variable'. Each variable now has a setting 'audience', which can be either 'workers' or 'users' to be applied only to those, or 'all' when the value is the same for both.
- Loading branch information
1 parent
aaeb6ee
commit 6fc2d65
Showing
13 changed files
with
344 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import typing | ||
|
||
import flask | ||
import werkzeug.exceptions as wz_exceptions | ||
|
||
|
||
def requested_by_version() -> typing.Optional[typing.Tuple[int, int, int]]: | ||
"""Determine the version of the Blender Cloud add-on. | ||
The version of the Blender Cloud add-on performing the current request is | ||
returned as (major, minor, micro) tuple. If the current request did not | ||
come from the Blender Cloud add-on (as recognised by the | ||
'Blender-Cloud-Addon' HTTP header), return None. | ||
""" | ||
addon_version = flask.request.headers.get('Blender-Cloud-Addon') | ||
if not addon_version: | ||
return None | ||
|
||
try: | ||
parts = tuple(int(part) for part in addon_version.split('.')) | ||
except ValueError: | ||
raise wz_exceptions.BadRequest('Invalid Blender-Cloud-Addon header') | ||
|
||
if 2 <= len(parts) < 4: | ||
return (parts + (0, 0))[:3] | ||
|
||
raise wz_exceptions.BadRequest('Invalid Blender-Cloud-Addon header') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
| {% macro variables_view(manager) -%} | ||
| {% if manager.settings_version < 2 %} | ||
//- ---------- SETTINGS version 1 -------------- | ||
| {% if manager.variables %} | ||
h4 Variables | ||
| {% for var_key, var_values in manager.variables.items() %} | ||
.table.item-properties | ||
.table-body(title='Unable to edit, set by Manager') | ||
| {% for v in var_values %} | ||
.table-row.properties-variables | ||
.table-cell.variable-name {% if loop.first %}{{ var_key }}{% endif %} | ||
.table-cell.variable-key {{ v }} | ||
.table-cell.variable-value {{ var_values[v] }} | ||
| {% endfor %} | ||
| {% endfor %} | ||
| {% endif %} | ||
|
||
| {% if manager.path_replacement %} | ||
h4 Path Replacement Variables | ||
| {% for pathrep_key, pathrep_values in manager.path_replacement.items() %} | ||
.table.item-properties | ||
.table-body(title='Unable to edit, set by Manager') | ||
| {% for v in pathrep_values %} | ||
.table-row.properties-path-replacement | ||
.table-cell.variable-name {% if loop.first %}{{ pathrep_key }}{% endif %} | ||
.table-cell.variable-key {{ v }} | ||
.table-cell.variable-value {{ pathrep_values[v] }} | ||
| {% endfor %} | ||
| {% endfor %} | ||
| {% endif %} | ||
|
||
//- ---------- SETTINGS version 2 -------------- | ||
| {% elif manager.settings_version == 2 %} | ||
| {% if manager.variables %} | ||
h4 Variables | ||
|
||
.table.item-properties | ||
.table-body(title='Unable to edit, set by Manager') | ||
| {% for var_key, var_definition in manager.variables.items() %} | ||
| {% set evenodd = loop.cycle('odd', 'even') %} | ||
| {% for v in var_definition['values'] %} | ||
.table-row.properties-variables(class="{{ evenodd }}") | ||
.table-cell.variable-name {% if loop.first %}{{ var_key }}{% endif %} | ||
.table-cell.variable-direction(title="{% if var_definition.direction == 'twoway' %}Two-way, values are replaced by variables and vice versa{%else%}One-way, variables are replaced with values{%endif%}") | ||
| {% if loop.first %}{% if var_definition.direction == "twoway" %}⇄{% else %}→{% endif %}{% endif %} | ||
.table-cell.variable-value {{ v.value }} | ||
.table-cell.variable-platform {{ v.platform }} {{ v.platforms|join(' ') }} | ||
.table-cell.variable-audience {{ v.audience }} | ||
| {% endfor %} | ||
| {% endfor %} | ||
|
||
|
||
| {% endif %} | ||
|
||
| {% else %} | ||
h4 Unsupported version | ||
p This manager has settings version {{ manager.settings_version }}, which we don't support. | ||
| {% endif %} | ||
| {%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.