goblin package¶
Subpackages¶
Submodules¶
goblin.abc module¶
-
class
goblin.abc.
BaseProperty
[source]¶ Bases:
object
Abstract base class that implements the property interface
-
data_type
¶
-
goblin.app module¶
Goblin application class and class constructor
-
class
goblin.app.
Goblin
(cluster, *, provider=<class 'goblin.provider.TinkerGraph'>, get_hashable_id=None, aliases=None)[source]¶ Bases:
object
Class used to encapsulate database connection configuration and generate database connections Used as a factory to create
Session
objects.Parameters: - url (str) – Database url
- loop (asyncio.BaseEventLoop) – Event loop implementation
- features (dict) – Vendor implementation specific database features
- config (dict) – Config parameters for application
-
cluster
¶
-
config
¶
-
config_from_file
(filename)[source]¶ Load configuration from from file.
Parameters: filename (str) – Path to the configuration file.
-
config_from_json
(filename)[source]¶ Load configuration from from JSON file.
Parameters: filename (str) – Path to the configuration file.
-
edges
¶ Registered edge classes
-
classmethod
open
(loop, *, provider=<class 'goblin.provider.TinkerGraph'>, get_hashable_id=None, aliases=None, **config)[source]¶
-
register
(*elements)[source]¶ Register user created Element classes.
Parameters: elements (goblin.element.Element) – User defined Element classes
-
session
(*, processor='', op='eval', aliases=None)[source]¶ Create a session object.
Returns: Session
object
-
url
¶ Database url
-
vertices
¶ Registered vertex classes
goblin.element module¶
Module defining graph elements.
-
class
goblin.element.
Edge
(source=None, target=None)[source]¶ Bases:
goblin.element.Element
Base class for user defined Edge classes.
Parameters: -
source
¶
-
target
¶
-
-
class
goblin.element.
Element
(**kwargs)[source]¶ Bases:
object
Base class for classes that implement the Element property interface
-
id
¶
-
-
class
goblin.element.
ElementMeta
[source]¶ Bases:
type
Metaclass for graph elements. Responsible for creating the
Mapping
object and replacing user definedgoblin.properties.Property
withgoblin.properties.PropertyDescriptor
.
-
class
goblin.element.
GenericEdge
(source=None, target=None)[source]¶ Bases:
goblin.element.Edge
Class used to build edges when user defined edges class is not available. Generally not instantiated by end user.
-
class
goblin.element.
GenericVertex
(**kwargs)[source]¶ Bases:
goblin.element.Vertex
Class used to build vertices when user defined vertex class is not available. Generally not instantiated by end user.
-
class
goblin.element.
Vertex
(**kwargs)[source]¶ Bases:
goblin.element.Element
Base class for user defined Vertex classes
-
class
goblin.element.
VertexProperty
(data_type, *, default=None, db_name=None, card=None, db_name_factory=None)[source]¶ Bases:
goblin.element.Element
,goblin.abc.BaseProperty
Base class for user defined vertex properties.
-
cardinality
¶
-
data_type
¶
-
db_name
¶
-
db_name_factory
¶
-
default
¶
-
value
¶
-
goblin.exception module¶
goblin.manager module¶
Managers for multi cardinality vertex properties
-
class
goblin.manager.
ListVertexPropertyManager
(data_type, vertex_prop, card, obj)[source]¶ Bases:
list
,goblin.manager.VertexPropertyManager
-
vp_map
¶
-
goblin.mapper module¶
Helper functions and class to map between OGM Elements <-> DB Elements
-
class
goblin.mapper.
Mapping
(namespace, element_type, mapper_func, properties)[source]¶ Bases:
object
This class stores the information necessary to map between an OGM element and a DB element.
-
db_properties
¶ A dictionary of property mappings
-
label
¶ Element label
-
mapper_func
¶ Function responsible for mapping db results to ogm
-
ogm_properties
¶ A dictionary of property mappings
-
-
goblin.mapper.
map_edge_to_ogm
(result, props, element, *, mapping=None)[source]¶ Map an edge returned by DB to OGM edge
-
goblin.mapper.
map_props_to_db
(element, mapping)[source]¶ Convert OGM property names/values to DB property names/values
goblin.properties module¶
Classes to handle properties and data type definitions
-
class
goblin.properties.
Boolean
(val=None)[source]¶ Bases:
goblin.abc.DataType
Simple boolean datatype
-
class
goblin.properties.
Float
(val=None)[source]¶ Bases:
goblin.abc.DataType
Simple float datatype
-
class
goblin.properties.
Generic
(val=None)[source]¶ Bases:
goblin.abc.DataType
-
class
goblin.properties.
IdProperty
(data_type, *, serializer=None)[source]¶ Bases:
goblin.abc.BaseProperty
-
data_type
¶
-
serializer
¶
-
-
class
goblin.properties.
Integer
(val=None)[source]¶ Bases:
goblin.abc.DataType
Simple integer datatype
-
class
goblin.properties.
Property
(data_type, *, db_name=None, default=None, db_name_factory=None)[source]¶ Bases:
goblin.abc.BaseProperty
API class used to define properties. Replaced with
PropertyDescriptor
bygoblin.element.ElementMeta
.Parameters: - data_type (goblin.abc.DataType) – Str or class of data type
- db_name (str) – User defined custom name for property in db
- default – Default value for this property.
-
data_type
¶
-
db_name
¶
-
db_name_factory
¶
-
default
¶
-
class
goblin.properties.
PropertyDescriptor
(name, prop)[source]¶ Bases:
object
Descriptor that validates user property input and gets/sets properties as instance attributes. Not instantiated by user.
-
class
goblin.properties.
String
(val=None)[source]¶ Bases:
goblin.abc.DataType
Simple string datatype
goblin.session module¶
Main OGM API classes and constructors
-
class
goblin.session.
Session
(app, remote_connection, get_hashable_id)[source]¶ Bases:
object
Provides the main API for interacting with the database. Does not necessarily correpsond to a database session. Don’t instantiate directly, instead use
Goblin.session
.Parameters: - app (goblin.app.Goblin) –
- conn (aiogremlin.driver.connection.Connection) –
-
add
(*elements)[source]¶ Add elements to session pending queue.
Parameters: elements (goblin.element.Element) – Elements to be added
-
app
¶
-
current
¶
-
flush
()[source]¶ Issue creation/update queries to database for all elements in the session pending queue.
-
g
¶ Get a simple traversal source.
Returns: gremlin_python.process.GraphTraversalSource object
-
get_edge
(edge)[source]¶ Get a edge from the db. Edge must have id.
Parameters: element (goblin.element.Edge) – Edge to be retrieved Returns: Edge
| None
-
get_vertex
(vertex)[source]¶ Get a vertex from the db. Vertex must have id.
Parameters: element (goblin.element.Vertex) – Vertex to be retrieved Returns: Vertex
| None
-
graph
¶
-
remote_connection
¶
-
remove_edge
(edge)[source]¶ Remove an edge from the db.
Parameters: edge (goblin.element.Edge) – Element to be removed
-
remove_vertex
(vertex)[source]¶ Remove a vertex from the db.
Parameters: vertex (goblin.element.Vertex) – Vertex to be removed
-
save
(elem)[source]¶ Save an element to the db.
Parameters: element (goblin.element.Element) – Vertex or Edge to be saved Returns: Element
object
-
save_edge
(edge)[source]¶ Save an edge to the db.
Parameters: element (goblin.element.Edge) – Edge to be saved Returns: Edge
object
-
save_vertex
(vertex)[source]¶ Save a vertex to the db.
Parameters: element (goblin.element.Vertex) – Vertex to be saved Returns: Vertex
object
-
submit
(bytecode)[source]¶ Submit a query to the Gremiln Server.
Parameters: Returns: gremlin_python.driver.remove_connection.RemoteTraversal object
-
traversal
(element_class=None)[source]¶ Generate a traversal using a user defined element class as a starting point.
Parameters: element_class (goblin.element.Element) – An optional element class that will dictate the element type (vertex/edge) as well as the label for the traversal source Returns: aiogremlin.process.graph_traversal.AsyncGraphTraversal
-
goblin.session.
bindprop
(element_class, ogm_name, val, *, binding=None)[source]¶ Helper function for binding ogm properties/values to corresponding db properties/values for traversals.
Parameters: - element_class (goblin.element.Element) – User defined element class
- ogm_name (str) – Name of property as defined in the ogm
- val – The property value
- binding (str) – The binding for val (optional)
Returns: tuple object (‘db_property_name’, (‘binding(if passed)’, val))
Module contents¶
Python toolkit for Tinker Pop 3 Gremlin Server.