Update blender render harness (#69)

* Add blender barbershop render

* Avoid spellchecking imports

* Add more...

* Add pylint fixes

* add pylintrc

* Some fixes to running

* Update friendly name

* pylint fixes
This commit is contained in:
nharris-lmg
2023-10-18 11:28:27 -07:00
committed by GitHub
parent 5362ee9ba7
commit 0178d4c25e
6 changed files with 718 additions and 729 deletions

2
.gitignore vendored
View File

@@ -16,6 +16,8 @@ y-cruncher v0.8.2.9522.zip
csgo-benchmark-master/
csgo-benchmark-master.zip
*.blend
0001.png
*.msi
# python
__pycache__/

View File

@@ -43,13 +43,22 @@ if args.device not in VALID_DEVICES:
if os.path.isfile(ABSOLUTE_PATH) is False:
download_and_install_blender(DOWNLOAD_URL, MSI_NAME)
if os.path.isfile(ABSOLUTE_PATH) is False:
logging.error("Failed to install Blender, exiting")
sys.exit(1)
logging.info('Blender already installed')
download_barbershop_scene()
try:
logging.info('Starting benchmark!')
start_time = time.time()
score = run_blender_render(
ABSOLUTE_PATH, LOG_DIRECTORY, args.device.upper())
end_time = time.time()
logging.info('Finished rendering barbership in %s seconds', (end_time - start_time)/ 60)
if score is None:
logging.error("No duration was found in the log to use as the score")

View File

@@ -1,3 +1,4 @@
"""Blender render test script"""
import logging
import os
@@ -15,8 +16,8 @@ def download_and_install_blender(url: str, msi_name: str):
response = requests.get(url, allow_redirects=True, timeout=120)
with open(dest_path, 'wb') as file:
file.write(response.content)
subprocess.call(f"MsiExec.exe /i {dest_path} ALLUSERS=1 /qn")
result = subprocess.run([f"MsiExec.exe /i {dest_path} ALLUSERS=1"], check=True)
logging.info(result)
def download_barbershop_scene():
"""Downloads blender scene to render"""
@@ -24,14 +25,13 @@ def download_barbershop_scene():
download_url = f"https://svn.blender.org/svnroot/bf-blender/trunk/lib/benchmarks/cycles/barbershop_interior/{blend_file_name}"
root_dir = os.path.dirname(os.path.realpath(__file__))
dest_path = os.path.join(root_dir, blend_file_name)
if os.path.isfile(dest_path) is not True:
logging.info("Downloading barbershop scene")
response = requests.get(
download_url, allow_redirects=True, timeout=120)
with open(dest_path, 'wb') as file:
file.write(response.content)
logging.info('Barbershop already downloaded')
def run_blender_render(executable_path: str, log_directory: str, device: str) -> str:
"""Execute the blender render of barbershop, returns the duration as string"""
@@ -39,7 +39,7 @@ def run_blender_render(executable_path: str, log_directory: str, device: str) ->
root_dir = os.path.dirname(os.path.realpath(__file__))
blend_path = os.path.join(root_dir, "barbershop_interior.blend")
cmd_line = f"{executable_path} -b -E CYCLES -y {blend_path} -f 1 -- --cycles-device {device} --cycles-print-stats"
with open(blend_log, 'w', encoding="utf-8") as f_obj:
with open(blend_log,'w' , encoding="utf-8") as f_obj:
subprocess.run(cmd_line, stdout=f_obj, text=True, check=True)
# example: Time: 02:59.57 (Saving: 00:00.16)

View File

@@ -1,4 +1,4 @@
friendly_name: "Blender Render"
friendly_name: "Blender Render 3.6.4"
executable: "blender.py"
process_name: "blender.exe"
disable_presentmon: true

1422
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@ authors = []
[tool.poetry.dependencies]
python = "^3.10"
pywinauto = "0.6.8"
pyyaml = "6.0"
pyyaml = "6.0.1"
python-dotenv = "0.20.0"
pyfiglet = "0.8.post1"
PyAutoGUI = "^0.9.53"