Skip to content
Snippets Groups Projects
Commit bd20bf47 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Server: some job setting validation

parent 975c6fa7
No related branches found
No related tags found
No related merge requests found
"""Flamenco-specific exceptions."""
class FlamencoException(Exception):
"""Base exception for all Flamenco-specific exceptions."""
class JobSettingError(FlamencoException):
"""Raised when a job's settings contains errors."""
......@@ -7,9 +7,32 @@ class AbstractJobCompiler(object):
task_manager = attr.ib(cmp=False, hash=False)
_log = attrs_extra.log('%s.AbstractJobType' % __name__)
REQUIRED_SETTINGS = []
def compile(self, job):
"""Compiles the job into a list of tasks.
Calls self.task_manager.create_task(...) to create the task in the database.
"""
raise NotImplementedError()
def validate_job_settings(self, job):
"""Raises an exception if required settings are missing.
:raises: flamenco.exceptions.JobSettingError
"""
from pillarsdk import Resource
job_settings = job['settings']
if isinstance(job_settings, Resource):
job_settings = job_settings.to_dict()
missing = [key for key in self.REQUIRED_SETTINGS
if key not in job_settings]
if not missing:
return
from flamenco import exceptions
raise exceptions.JobSettingError(
u'Job %s is missing required settings: %s' % (job[u'_id'], u', '.join(missing)))
from pillar import attrs_extra
from .abstract_compiler import AbstractJobCompiler
from . import commands, register_compiler
......@@ -5,9 +7,13 @@ from . import commands, register_compiler
@register_compiler('blender-render')
class BlenderRender(AbstractJobCompiler):
"""Basic Blender render job."""
_log = attrs_extra.log('%s.BlenderRender' % __name__)
REQUIRED_SETTINGS = ('blender_cmd', 'filepath', 'render_output', 'frames', 'chunk_size')
def compile(self, job):
self._log.info('Compiling job %s', job['_id'])
self.validate_job_settings(job)
move_existing_task_id = self._make_move_out_of_way_task(job)
task_count = 1 + self._make_render_tasks(job, move_existing_task_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment