Blender Parser Needs Update

Post Reply
SteffenD
Posts: 20
Joined: Fri Oct 13, 2017 12:15 pm

Blender Parser Needs Update

Post by SteffenD »

Hi there!

First of all let me thank you for giving us this awesome render manager software. We've been absolutely hammering our farm during the last months and it has been rock solid and super easy to setup! :)

Today I noticed that with the latest Blender (own builds from current master and current builds from Buildbot) the progress during rendering isn't updated any more.
This comes from a change that Brecht recently made. Instead of "... Path Tracing Tile 26/40 ..." Blender now outputs "... Rendered 26/40 Tiles..." and the parser doesn't recognize this change.
This will affect all future versions of Blender.

I guess the change should be made in ..\cgru\afanasy\python\parsers\blender_cycles.py

Thanks!
User avatar
timurhai
Site Admin
Posts: 910
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: Blender Parser Needs Update

Post by timurhai »

Hi.
Look for blender*.py files here:
https://github.com/CGRU/cgru/tree/maste ... on/parsers
May be some changes needed to adopt new version.
You can make changes and create a pull request on github to contribute to the project.
Check that render engine is recognized correctly.
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
SteffenD
Posts: 20
Joined: Fri Oct 13, 2017 12:15 pm

Re: Blender Parser Needs Update

Post by SteffenD »

Hi timurhai,

thanks for your reply. I'm not a coder at all but I managed to hack the blender_cycles.py to work with the latest master. It's kind of dirty I guess and no longer working with the official releases.
I just changed line 5 to:

Code: Select all

keypart = 'Rendered '
and line 22 to:

Code: Select all

parts = line[ptpos + len(keypart):].split(' Tiles,')[0].split('/')
Someone with a bit of Python knowledge should look over this and maybe add some magic to allow both kinds of Cycles to report the progress by accepting both, the old and the new "keypart".
SteffenD
Posts: 20
Joined: Fri Oct 13, 2017 12:15 pm

Re: Blender Parser Needs Update

Post by SteffenD »

OK, so here is a version that's working with both, the old and the new syntax of Cycles's output (Thanks to my Python wizard who had a quick look):

Code: Select all

# -*- coding: utf-8 -*-

from parsers import blender

class blender_cycles(blender.blender):
	"""Blender Cycles
	"""

	def __init__(self):
		blender.blender.__init__(self)

	def extractPercentage(self, line, left_token, right_token):
		"""Tries to extract the percentage of the current render progress in this line.
		
		Works with the old syntax:
			(...) RenderLayer | Rendered 136/510 Tiles, Denoised 96 tiles
		And the new syntax:
			(...) RenderLayer | Path Tracing Tile  136/510, Denoised 96 tiles
		
		Args:
			line (string) : blender cycles render output line to parse
			left_token (string) : separator string to extract the percentage on the left side
			right_token (string) : separator string to extract the percentage on the right side
			
		Returns:
			(bool) : True if a percentage got extracted, False if not
			(int)  : percentage value
			
		"""
		tokens = line.split(left_token)
		if len(tokens) > 1:
			tokens = tokens[1].split(right_token)	
			numbers = tokens[0].split('/')
			if len(numbers) == 2:
				try:
					part0 = int(numbers[0])
					part1 = int(numbers[1])
					if part1 > 0:
						perc = int(100 * part0 / part1)
						return True, perc
				except:
					pass
		return False, 0

	
	def do(self, data, mode):
		lines = data.split('\n')
		need_calc = False
		for line in lines:
			# deal with new syntax
			status, perc = self.extractPercentage(line, '| Rendered ', 'Tiles')
			if status:
				self.percentframe = perc
				need_calc = True
			# deal with old syntax
			status, perc = self.extractPercentage(line, '| Path Tracing Tile ', ',')
			if status:
				self.percentframe = perc
				need_calc = True
						
		if need_calc:
			self.calculate()
		blender.blender.do(self, data, mode)
User avatar
timurhai
Site Admin
Posts: 910
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: Blender Parser Needs Update

Post by timurhai »

Great!
You can make a pull request here:
https://github.com/CGRU/cgru
to share your work with others!
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
SteffenD
Posts: 20
Joined: Fri Oct 13, 2017 12:15 pm

Re: Blender Parser Needs Update

Post by SteffenD »

Sorry for taking so long but yesterday I added a pull request to github. :)
Post Reply