No More Progress Bar in Afwatch

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

No More Progress Bar in Afwatch

Post by SteffenD »

Hi there,

I noticed that Afwatch doesn't show a per-frame progress bar when rendering with Cycles any more (3.x+).
The syntax of the render log has changed to:

Code: Select all

Fra:31 Mem:1232.12M (Peak 2206.01M) | Time:02:15.69 | Remaining:02:00.57 | Mem:1139.36M, Peak:1237.26M | SHOT010_Scene, ViewLayer | Sample 2128/4096
The "blender_cycles.py" parser contains:

Code: Select all

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
So, it expects either "Rendered" or "Path Tracing Tile" to read the percentage from the log but he new (let's call it Cycles X) syntax prints "Sample". My Python knowledge isn't good enough to add the new syntax.
Can anybody help me / us?

Thanks
SteffenD
Posts: 19
Joined: Fri Oct 13, 2017 12:15 pm

Re: No More Progress Bar in Afwatch

Post by SteffenD »

OK, I fixed it (hopefully, it's more like an educated guess at copy&paste ;) ).

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, i_args):
        data = i_args['data']

        lines = data.split('\n')
        need_calc = False
        for line in lines:
            # deal with Cycles X syntax
            status, perc = self.extractPercentage(line, '| Sample ', '\n')
            if status:
                self.percentframe = perc
                need_calc = True
            # 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, i_args)
If I find some time I'll try a pull request. In the mean time you can just replace the blender_cycles.py in /cgru/afanasy/python/parsers with these changes

EDIT: I tried my best and made a pull request. I hope I didn't break anything!
SteffenD
Posts: 19
Joined: Fri Oct 13, 2017 12:15 pm

Re: No More Progress Bar in Afwatch

Post by SteffenD »

To get it running you have to update every client's blender_cycles.py and restart afrender
User avatar
timurhai
Site Admin
Posts: 840
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: No More Progress Bar in Afwatch

Post by timurhai »

Thank You!
Timur Hairulin
CGRU 3.3.0, Ubuntu 20.04 LTS, MS Windows 10 (clients only).
SteffenD
Posts: 19
Joined: Fri Oct 13, 2017 12:15 pm

Re: No More Progress Bar in Afwatch

Post by SteffenD »

Just noticed that my "fix" is only partially working. As soon as Cycles uses "Tiles" (e.g. when you render resolution is > 2048 px in a default scene or you deliberately told Cycles to use tiles e.g. to save some memory), every single tile reports its render progress in the range from 0 to max samples, i.e. in a default scene with 4096 adaptive samples and 4 tiles, Cycles counts up from 0 to 4096 four times. My primitive "logic" does not handle this case, the progress bars move back and restarts several times which might look confusing.
My Python-fu is very very limited so maybe some real coder can fix this ;)
User avatar
timurhai
Site Admin
Posts: 840
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: No More Progress Bar in Afwatch

Post by timurhai »

Hi!
Does Blender(Cycles) prints some info about tiles count before the render?
If so, parser should parse tiles number first, then caclulate total percentage using tiles count.
Timur Hairulin
CGRU 3.3.0, Ubuntu 20.04 LTS, MS Windows 10 (clients only).
SteffenD
Posts: 19
Joined: Fri Oct 13, 2017 12:15 pm

Re: No More Progress Bar in Afwatch

Post by SteffenD »

Thanks for you quick reply :)

Yes, I just found this:

Code: Select all

Fra:1 Mem:840.29M (Peak 1682.40M) | Time:00:06.59 | Remaining:18:15.69 | Mem:1147.60M, Peak:1153.71M | Scene, ViewLayer | Rendered 1/12 Tiles, Sample 80/4096
So there is info about the current tile / total number of tiles and of course the samples rendered.
User avatar
timurhai
Site Admin
Posts: 840
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: No More Progress Bar in Afwatch

Post by timurhai »

So from this string

Code: Select all

Rendered 1/12 Tiles
we can parse and store total tiles count and the current tile number.
Timur Hairulin
CGRU 3.3.0, Ubuntu 20.04 LTS, MS Windows 10 (clients only).
SteffenD
Posts: 19
Joined: Fri Oct 13, 2017 12:15 pm

Re: No More Progress Bar in Afwatch

Post by SteffenD »

Yes, but I'm an extreme coding noob :lol: and at least I can't do it.
User avatar
timurhai
Site Admin
Posts: 840
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: No More Progress Bar in Afwatch

Post by timurhai »

Look at https://docs.python.org/3/library/re.html#match-objects

Code: Select all

>>> import re
>>> re.search('Rendered (\d+)/(\d+) Tiles','Fra:1 Mem:840.29M (Peak 1682.40M) | Time:00:06.59 | Remaining:18:15.69 | Mem:1147.60M, Peak:1153.71M | Scene, ViewLayer | Rendered 1/12 Tiles, Sample 80/4096').groups()
('1', '12')
Timur Hairulin
CGRU 3.3.0, Ubuntu 20.04 LTS, MS Windows 10 (clients only).
Post Reply