Skip to content

Check if self.cv is None in MeshMeta #109

@jasper-tms

Description

@jasper-tms

I had downloaded some meshes previously and I wanted to load them while on the airplane yesterday, and I struggled to figure out how to get MeshMeta.mesh(seg_id=blah) to give me the mesh. I was getting this error:

from meshparty import trimesh_io
mm = trimesh_io.MeshMeta(disk_cache_path='.')
mesh = mm.mesh(seg_id=720575941428754936)  # 720575941428754936.h5 exists in current folder


--> 699     if not isinstance(self.cv.mesh, ShardedMultiLevelPrecomputedMeshSource):
AttributeError: 'NoneType' object has no attribute 'mesh'

So clearly it didn't like that I hadn't set cv_path. I tried setting cv_path to some dummy path gs://foobar but it understandably tried querying that bucket and failed. Ultimately I figured out I could change

if not isinstance(self.cv.mesh, ShardedMultiLevelPrecomputedMeshSource):

to

        if self.cv is None or not isinstance(self.cv.mesh,
                                             ShardedMultiLevelPrecomputedMeshSource):

to get the code snippet above to work. This change is also necessary to get the more direct mm.mesh(filename='720575941428754936.h5') to work when there's no cv_path.

I would imagine this check of self.cv is None needs to be added a few more places to get all use cases to work, but I stopped at this one because it's all I needed, and I thought I'd contribute at least this one change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions