Skip to content

Commit

Permalink
minor wording and cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Christian López Barrón <[email protected]>
  • Loading branch information
chrizzFTD committed Dec 8, 2024
1 parent d080bb9 commit 4307720
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
9 changes: 4 additions & 5 deletions grill/cook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ def define_taxon(stage: Usd.Stage, name: str, *, references: tuple[Usd.Prim] = t
return prim


def itaxa(stage):
def itaxa(stage: Usd.Stage) -> typing.Generator[Usd.Prim]:
"""For the given stage, iterate existing taxa under the taxonomy hierarchy."""
return filter(
lambda prim: prim.GetAssetInfoByKey(_ASSETINFO_TAXA_KEY),
_usd.iprims(stage, root_paths={_TAXONOMY_ROOT_PATH}, traverse_predicate=Usd.PrimAllPrimsPredicate)
Expand Down Expand Up @@ -532,10 +533,8 @@ def _inherit_or_specialize_unit(method, context_unit):


@functools.singledispatch
def taxonomy_graph(prims, url_id_prefix):
"""
prims
"""
def taxonomy_graph(prims: Usd.Prim, url_id_prefix) -> nx.DiGraph:
"""Get the hierarchical taxonomy representation of the given taxa prims."""
graph = nx.DiGraph(tooltip="Taxonomy Graph")
graph.graph.update(
graph={'rankdir': 'LR'},
Expand Down
6 changes: 3 additions & 3 deletions grill/views/_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Please make sure graphviz is installed and 'dot' available on the system's PATH environment variable.
For more details on installing graphviz, visit https://pygraphviz.github.io/documentation/stable/install.html
For more details on installing graphviz, visit https://graphviz.org/download/ or https://grill.readthedocs.io/en/latest/install.html#conda-environment-example
"""


Expand Down Expand Up @@ -90,7 +90,7 @@ def _dot_2_svg(sourcepath):

class _Node(QtWidgets.QGraphicsTextItem):

# TODO: see if we can remove 'label', since we are already processing the graphviz one here, it might be cheaper to have label created only when we need it
# Note: keep 'label' as an argument to use as much as possible as-is for clients to provide their own HTML style
def __init__(self, parent=None, label="", color="", fillcolor="", plugs: tuple = (), visible=True):
super().__init__(parent)
self._edges = []
Expand Down Expand Up @@ -599,7 +599,7 @@ def _load_graph(self, graph):
self.scene().addItem(text_item)
return

try: # exit early if pygraphviz is not installed, needed for positions
try: # exit early if pydot is not installed, needed for positions
positions = drawing.nx_pydot.graphviz_layout(graph, prog='dot')
except ImportError as exc:
message = str(exc)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_cook.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def test_fetch_stage(self):
usd_opened = str(names.UsdAsset.get_anonymous(item='usd_opened'))
Sdf.Layer.CreateNew(str(repo_path / usd_opened))

with self.assertRaises(Tf.ErrorException):
with self.assertRaisesRegex(Tf.ErrorException, "Failed to open layer"):
# no resolver context, so unable to open stage
Usd.Stage.Open(usd_opened)

with Ar.ResolverContextBinder(resolver_ctx):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,14 @@ def test_scenegraph_composition(self):
widget._layers.table.selectAll()
self.assertEqual(5, widget._layers.model.rowCount())
self.assertEqual(1, widget._prims.model.rowCount())
# add_dll_directory only on Windows
os.add_dll_directory = lambda path: print(f"Added {path}") if not hasattr(os, "add_dll_directory") else os.add_dll_directory

_core._which.cache_clear()
with mock.patch("grill.views.description._which") as patch: # simulate dot is not in the environment
patch.return_value = None
widget._graph_view.view([0,1])

_core._which.cache_clear()
with mock.patch("grill.views.description.nx.nx_agraph.write_dot") as patch: # simulate pygraphviz is not installed
with mock.patch("grill.views.description.nx.nx_agraph.write_dot") as patch: # simulate pydot not installed
patch.side_effect = ImportError
widget._graph_view.view([0])

Expand Down

0 comments on commit 4307720

Please sign in to comment.