hydra.overlay.python.tinkerpop.coder module
Bidirectional bridge between Hydra property graphs and TinkerPop (Gremlin) graphs, in Python.
This is the Python counterpart of hydra.overlay.java.tinkerpop.coder (the
HydraGremlinBridge + Validate classes). It converts between a live TinkerPop
graph (read/written via a gremlinpython GraphTraversalSource) and Hydra’s
hydra.pg.model.Graph, and validates a TinkerPop graph against a Hydra GraphSchema
using the hydra.validate.pg engine.
Host-specific code: it depends on gremlinpython, so it lives under the hydra.overlay.python.*
namespace (only translingual/generated code lives outside hydra.overlay). This module is
currently shipped as a binding; it is authored at its eventual overlay namespace so the future
migration to overlay/ is a file move, not a rewrite.
- class hydra.overlay.python.tinkerpop.coder.Result(error)
Bases:
objectThe result of validating a graph against a schema.
errorcarries the typedInvalidGraphError(or None when valid).- property error
- property is_valid
- hydra.overlay.python.tinkerpop.coder.check_literal(lt, lv)
The
check_valuecallback forhydra.validate.pg.validate_graph.Returns
None_()if the literal value matches the expected type,Given(InvalidValueError(...))otherwise.
- hydra.overlay.python.tinkerpop.coder.gremlin_to_hydra(g, value_mapper=<function object_to_literal>)
Read a TinkerPop graph via traversals and convert to a Hydra Graph.
gis a gremlinpythonGraphTraversalSource(remote or embedded). Returns ahydra.pg.model.Graphwith Literal values.
- hydra.overlay.python.tinkerpop.coder.hydra_to_gremlin(graph, g, value_unmapper=<function literal_to_object>)
Write a Hydra Graph into a live TinkerPop graph via traversals.
Upserts by id: existing vertices/edges keep their identity and have properties overwritten; new ones are added. Vertices are written before edges to avoid dangling references within a single call.
gmay be remote or embedded but must allow writes.
- hydra.overlay.python.tinkerpop.coder.literal_family(lit)
- hydra.overlay.python.tinkerpop.coder.literal_to_object(literal)
Convert a Hydra Literal to a plain Python value. Inverse of
object_to_literal.
- hydra.overlay.python.tinkerpop.coder.object_to_literal(obj)
Convert a Python value from gremlinpython to a Hydra Literal.
Handles the types that TinkerPop’s Modern graph uses: str, int, and float (Python float is 64-bit).
- hydra.overlay.python.tinkerpop.coder.show_literal(lit)
- hydra.overlay.python.tinkerpop.coder.show_literal_type(lt)
- hydra.overlay.python.tinkerpop.coder.validate(schema, g)
Validate a TinkerPop graph (via a gremlinpython traversal source) against a schema.
Returns a
Resultwhoserepr()is “VALID” or “INVALID - …” and whoseerror, when present, is a typedInvalidGraphError.