Added file exclusion filter for Flamenco.

A filter like "*.abc;*.mkv;*.mov" can be used to prevent certain files
from being copied to the job storage directory. Requires a Blender that is
bundled with BAM 1.1.7 or newer.
This commit is contained in:
Sybren A. Stüvel 2017-04-21 18:15:59 +02:00
parent 8d5c97931e
commit 1e80446870
4 changed files with 38 additions and 10 deletions

View File

@ -1,5 +1,13 @@
# Blender Cloud changelog # Blender Cloud changelog
## Version 1.6.4 (2017-04-21)
- Added file exclusion filter for Flamenco. A filter like "*.abc;*.mkv;*.mov" can be
used to prevent certain files from being copied to the job storage directory.
Requires a Blender that is bundled with BAM 1.1.7 or newer.
## Version 1.6.3 (2017-03-21) ## Version 1.6.3 (2017-03-21)
- Fixed bug where local project path wasn't shown for projects only set up for Flamenco - Fixed bug where local project path wasn't shown for projects only set up for Flamenco

View File

@ -228,6 +228,11 @@ class BlenderCloudPreferences(AddonPreferences):
default='//../') default='//../')
flamenco_manager = PointerProperty(type=flamenco.FlamencoManagerGroup) flamenco_manager = PointerProperty(type=flamenco.FlamencoManagerGroup)
flamenco_exclude_filter = StringProperty(
name='File Exclude Filter',
description='Filter like "*.abc;*.mkv" to prevent certain files to be packed '
'into the output directory',
default='')
# TODO: before making Flamenco public, change the defaults to something less Institute-specific. # TODO: before making Flamenco public, change the defaults to something less Institute-specific.
# NOTE: The assumption is that the workers can also find the files in the same path. # NOTE: The assumption is that the workers can also find the files in the same path.
# This assumption is true for the Blender Institute. # This assumption is true for the Blender Institute.
@ -424,7 +429,9 @@ class BlenderCloudPreferences(AddonPreferences):
header_row = flamenco_box.row(align=True) header_row = flamenco_box.row(align=True)
header_row.label('Flamenco:', icon_value=icon('CLOUD')) header_row.label('Flamenco:', icon_value=icon('CLOUD'))
manager_box = flamenco_box.row(align=True) manager_split = flamenco_box.split(0.32, align=True)
manager_split.label('Manager:')
manager_box = manager_split.row(align=True)
if bcp.status in {'NONE', 'IDLE'}: if bcp.status in {'NONE', 'IDLE'}:
if not bcp.available_managers or not bcp.manager: if not bcp.available_managers or not bcp.manager:
@ -432,26 +439,33 @@ class BlenderCloudPreferences(AddonPreferences):
text='Find Flamenco Managers', text='Find Flamenco Managers',
icon='FILE_REFRESH') icon='FILE_REFRESH')
else: else:
manager_box.prop(bcp, 'manager', text='Manager') manager_box.prop(bcp, 'manager', text='')
manager_box.operator('flamenco.managers', manager_box.operator('flamenco.managers',
text='', text='',
icon='FILE_REFRESH') icon='FILE_REFRESH')
else: else:
manager_box.label('Fetching available managers.') manager_box.label('Fetching available managers.')
path_box = flamenco_box.row(align=True) path_split = flamenco_box.split(0.32, align=True)
path_box.prop(self, 'flamenco_job_file_path') path_split.label(text='Job File Path:')
path_box = path_split.row(align=True)
path_box.prop(self, 'flamenco_job_file_path', text='')
props = path_box.operator('flamenco.explore_file_path', text='', icon='DISK_DRIVE') props = path_box.operator('flamenco.explore_file_path', text='', icon='DISK_DRIVE')
props.path = self.flamenco_job_file_path props.path = self.flamenco_job_file_path
job_output_box = flamenco_box.column(align=True) job_output_box = flamenco_box.column(align=True)
path_box = job_output_box.row(align=True) path_split = job_output_box.split(0.32, align=True)
path_box.prop(self, 'flamenco_job_output_path') path_split.label(text='Job Output Path:')
path_box = path_split.row(align=True)
path_box.prop(self, 'flamenco_job_output_path', text='')
props = path_box.operator('flamenco.explore_file_path', text='', icon='DISK_DRIVE') props = path_box.operator('flamenco.explore_file_path', text='', icon='DISK_DRIVE')
props.path = self.flamenco_job_output_path props.path = self.flamenco_job_output_path
job_output_box.prop(self, 'flamenco_job_output_strip_components', job_output_box.prop(self, 'flamenco_exclude_filter')
text='Strip Components')
prop_split = job_output_box.split(0.32, align=True)
prop_split.label('Strip Components:')
prop_split.prop(self, 'flamenco_job_output_strip_components', text='')
from .flamenco import render_output_path from .flamenco import render_output_path

View File

@ -300,6 +300,8 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
outdir = Path(prefs.flamenco_job_file_path) / unique_dir outdir = Path(prefs.flamenco_job_file_path) / unique_dir
outfile = outdir / filepath.name outfile = outdir / filepath.name
exclusion_filter = prefs.flamenco_exclude_filter or None
try: try:
outdir.mkdir(parents=True) outdir.mkdir(parents=True)
except Exception as ex: except Exception as ex:
@ -309,7 +311,7 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
return None, [] return None, []
try: try:
missing_sources = await bam_interface.bam_copy(filepath, outfile) missing_sources = await bam_interface.bam_copy(filepath, outfile, exclusion_filter)
except bam_interface.CommandExecutionError as ex: except bam_interface.CommandExecutionError as ex:
self.log.exception('Unable to execute BAM pack') self.log.exception('Unable to execute BAM pack')
self.report({'ERROR'}, 'Unable to execute BAM pack: %s' % ex) self.report({'ERROR'}, 'Unable to execute BAM pack: %s' % ex)

View File

@ -14,7 +14,8 @@ class CommandExecutionError(Exception):
pass pass
async def bam_copy(base_blendfile: Path, target_blendfile: Path) -> typing.List[Path]: async def bam_copy(base_blendfile: Path, target_blendfile: Path,
exclusion_filter: str) -> typing.List[Path]:
"""Uses BAM to copy the given file and dependencies to the target blendfile. """Uses BAM to copy the given file and dependencies to the target blendfile.
Due to the way blendfile_pack.py is programmed/structured, we cannot import it Due to the way blendfile_pack.py is programmed/structured, we cannot import it
@ -41,6 +42,9 @@ async def bam_copy(base_blendfile: Path, target_blendfile: Path) -> typing.List[
'--mode', 'FILE', '--mode', 'FILE',
] ]
if exclusion_filter:
args.extend(['--exclude', exclusion_filter])
cmd_to_log = ' '.join(shlex.quote(s) for s in args) cmd_to_log = ' '.join(shlex.quote(s) for s in args)
log.info('Executing %s', cmd_to_log) log.info('Executing %s', cmd_to_log)