-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added blender sequencer pipeline to devops folder. closes #107 * added blender rendering pipeline to devops folder
- Loading branch information
Showing
4 changed files
with
111 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash -l | ||
#SBATCH --job-name="Blender" | ||
#SBATCH --mail-type=ALL | ||
#SBATCH --time=01:00:00 | ||
#SBATCH --nodes=25 | ||
#SBATCH --ntasks-per-core=1 | ||
#SBATCH --ntasks-per-node=24 | ||
#SBATCH --cpus-per-task=1 | ||
#SBATCH --partition=normal | ||
#SBATCH --constraint=mc | ||
#SBATCH --hint=nomultithread | ||
|
||
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK | ||
|
||
module swap gcc/8.3.0 gcc/9.3.0 | ||
module load daint-mc | ||
module load cray-python/3.8.2.1 | ||
module load PyExtensions/python3-CrayGNU-20.08 | ||
module load h5py/2.10.0-CrayGNU-20.08-python3-parallel | ||
|
||
srun python render.py $1 $2 |
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,17 @@ | ||
#!/bin/bash -l | ||
#SBATCH --job-name="Render Blender" | ||
#SBATCH --mail-type=ALL | ||
#SBATCH --mail-user=robin.deschepper93@gmail.com | ||
#SBATCH --time=00:15:00 | ||
#SBATCH --nodes=1 | ||
#SBATCH --ntasks-per-core=1 | ||
#SBATCH --ntasks-per-node=1 | ||
#SBATCH --cpus-per-task=1 | ||
#SBATCH --partition=normal | ||
#SBATCH --constraint=mc | ||
#SBATCH --hint=nomultithread | ||
|
||
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK | ||
|
||
source $HOME/load_blender.sh | ||
srun blender-2.91.0-cacd57b67a15-linux64/blender -b $1 -E CYCLES -P render.py -- $2 |
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,38 @@ | ||
import mpi4py.MPI, os, sys, subprocess | ||
|
||
rank = mpi4py.MPI.COMM_WORLD.rank + 1 | ||
size = mpi4py.MPI.COMM_WORLD.size | ||
f = sys.argv[1] | ||
o = sys.argv[2] | ||
e = "CYCLES" if len(sys.argv) < 4 or sys.argv[3] != "EEVEE" else "BLENDER_EEVEE" | ||
if o[-1] != "/": | ||
o += "/" | ||
|
||
if rank == 1: | ||
from pathlib import Path | ||
|
||
op = Path(o) | ||
print("pathinfo:", op.parts, len(op.parts), op.parts[:-1]) | ||
if len(op.parts) > 1: | ||
Path(os.path.join(*op.parts[:-1])).mkdir(parents=True, exist_ok=True) | ||
op.mkdir(exist_ok=False) | ||
|
||
print(f"Starting blender {e} job") | ||
|
||
subprocess.check_call( | ||
[ | ||
"blender-2.90.0-linux64/blender", | ||
"-b", | ||
f, | ||
"-E", | ||
e, | ||
"-o", | ||
o, | ||
"-s", | ||
rank, | ||
"-j", | ||
size, | ||
"-a", | ||
] | ||
) | ||
mpi4py.MPI.COMM_WORLD.Barrier() |
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,35 @@ | ||
import os, sys, bpy, glob | ||
|
||
scene = bpy.context.scene | ||
args = sys.argv[sys.argv.index("--") + 1 :] | ||
path = os.path.abspath(args[0]) | ||
if path[-1] != "/": | ||
path += "/" | ||
print("output path:", path) | ||
scene.render.filepath = path | ||
bpy.context.scene.render.image_settings.file_format = "FFMPEG" | ||
preset_script = os.path.join(sys.prefix, "../scripts/presets/ffmpeg/h264_in_MP4.py") | ||
exec(open(preset_script).read()) | ||
|
||
files = [f.split("/")[-1] for f in sorted(glob.glob(os.path.join(path, "*.png")))] | ||
scene.sequence_editor_create() | ||
|
||
for seq in scene.sequence_editor.sequences: | ||
if seq["created_by_bsb"]: | ||
scene.sequence_editor.sequences.remove(seq) | ||
|
||
start = int(files[0].split("/")[-1].split(".")[0]) | ||
seq = scene.sequence_editor.sequences.new_image( | ||
name="FullStrip", filepath=os.path.join(path, files[0]), channel=1, frame_start=start | ||
) | ||
seq["created_by_bsb"] = True | ||
for f in files: | ||
seq.elements.append(f) | ||
|
||
|
||
bpy.context.scene.frame_start = start | ||
bpy.context.scene.frame_end = start + len(seq.elements) - 1 | ||
bpy.context.scene.render.use_compositing = False | ||
bpy.context.scene.render.use_sequencer = True | ||
|
||
print(bpy.ops.render.render(animation=True)) |