Skip to content

Switch Plottable to a Protocol#667

Merged
exrhizo merged 3 commits into
masterfrom
garden/pytyped-protocol
Jun 20, 2025
Merged

Switch Plottable to a Protocol#667
exrhizo merged 3 commits into
masterfrom
garden/pytyped-protocol

Conversation

@exrhizo

@exrhizo exrhizo commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

TODO

  • Think about pattern for Kusto and Spanner
  • Put back in Kusto
  • Put back in Spanner
  • Add notes / readme to help future developers with typing
  • Changelog

Typecheck

Getting close to types passing, still have these mysterious cases, should fallback on the PlottableBase afiac

graphistry/plotter.py:17: error: Cannot determine type of "_edges" in base class "HeterographEmbedModuleMixin"  [misc]
graphistry/plotter.py:17: error: Cannot determine type of "_edges" in base class "DGLGraphMixin"  [misc]
graphistry/embed_utils.py:307: error: Cannot determine type of "_nodes"  [has-type]
graphistry/embed_utils.py:308: error: Cannot determine type of "_nodes"  [has-type]
graphistry/embed_utils.py:312: error: Cannot determine type of "_edges"  [has-type]
graphistry/embed_utils.py:313: error: Cannot determine type of "_edges"  [has-type]
graphistry/dgl_utils.py:258: error: Cannot determine type of "_edges"  [has-type]

@exrhizo exrhizo requested a review from lmeyerov June 18, 2025 22:46
@exrhizo exrhizo added the WIP label Jun 18, 2025
Comment thread graphistry/Engine.py Outdated
Comment thread graphistry/Plottable.py
Comment thread graphistry/Plottable.py
Comment thread graphistry/Plottable.py
Comment thread graphistry/Plottable.py
Comment thread graphistry/compute/cluster.py Outdated
Comment thread graphistry/Plottable.py
Comment thread graphistry/Plottable.py
Comment thread graphistry/embed_utils.py Outdated
Comment thread graphistry/layouts.py
Comment thread graphistry/dgl_utils.py Outdated
Comment thread graphistry/compute/python_remote.py Outdated
Comment thread graphistry/plugins/kustograph.py
Comment thread graphistry/plugins/spannergraph.py
Comment thread graphistry/pygraphistry.py Outdated
):
return Plotter().from_igraph(ig, node_attributes, edge_attributes, load_nodes, load_edges)
from_igraph.__doc__ = Plotter.from_igraph.__doc__
from_igraph.__doc__ = Plotter.from_igraph.__doc__ # type: ignore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to work, when I inspect in a notebook and it didn't work before my changes

I also notice that the docs don't show the PyGraphistry functions anyway, so it doesn't look like adding docs here is meaningful

Comment thread graphistry/pygraphistry.py
Comment thread graphistry/umap_utils.py
@exrhizo exrhizo force-pushed the garden/pytyped-protocol branch 3 times, most recently from eeb568d to 26353b9 Compare June 19, 2025 16:33
@exrhizo exrhizo marked this pull request as ready for review June 19, 2025 16:33

@exrhizo exrhizo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay put back in spanner and kusto, fixed issues and responded to comments

Comment thread graphistry/layouts.py
@exrhizo exrhizo force-pushed the garden/pytyped-protocol branch from 26353b9 to 71fec5e Compare June 19, 2025 16:40
Comment thread docs/source/api/plotter.rst
Comment thread graphistry/compute/cluster.py Outdated
logger.info('-Reusing Existing Node Featurization')
return res._node_features, res._node_target, res
# NOTE: Wasn't sure if " res._node_target is not None" ought to have been a condition for this code path
node_target = res._node_target if res._node_target is not None else pd.DataFrame()

@lmeyerov lmeyerov Jun 19, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i missed it on the first pass of these, but i wonder if for these df.empty y stubs, we need len(y.index) == len(X.index), even if no columns... i can imagine downstream code being confused on shape mismatch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as CI passes, don't need here, but more of a note for future PRs to think about

load_nodes = True, load_edges = True
):
return Plotter().from_igraph(ig, node_attributes, edge_attributes, load_nodes, load_edges)
from_igraph.__doc__ = Plotter.from_igraph.__doc__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we want to copy the doc str in cases like these? like we inherit (maybe) when it is x = x, but not when def x(): x()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(unsure where else)

@exrhizo exrhizo Jun 19, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I replied somewhere, that this didn't work before and it isn't working now, I don't know why not

is in, from_igraph.__doc__ maybe because it is static doesn't get set

actually the module level exports got have doc pages afaik

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it works for help(x) but sphinx doesn't see it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look at this more

@lmeyerov lmeyerov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved - see comments, a few things worth noting:

  • seems worth trying on rtd.org , see slack for getting you a maintainer acct
  • we still likely need to copy docstr when doing def x(): return x(), as that's a new method, vs a pointer
  • i saw some type ignores on transform unsure if more
  • CHANGELOG.md

would you like to try publishing, or should i?

exrhizo added 2 commits June 19, 2025 16:14
Hide the inherttited members for mixins
fix lint

fix lint
@exrhizo exrhizo force-pushed the garden/pytyped-protocol branch from 0bfa7ac to 2bfc6bf Compare June 19, 2025 23:14
@exrhizo exrhizo merged commit b2f297f into master Jun 20, 2025
57 checks passed
@exrhizo exrhizo deleted the garden/pytyped-protocol branch June 20, 2025 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants