Workflow wrt hip, render and cache folders and filenames

   503   1   1
User Avatar
Member
11 posts
Joined: May 2010
Offline
I have a question regarding tips for folders and filenames for hip, render and cache.

Let's say I'm working on a project called `MyProject`. I like to increment hip versions so I have `MyProject.001.hip`, `MyProject.002.hip`, `MyProject.003.hip` etc.

I might have multiple simulations in a hip, and for each one I might try different settings and versions, and then cache and render them.

What I'd like to be able to do is: when I view any render, I'd like to be able to go back to see those exact settings.

So I include `$HIPNAME` and `$ACTIVETAKE` and `cache version(s)` in my cache and render paths.

The problem is, if I include the full versioned `$HIPNAME` in the cache path, when I increment the version of the HIP, the cache cannot be found anymore (because the cache might be called `cache/MyProject.017/fluid/v4/*` while the new HIP v18 will be looking
for `cache/MyProject.018/fluid/v4/*`).

If I exclude the HIP version from the cache path, then I can increment HIP version, but then I don't have a way of recalling those exact settings which led to that cache or render.

I tried using the Houdini Take system, and the Preset system, but both get very messy very quickly. Especially when I'm working with custom OTLs which I'm continuously updating, and adding new features and parameters to.

The only solution I've found so far, which actually achieves what I want - but is ridiculously cumbersome - is to:
1. Use the cache versioning system, and NOT include the full hipname in the path, but just use the base hipname without version. e.g. `cache/MyProject/fluid/v4`, `cache/MyProject/particles/v8` as opposed to `cache/MyProject.018/fluid/v4`, `cache/MyProject.018/particles/v8` etc.
2. As soon as I cache a simulation, increment the `$HIPNAME` version number
3. Log in separate spreadsheet to keep track of which version of which simulation is in which $HIPNAME with version. E.g. `fluid.v4: MyProject.011.hip`, `particles.v8: MyProject.018.hip` etc.

This feels like a problem many others might have encountered, and solved more elegantly. I'm open to suggestions!
User Avatar
Member
11 posts
Joined: May 2010
Offline
I ended up writing a little HDA to manage this. It browses and lists all subfolders of a specified cache root folder, and constructs a path to be used by other nodes (such as FileCache, Render etc).

Details at https://github.com/memo/msa_pathversioner [github.com]



def listdir(path):
    '''list only directories in a path'''
    return [_ for _ in os.listdir(path) if os.path.isdir(os.path.join(path, _))]
    
    
def get_hipname():
    '''return current HIP name'''
    return hou.expandString('$HIPNAME')
    
    
def menu_from_list(l):
    '''
    return a list suitable for displaying as a dropdown menu
    i.e. each item is listed twice 
    '''
    return [x for x in l for _ in (0, 1)]

    
    
def get_path(node):
    '''construct the path to search'''
    root_folder = node.parm('root_folder').eval()
    name = node.parm('name').eval()
    path = os.path.join(root_folder, name)
    return path

    
def menu_from_dirlist(node):
    '''
    given a root directory path,
    return folder contents suitable for displaying as a dropdown menu,
    '''
    path = get_path(node)
    try:
        l = menu_from_list(listdir(path))
    except:
        l = []
        pass
        
    hipname = get_hipname()
    if hipname in l:    # if current hipname is in the list, add info that it's current
        # add to next index, because first occurence is value, second occurence is label
        l[l.index(hipname) + 1] += ' (Current HIP file)'
    else: # if not found, add it to the top as current
        l = ['$HIPNAME', f'{hipname} (Current HIP file, no folder available)'] + l
    update(node) # update UI
    return l
    
def update_env():
    hou.putenv('HIPBASENAME', get_hipname().split('.')[0])

    
def update(node):
    '''update UI'''
    update_env()
    path = get_path(node)
    msg = path + '\n'
    if not os.path.exists(path) or not os.path.isdir(path):
        msg += 'Directory not found\n'
    else:
        l = []
        try:
            l = listdir(path)
        except:
            pass
        msg += f'{len(l)} entries found:\n'
        msg += '\n'.join(l)
        msg += '\n'
    msg += '------\n'
    msg += f'Current HIP: {get_hipname()}\n'
    node.parm('info').set(msg)
Edited by memo - Sept. 5, 2023 11:46:40
  • Quick Links