Add-on: Skip BAT-packing when file already in shared storage
When the to-be-submitted blend file is already stored in the shared storage, and Shaman is disabled, the add-on now skips BAT-packing it. Instead, the file is copied to `filename.flamenco.blend` and the path is submitted as-is.
This commit is contained in:
parent
a6e3442aa0
commit
344a62f37b
@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Optional, Union
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from .job_types_propgroup import JobTypePropertyGroup
|
from .job_types_propgroup import JobTypePropertyGroup
|
||||||
|
from . import preferences
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .manager import ApiClient as _ApiClient
|
from .manager import ApiClient as _ApiClient
|
||||||
@ -84,3 +85,22 @@ def submit_job(job: _SubmittedJob, api_client: _ApiClient) -> _Job:
|
|||||||
print("Job submitted: %s (%s)" % (response.name, response.id))
|
print("Job submitted: %s (%s)" % (response.name, response.id))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def is_file_inside_job_storage(context: bpy.types.Context, blendfile: Path) -> bool:
|
||||||
|
"""Check whether current blend file is inside the storage path.
|
||||||
|
|
||||||
|
:return: True when the current blend file is inside the Flamenco job storage
|
||||||
|
directory already. In this case it won't be BAT-packed, as it's assumed
|
||||||
|
the job storage dir is accessible by the workers already.
|
||||||
|
"""
|
||||||
|
|
||||||
|
blendfile = blendfile.absolute().resolve()
|
||||||
|
|
||||||
|
prefs = preferences.get(context)
|
||||||
|
job_storage = Path(prefs.job_storage).absolute().resolve()
|
||||||
|
try:
|
||||||
|
blendfile.relative_to(job_storage)
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
@ -170,7 +170,7 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator):
|
|||||||
self.report({"ERROR"}, "Unable to create job")
|
self.report({"ERROR"}, "Unable to create job")
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
return self._bat_pack(context, filepath)
|
return self._submit_files(context, filepath)
|
||||||
|
|
||||||
def modal(self, context: bpy.types.Context, event: bpy.types.Event) -> set[str]:
|
def modal(self, context: bpy.types.Context, event: bpy.types.Event) -> set[str]:
|
||||||
# This function is called for TIMER events to poll the BAT pack thread.
|
# This function is called for TIMER events to poll the BAT pack thread.
|
||||||
@ -225,7 +225,9 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator):
|
|||||||
|
|
||||||
return filepath
|
return filepath
|
||||||
|
|
||||||
def _bat_pack(self, context: bpy.types.Context, blendfile: Path) -> set[str]:
|
def _submit_files(self, context: bpy.types.Context, blendfile: Path) -> set[str]:
|
||||||
|
"""Ensure that the files are somewhere in the shared storage."""
|
||||||
|
|
||||||
from .bat import interface as bat_interface
|
from .bat import interface as bat_interface
|
||||||
|
|
||||||
if bat_interface.is_packing():
|
if bat_interface.is_packing():
|
||||||
@ -239,6 +241,8 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator):
|
|||||||
# see _on_bat_pack_msg() below.
|
# see _on_bat_pack_msg() below.
|
||||||
self.blendfile_on_farm = None
|
self.blendfile_on_farm = None
|
||||||
self._bat_pack_shaman(context, blendfile)
|
self._bat_pack_shaman(context, blendfile)
|
||||||
|
elif job_submission.is_file_inside_job_storage(context, blendfile):
|
||||||
|
self._use_blendfile_directly(context, blendfile)
|
||||||
else:
|
else:
|
||||||
self.blendfile_on_farm = self._bat_pack_filesystem(context, blendfile)
|
self.blendfile_on_farm = self._bat_pack_filesystem(context, blendfile)
|
||||||
|
|
||||||
@ -352,6 +356,16 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator):
|
|||||||
|
|
||||||
return {"RUNNING_MODAL"}
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
def _use_blendfile_directly(self, context: bpy.types.Context, blendfile: Path) -> None:
|
||||||
|
# The temporary '.flamenco.blend' file should not be deleted, as it
|
||||||
|
# will be used directly by the render job.
|
||||||
|
self.temp_blendfile = None
|
||||||
|
|
||||||
|
# The blend file is contained in the job storage path, no need to
|
||||||
|
# copy anything.
|
||||||
|
self.blendfile_on_farm = PurePosixPath(blendfile.absolute().resolve().as_posix())
|
||||||
|
self._submit_job(context)
|
||||||
|
|
||||||
def _submit_job(self, context: bpy.types.Context) -> None:
|
def _submit_job(self, context: bpy.types.Context) -> None:
|
||||||
"""Use the Flamenco API to submit the new Job."""
|
"""Use the Flamenco API to submit the new Job."""
|
||||||
assert self.job is not None
|
assert self.job is not None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user