blocks2assets: debug filepath on reading unsupported blocks #92885

Merged
Sybren A. Stüvel merged 2 commits from oliverpool/blender-asset-tracer:blocks2assets_print_filepath into main 2023-12-18 17:57:44 +01:00
Contributor

To ease support of other data blocks in the future, this PR logs the filepath to the debug message on unsupported block types (if present).

To test this PR, you need to have a blend file with an unsupported block type, which contains a filepath property.

For instance VDB volumes of scene_with_vdb_and_fluid_cache.zip are not supported yet (PR pending in #92884). As long as VDB are not supported by BAT, the log will read:

DEBUG:No expander implemented for block type 'VO'
DEBUG:No reader implemented for block type 'VO' (filepath='//cache_vdb/CCup_ws_01/fluid_data_0002.vdb')

When rendering a scene prepared by BAT, having the filepath of the block in the log will help a lot, to know what kind of asset could not be read.

To ease support of other data blocks in the future, this PR logs the filepath to the debug message on unsupported block types (if present). To test this PR, you need to have a blend file with an unsupported block type, which contains a `filepath` property. For instance VDB volumes of [scene_with_vdb_and_fluid_cache.zip](https://projects.blender.org/attachments/a1bdd002-d684-4709-bb0a-744590606413) are not supported yet (PR pending in #92884). As long as VDB are not supported by BAT, the log will read: ``` DEBUG:No expander implemented for block type 'VO' DEBUG:No reader implemented for block type 'VO' (filepath='//cache_vdb/CCup_ws_01/fluid_data_0002.vdb') ``` When rendering a scene prepared by BAT, having the filepath of the block in the log will help a lot, to know what kind of asset could not be read.
Olivier C added 1 commit 2023-11-06 09:58:18 +01:00

Please update the PR description, so that it actually describes what the PR is for.

Please update the PR description, so that it actually describes what the PR is for.
Sybren A. Stüvel requested changes 2023-12-14 10:44:12 +01:00
Sybren A. Stüvel left a comment
Member

The code is getting quite nested now, which I think can easily be resolved. Also I would suggest using %r for printing the filepath, rather than %s, such that trailing spaces and empty strings are recognisable. Finally, it would help to know that the 2nd string that's printed is actually the filepath property.

This would combine into something like:

except KeyError:
    if block.code in _warned_about_types:
        return

    blocktype = block.code.decode()
    filepath = block.get(b"filepath", "", as_str=True)
    if filepath:
        log.debug(
            "No reader implemented for block type %r (filepath=%r)",
            blocktype,
            filepath,
        )
    else:
        log.debug("No reader implemented for block type %r", blocktype)
    _warned_about_types.add(block.code)
    return

Could you also add some instructions to the PR description on how to test this particular branch of the code? That'll make testing & accepting this PR a lot easier.

The code is getting quite nested now, which I think can easily be resolved. Also I would suggest using `%r` for printing the filepath, rather than `%s`, such that trailing spaces and empty strings are recognisable. Finally, it would help to know that the 2nd string that's printed is actually the `filepath` property. This would combine into something like: ```python except KeyError: if block.code in _warned_about_types: return blocktype = block.code.decode() filepath = block.get(b"filepath", "", as_str=True) if filepath: log.debug( "No reader implemented for block type %r (filepath=%r)", blocktype, filepath, ) else: log.debug("No reader implemented for block type %r", blocktype) _warned_about_types.add(block.code) return ``` Could you also add some instructions to the PR description on how to test this particular branch of the code? That'll make testing & accepting this PR a lot easier.
Olivier C force-pushed blocks2assets_print_filepath from 5088f6d569 to 589dbd6752 2023-12-15 10:05:12 +01:00 Compare
Author
Contributor

I implemented your suggestion and rebased on top of main (hence the force-push)

I implemented your suggestion and rebased on top of main (hence the force-push)

Could you also add some instructions to the PR description on how to test this particular branch of the code? That'll make testing & accepting this PR a lot easier.

This one is still missing, though.

> Could you also add some instructions to the PR description on how to test this particular branch of the code? That'll make testing & accepting this PR a lot easier. This one is still missing, though.
Author
Contributor

This one is still missing, though.

Sorry, I overlooked this part of your comment.

You can use the .blend file of #92884: scene_with_vdb_and_fluid_cache.zip, the log will output:

DEBUG:No expander implemented for block type 'VO'
DEBUG:No reader implemented for block type 'VO' (filepath='//cache_vdb/CCup_ws_01/fluid_data_0002.vdb')
> This one is still missing, though. Sorry, I overlooked this part of your comment. You can use the .blend file of #92884: [scene_with_vdb_and_fluid_cache.zip](https://projects.blender.org/attachments/a1bdd002-d684-4709-bb0a-744590606413), the log will output: ``` DEBUG:No expander implemented for block type 'VO' DEBUG:No reader implemented for block type 'VO' (filepath='//cache_vdb/CCup_ws_01/fluid_data_0002.vdb') ```
Olivier C requested review from Sybren A. Stüvel 2023-12-15 17:28:42 +01:00
Sybren A. Stüvel merged commit 2099827554 into main 2023-12-18 17:57:44 +01:00
Sybren A. Stüvel deleted branch blocks2assets_print_filepath 2023-12-18 17:57:53 +01:00

Looks good, thanks!

Looks good, thanks!
Sign in to join this conversation.
No description provided.