Skip to content

Template Generation #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ stages:
buffer_frames: 1-90
force_update: false
render_output: 'imgs/buffer/'
engine: CYCLES # todo: figure out how to do EEVEE
engine: EEVEE # todo: figure out how to do EEVEE
blend_file: scene.blend
render_format: PNG
blender_flags: ''
Expand Down Expand Up @@ -47,9 +47,9 @@ model_output_format: '{model}_{angle}_{map}'

# experimental below, do not alter
docker:
image: tennisgazelle/blender-pipeline:latest
image: tennisgazelle/blender-pipeline-gpu:latest
#render_cmd: docker run --rm -v {cwd}/blender/:/blender/ -v {cwd}/imgs:/imgs ikester/blender blender/{blend_file} -o {output_location} -E {engine} -F {format} -t 8 {flags}
render_cmd: docker run --rm -v {cwd}/blender/:/blender/ -v {cwd}/imgs:/imgs tennisgazelle/blender-pipeline:latest blender/{blend_file} -E {engine} -F {format} -t 8 {flags}
render_cmd: docker run --rm -v {cwd}/blender/:/blender/ -v {cwd}/imgs:/imgs tennisgazelle/blender-pipeline-gpu:latest blender/{blend_file} -E {engine} -F {format} -t 8 {flags}
# python_cmd: docker run --rm -v ${cwd}/blender/:/blender/ -v ${cwd}/scripts:/scripts -v ${cwd}/config.yaml:/config.yaml tennisgazelle/blender-pipeline:latest blender/scene.blend --python scripts/get_path.py
var_defaults:
engine: CYCLES
Expand Down
45 changes: 45 additions & 0 deletions scripts/Dockerfile.gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ARG IMAGE_NAME
# FROM ${IMAGE_NAME}:11.3.0-runtime-ubuntu20.04
# LABEL maintainer "NVIDIA CORPORATION <cudatools@nvidia.com>"
# ENV CUDNN_VERSION 8.2.0.53
# LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"
# RUN apt-get update && apt-get install -y --no-install-recommends \
# libcudnn8=$CUDNN_VERSION-1+cuda11.3 \
# && apt-mark hold libcudnn8 && \
# rm -rf /var/lib/apt/lists/*

FROM nvidia/cuda:10.0-devel-ubuntu18.04

LABEL authors="Daniel Lopez <daniellopez@nevada.unr.edu>"

# set up deps for blender
RUN apt-get update && \
apt-get install -y \
curl \
libfreetype6 \
libglu1-mesa \
libxi6 \
libxrender1 \
xz-utils && \
apt-get -y autoremove

# Download blender
ENV BLENDER_MAJOR 2.82
ENV BLENDER_VERSION 2.82a
ENV BLENDER_URL https://download.blender.org/release/Blender${BLENDER_MAJOR}/blender-${BLENDER_VERSION}-linux64.tar.xz

RUN curl -L ${BLENDER_URL} | tar -xJ -C /usr/local/ \
&& mv /usr/local/blender-${BLENDER_VERSION}-linux64 /usr/local/blender

# run the pip install for the bundled python
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& ls /usr/local/blender/${BLENDER_MAJOR}/python/lib \
&& /usr/local/blender/${BLENDER_MAJOR}/python/bin/python3.7m get-pip.py \
&& /usr/local/blender/${BLENDER_MAJOR}/python/bin/python3.7m -m pip install pyyaml yamale --user

# Get the config common library near the blender executable
COPY common.py /usr/local/blender/${BLENDER_MAJOR}/python/lib/python3.7/

VOLUME /media
WORKDIR /
ENTRYPOINT ["/usr/local/blender/blender", "-b"]
39 changes: 39 additions & 0 deletions scripts/compare_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import filecmp
import yaml
import json

config = {}
sandbox_header_dir = 'sandbox/'

def load_files_to_gen():
with open ('template_files.yaml', 'r') as template_files:
config['template_files'] = yaml.load(template_files)

print(json.dumps(config, indent=3))


## start here:

import argparse

parser = argparse.ArgumentParser(description='Generate a template in the indicated directory')
parser.add_argument('--template', metavar='-t', type=str, required=True,
help='the generated template dir')
parser.add_argument('--yours', metavar='-y', type=str, required=True,
help='your project root dir')
args = parser.parse_args()

load_files_to_gen('sandbox/')


# preview of file diffing
for file in config['template_files']:
if 'blend' in file:
continue

print('checking for differences in {}{}'.format(sandbox_header_dir, file))
areEqual = filecmp.cmp(file, '{}{}'.format(sandbox_header_dir, file))
if areEqual:
print(' -- good')
else:
print(' -- not equal')
36 changes: 36 additions & 0 deletions scripts/generate_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import yaml
import json
import os
import shutil

config = {}
def load_files_to_gen():
with open ('template_files.yaml', 'r') as template_files:
config['template_files'] = yaml.load(template_files)

print(json.dumps(config, indent=3))

def make_files(sandbox_header_dir):
print('refreshing sandbox/')
shutil.rmtree(sandbox_header_dir)
os.mkdir(sandbox_header_dir)
os.mkdir(sandbox_header_dir + 'blender/')
os.mkdir(sandbox_header_dir + 'scripts/')
os.mkdir(sandbox_header_dir + 'logs/')

for file in config['template_files']:
shutil.copy(file, '{}{}'.format(sandbox_header_dir, file))
print('file created in sandbox: {}{}'.format(sandbox_header_dir, file))

## start here:

import argparse

parser = argparse.ArgumentParser(description='Generate a template in the indicated directory')
parser.add_argument('out', metavar='o', type=str,
help='the output dir location (will create it if not there already)')

args = parser.parse_args()

load_files_to_gen()
make_files(args.out + "/")
5 changes: 5 additions & 0 deletions template_files.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- blender/scene.blend
- blender/edit.blend
- scripts/render.py
- config.yaml
- Makefile