def validate_job_settings(self, job, *, _must_have_filepath=False): """Ensure that the job uses format=OPEN_EXR.""" from flamenco import exceptions job_id_str = job.get('_id', '') if job_id_str: job_id_str = f'{job_id_str} ' if job['settings'].get('cycles_num_chunks'): # End of January 2019 we changed how progressive rendering works. # Users no longer provide the number of chunks, but the maximum # number of samples per render task. raise exceptions.JobSettingError( f'Job {job_id_str}was created using outdated Blender Cloud add-on, please upgrade.' ) super().validate_job_settings(job, _must_have_filepath=_must_have_filepath) render_format = job['settings']['format'] if render_format.upper() not in {'OPEN_EXR', 'EXR'}: raise exceptions.JobSettingError( f'Job {job_id_str}must use format="OPEN_EXR", not {render_format!r}' ) # This is quite a limitation, but makes our code to predict the # filename that Blender will use a lot simpler. render_output = job['settings']['render_output'] if not render_output.endswith('######') or render_output.endswith( '#######'): raise exceptions.JobSettingError( 'Setting "render_output" must end in exactly 6 "#" marks.')
def validate_job_settings(self, job: dict, *, _must_have_filepath=False): super().validate_job_settings(job) # For compilation we really need to have the filepath setting. # Missing it is only valid when status='waiting-for-files'. if 'filepath' in job['settings']: filepath = job['settings']['filepath'] if not isinstance(filepath, str): raise exceptions.JobSettingError( f'filepath should be a string, not {filepath!r}') if not filepath.lower().endswith('.blend'): raise exceptions.JobSettingError( f'filepath should end in .blend, but is {filepath!r}') elif job['status'] != 'waiting-for-files' or _must_have_filepath: raise exceptions.JobSettingError("missing setting 'filepath'")
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 job_id = job.get('_id', '') if job_id: job_id = ' ' + job_id if len(missing) == 1: setting = 'setting' else: setting = 'settings' raise exceptions.JobSettingError('Job%s is missing required %s: %s' % (job_id, setting, ', '.join(missing)))
def validate_job_settings(self, job: dict): """Raises an exception if required settings are missing. :raises: flamenco.exceptions.JobSettingError """ if not isinstance(job, dict): raise TypeError('job should be a dict, not %s' % type(job)) job_settings = job['settings'] missing = [ key for key in self.REQUIRED_SETTINGS if key not in job_settings ] if not missing: return from flamenco import exceptions job_id = job.get('_id') or '' if job_id: job_id = ' %s' % job_id if len(missing) == 1: setting = 'setting' else: setting = 'settings' raise exceptions.JobSettingError('Job%s is missing required %s: %s' % (job_id, setting, ', '.join(missing)))
def validate_job_settings(self, job: dict, *, _must_have_filepath=False): super().validate_job_settings(job, _must_have_filepath=_must_have_filepath) if not isinstance(job, dict): raise TypeError('job should be a dict, not %s' % type(job)) fps = job['settings'].get('fps') if fps is not None and not isinstance(fps, (int, float)): raise exceptions.JobSettingError( f'Job {job["_id"]} has non-numerical "fps" setting {fps!r}') rna_overrides = job['settings'].get('rna_overrides') or [] if not all(isinstance(override, str) for override in rna_overrides): raise exceptions.JobSettingError( f'Job {job["_id"]} has non-string element in ' f'"rna_overrides" setting {rna_overrides!r}')
def validate_job_settings(self, job): super().validate_job_settings(job) if hasattr(job, 'to_dict'): job = job.to_dict() img_or_vid = job['settings']['images_or_video'] if img_or_vid != 'video': raise exceptions.JobSettingError( f'Job {job["_id"]} is rendering {img_or_vid}, but job type requires video' ) extract_audio = job['settings']['extract_audio'] if not isinstance(extract_audio, bool): raise exceptions.JobSettingError( f'Job {job["_id"]} setting "extract_audio" is {extract_audio!r},' f' expected a boolean')
def validate_job_settings(self, job): """Ensure that the job uses format=EXR.""" super().validate_job_settings(job) from flamenco import exceptions render_format = job['settings']['format'] if render_format.upper() != 'EXR': raise exceptions.JobSettingError( 'Job %s must use format="EXR", not %r' % (job['_id'], render_format)) # This is quite a limitation, but makes our code to predict the # filename that Blender will use a lot simpler. render_output = job['settings']['render_output'] if not render_output.endswith('######') or render_output.endswith( '#######'): raise exceptions.JobSettingError( 'Setting "render_output" must end in exactly 6 "#" marks.')
def validate_job_settings(self, job): super().validate_job_settings(job) if hasattr(job, 'to_dict'): job = job.to_dict() filepath = job['settings']['filepath'] if not filepath.lower().endswith('.blend'): raise exceptions.JobSettingError( f'filepath should end in .blend, but is {filepath!r}') fps = job['settings'].get('fps') if fps is not None and not isinstance(fps, (int, float)): raise exceptions.JobSettingError( f'Job {job["_id"]} has non-numerical "fps" setting {fps!r}') rna_overrides = job['settings'].get('rna_overrides') or [] if not all(isinstance(override, str) for override in rna_overrides): raise exceptions.JobSettingError( f'Job {job["_id"]} has non-string element in ' f'"rna_overrides" setting {rna_overrides!r}')