Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for google spanner graph #622

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

DataBoyTX
Copy link
Contributor

TODO(tcook)

from typing import Any
from google.cloud.spanner_dbapi.connection import connect
from google.cloud.spanner_v1.data_types import JsonObject
from google.cloud.spanner_v1 import KeySet
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be an optional dep in setup.py:

base_extras_light = {

moving to dynamic imports may help, not sure

@@ -0,0 +1,287 @@
import os
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -38,6 +38,7 @@
from .arrow_uploader import ArrowUploader
from .nodexlistry import NodeXLGraphistry
from .tigeristry import Tigeristry
from .database_clients.spannergraph import spannergraph
Copy link
Contributor

Choose a reason for hiding this comment

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

this top-level import would force all users to import, so we need to be lazy/dynamic somewhere

get_schema: Retrieve the schema of the database.
validate_data: Validate input data for queries or updates.
dump_config: Returns the configuration of the spannergraph instance.
"""
Copy link
Contributor

@lmeyerov lmeyerov Dec 24, 2024

Choose a reason for hiding this comment

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

see the docs conventions in more modern code in pygraphistry, this is important for sphinx/readthedocs . likewise, for llm use, important to have examples in the doc strs

Returns:
PlotterBase: A PlotterBase instance configured with SpannerGraph.
"""
return Plotter().spannergraph(project_id, instance_id, database_id)
Copy link
Contributor

@lmeyerov lmeyerov Dec 24, 2024

Choose a reason for hiding this comment

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

re:interface --

Connection

i wonder if we want something similar to the bolt connectors, where we can do streamlined auth + passing in a client

CONN_CFG = { ... }
g1 = graphistry.spanner_connect(**CONN_CFG)
g2 = g1.spanner_query("...")
native_client = google.spanner.client(...)
g1 = graphistry.spanner_connect(native_client)
g2 = g1.spanner_query("....")

Return-typed query methods

Separately, a pattern I'm finding to be type-friendly with remote-mode gfql has been separating return-shape-typed methods:

g2 = g1.spanner_g("get a graph")
df = g1.spanner_df("get a table"")

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, in the neo4j & gremlin cases, when building real examples:

  • hydration: I found scenarios like we'd get either node IDs or edge IDs and would want to then hydrate them against the db
  • stored procedures: does GSQL have some notion of passing inputs
  • reads vs creates vs writes: any notions here? a good flow would be an example of going through uploading some data, querying it, doing some local enrichment, and then writing back the updates

Part of this makes me want to have some bigger examples to motivate helper functions on top. I suspect query_g() and query_df() can be good starts, but we need these examples to make more realistic

(The lack of bulk reads/writes such as via arrow is a bit puzzling, but that can wait?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants