neo4j_uploader.models

  1from pydantic import BaseModel, Field
  2from typing import Optional
  3
  4# Specify Google doctstring type for pdoc auto doc generation
  5__docformat__ = "google"
  6
  7class Neo4jConfig(BaseModel):
  8    """
  9    Object for specifying target local or hosted Neo4j database instance to upload to data to.
 10
 11    Args:
 12        neo4j_uri (str): The URI of the Neo4j instance to upload to.
 13        neo4j_password (str): The password for the Neo4j instance to upload to.
 14        neo4j_user (str): The username for the Neo4j instance to upload to.
 15        neo4j_database (str): The name of the Neo4j database to upload to. Default 'neo4j'.
 16        max_batch_size (int): Maximum number of nodes to upload in a single batch. Default 500.
 17        overwrite (bool): Overwrite existing nodes. Default False.
 18    """
 19    neo4j_uri : str
 20    neo4j_password: str
 21    neo4j_user : str = Field(default="neo4j")
 22    neo4j_database : str = Field(default="neo4j")
 23    max_batch_size : int = Field(default=500)
 24    overwrite : bool = False
 25
 26class Nodes(BaseModel):
 27    """Configuration object for uploading nodes to a Neo4j database.
 28
 29    Args:
 30        labels (list[str]): List of node labels to upload (ie Person, Place, etc).
 31        key (str): Unique key for each node.
 32        records (list[dict]): List of dictionary objects containing node data.
 33        exclude_keys (list[str]): List of keys to exclude from upload.
 34        dedupe (bool): Remove duplicate entries. Default True.
 35    """
 36    labels: list[str]
 37    key: str
 38    records: list[dict]
 39    exclude_keys: Optional[list[str]] = []
 40    dedupe : Optional[bool] = True
 41
 42class TargetNode(BaseModel):
 43    """Node specification object for uploading relationships to a Neo4j database.
 44
 45    Args:
 46        node_label (str): Optional Node label of the target node. Including a label is more performant than without.
 47        node_key (str): Target key or property name that identifies a unique node.
 48        record_key (str): Key within the relationship record, whose value will be mapped to the node_key.
 49    """
 50    node_label: Optional[str] = None
 51    node_key: str
 52    record_key: str
 53
 54class Relationships(BaseModel):
 55    """Configuration object for uploading relationships to a Neo4j database.
 56
 57    Args:
 58        type (str): Relationship type (ie FOLLOWS, WORKS_AT, etc).
 59        from_node (TargetNode): TargetNode object for the source node.
 60        to_node (TargetNode): TargetNode object for the target node.
 61        records (list[dict]): List of dictionary objects containing relationship data.
 62        exclude_keys (list[str]): List of keys to exclude from upload.
 63        auto_exclude_keys (bool): Automatically exclude keys used to reference nodes used in the from_node and to_node arguments. Default True.
 64        dedupe (bool): Remove duplicate entries. Default True.
 65    """
 66    type: str
 67    from_node: TargetNode
 68    to_node: TargetNode
 69    records : list[dict]
 70    exclude_keys: Optional[list[str]] = []
 71    auto_exclude_keys: Optional[bool] = True
 72    dedupe: Optional[bool] = True
 73
 74class GraphData(BaseModel):
 75    """Object representation of nodes and relationships specifications and records to upload to a specified Neo4j database.
 76
 77    Args:
 78        nodes (list[Nodes]): List of Nodes configuration objects for specifying nodes to upload.
 79        relationships (list[Relationships]): Optional List of Relationships configuration objects for specifying relationships to upload.
 80    """
 81    nodes: list[Nodes] = []
 82    relationships: Optional[list[Relationships]] = []
 83
 84class UploadResult(BaseModel):
 85    """Result object for uploading nodes to a Neo4j database.
 86
 87    Args:
 88        was_successful (bool): True if upload was successful.
 89        seconds_to_complete (float): Time taken to upload nodes in seconds.
 90        nodes_created (int): Number of nodes created.
 91        relationships_created (int): Number of relationships created.
 92        properties_set (int): Number of properties set.
 93        error_message (str): Error message if upload failed.
 94    """
 95    was_successful : bool
 96    seconds_to_complete: Optional[float] = None
 97    nodes_created: Optional[int] = None
 98    relationships_created: Optional[int] = None
 99    properties_set: Optional[int] = None
100    error_message: Optional[str] = None
class Neo4jConfig(pydantic.main.BaseModel):
 8class Neo4jConfig(BaseModel):
 9    """
10    Object for specifying target local or hosted Neo4j database instance to upload to data to.
11
12    Args:
13        neo4j_uri (str): The URI of the Neo4j instance to upload to.
14        neo4j_password (str): The password for the Neo4j instance to upload to.
15        neo4j_user (str): The username for the Neo4j instance to upload to.
16        neo4j_database (str): The name of the Neo4j database to upload to. Default 'neo4j'.
17        max_batch_size (int): Maximum number of nodes to upload in a single batch. Default 500.
18        overwrite (bool): Overwrite existing nodes. Default False.
19    """
20    neo4j_uri : str
21    neo4j_password: str
22    neo4j_user : str = Field(default="neo4j")
23    neo4j_database : str = Field(default="neo4j")
24    max_batch_size : int = Field(default=500)
25    overwrite : bool = False

Object for specifying target local or hosted Neo4j database instance to upload to data to.

Arguments:
  • neo4j_uri (str): The URI of the Neo4j instance to upload to.
  • neo4j_password (str): The password for the Neo4j instance to upload to.
  • neo4j_user (str): The username for the Neo4j instance to upload to.
  • neo4j_database (str): The name of the Neo4j database to upload to. Default 'neo4j'.
  • max_batch_size (int): Maximum number of nodes to upload in a single batch. Default 500.
  • overwrite (bool): Overwrite existing nodes. Default False.
neo4j_uri: str
neo4j_password: str
neo4j_user: str
neo4j_database: str
max_batch_size: int
overwrite: bool
model_config = {}
model_fields = {'neo4j_uri': FieldInfo(annotation=str, required=True), 'neo4j_password': FieldInfo(annotation=str, required=True), 'neo4j_user': FieldInfo(annotation=str, required=False, default='neo4j'), 'neo4j_database': FieldInfo(annotation=str, required=False, default='neo4j'), 'max_batch_size': FieldInfo(annotation=int, required=False, default=500), 'overwrite': FieldInfo(annotation=bool, required=False, default=False)}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_computed_fields
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class Nodes(pydantic.main.BaseModel):
27class Nodes(BaseModel):
28    """Configuration object for uploading nodes to a Neo4j database.
29
30    Args:
31        labels (list[str]): List of node labels to upload (ie Person, Place, etc).
32        key (str): Unique key for each node.
33        records (list[dict]): List of dictionary objects containing node data.
34        exclude_keys (list[str]): List of keys to exclude from upload.
35        dedupe (bool): Remove duplicate entries. Default True.
36    """
37    labels: list[str]
38    key: str
39    records: list[dict]
40    exclude_keys: Optional[list[str]] = []
41    dedupe : Optional[bool] = True

Configuration object for uploading nodes to a Neo4j database.

Arguments:
  • labels (list[str]): List of node labels to upload (ie Person, Place, etc).
  • key (str): Unique key for each node.
  • records (list[dict]): List of dictionary objects containing node data.
  • exclude_keys (list[str]): List of keys to exclude from upload.
  • dedupe (bool): Remove duplicate entries. Default True.
labels: list[str]
key: str
records: list[dict]
exclude_keys: Optional[list[str]]
dedupe: Optional[bool]
model_config = {}
model_fields = {'labels': FieldInfo(annotation=list[str], required=True), 'key': FieldInfo(annotation=str, required=True), 'records': FieldInfo(annotation=list[dict], required=True), 'exclude_keys': FieldInfo(annotation=Union[list[str], NoneType], required=False, default=[]), 'dedupe': FieldInfo(annotation=Union[bool, NoneType], required=False, default=True)}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_computed_fields
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class TargetNode(pydantic.main.BaseModel):
43class TargetNode(BaseModel):
44    """Node specification object for uploading relationships to a Neo4j database.
45
46    Args:
47        node_label (str): Optional Node label of the target node. Including a label is more performant than without.
48        node_key (str): Target key or property name that identifies a unique node.
49        record_key (str): Key within the relationship record, whose value will be mapped to the node_key.
50    """
51    node_label: Optional[str] = None
52    node_key: str
53    record_key: str

Node specification object for uploading relationships to a Neo4j database.

Arguments:
  • node_label (str): Optional Node label of the target node. Including a label is more performant than without.
  • node_key (str): Target key or property name that identifies a unique node.
  • record_key (str): Key within the relationship record, whose value will be mapped to the node_key.
node_label: Optional[str]
node_key: str
record_key: str
model_config = {}
model_fields = {'node_label': FieldInfo(annotation=Union[str, NoneType], required=False), 'node_key': FieldInfo(annotation=str, required=True), 'record_key': FieldInfo(annotation=str, required=True)}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_computed_fields
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class Relationships(pydantic.main.BaseModel):
55class Relationships(BaseModel):
56    """Configuration object for uploading relationships to a Neo4j database.
57
58    Args:
59        type (str): Relationship type (ie FOLLOWS, WORKS_AT, etc).
60        from_node (TargetNode): TargetNode object for the source node.
61        to_node (TargetNode): TargetNode object for the target node.
62        records (list[dict]): List of dictionary objects containing relationship data.
63        exclude_keys (list[str]): List of keys to exclude from upload.
64        auto_exclude_keys (bool): Automatically exclude keys used to reference nodes used in the from_node and to_node arguments. Default True.
65        dedupe (bool): Remove duplicate entries. Default True.
66    """
67    type: str
68    from_node: TargetNode
69    to_node: TargetNode
70    records : list[dict]
71    exclude_keys: Optional[list[str]] = []
72    auto_exclude_keys: Optional[bool] = True
73    dedupe: Optional[bool] = True

Configuration object for uploading relationships to a Neo4j database.

Arguments:
  • type (str): Relationship type (ie FOLLOWS, WORKS_AT, etc).
  • from_node (TargetNode): TargetNode object for the source node.
  • to_node (TargetNode): TargetNode object for the target node.
  • records (list[dict]): List of dictionary objects containing relationship data.
  • exclude_keys (list[str]): List of keys to exclude from upload.
  • auto_exclude_keys (bool): Automatically exclude keys used to reference nodes used in the from_node and to_node arguments. Default True.
  • dedupe (bool): Remove duplicate entries. Default True.
type: str
from_node: TargetNode
to_node: TargetNode
records: list[dict]
exclude_keys: Optional[list[str]]
auto_exclude_keys: Optional[bool]
dedupe: Optional[bool]
model_config = {}
model_fields = {'type': FieldInfo(annotation=str, required=True), 'from_node': FieldInfo(annotation=TargetNode, required=True), 'to_node': FieldInfo(annotation=TargetNode, required=True), 'records': FieldInfo(annotation=list[dict], required=True), 'exclude_keys': FieldInfo(annotation=Union[list[str], NoneType], required=False, default=[]), 'auto_exclude_keys': FieldInfo(annotation=Union[bool, NoneType], required=False, default=True), 'dedupe': FieldInfo(annotation=Union[bool, NoneType], required=False, default=True)}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_computed_fields
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class GraphData(pydantic.main.BaseModel):
75class GraphData(BaseModel):
76    """Object representation of nodes and relationships specifications and records to upload to a specified Neo4j database.
77
78    Args:
79        nodes (list[Nodes]): List of Nodes configuration objects for specifying nodes to upload.
80        relationships (list[Relationships]): Optional List of Relationships configuration objects for specifying relationships to upload.
81    """
82    nodes: list[Nodes] = []
83    relationships: Optional[list[Relationships]] = []

Object representation of nodes and relationships specifications and records to upload to a specified Neo4j database.

Arguments:
  • nodes (list[Nodes]): List of Nodes configuration objects for specifying nodes to upload.
  • relationships (list[Relationships]): Optional List of Relationships configuration objects for specifying relationships to upload.
nodes: list[Nodes]
relationships: Optional[list[Relationships]]
model_config = {}
model_fields = {'nodes': FieldInfo(annotation=list[Nodes], required=False, default=[]), 'relationships': FieldInfo(annotation=Union[list[Relationships], NoneType], required=False, default=[])}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_computed_fields
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class UploadResult(pydantic.main.BaseModel):
 85class UploadResult(BaseModel):
 86    """Result object for uploading nodes to a Neo4j database.
 87
 88    Args:
 89        was_successful (bool): True if upload was successful.
 90        seconds_to_complete (float): Time taken to upload nodes in seconds.
 91        nodes_created (int): Number of nodes created.
 92        relationships_created (int): Number of relationships created.
 93        properties_set (int): Number of properties set.
 94        error_message (str): Error message if upload failed.
 95    """
 96    was_successful : bool
 97    seconds_to_complete: Optional[float] = None
 98    nodes_created: Optional[int] = None
 99    relationships_created: Optional[int] = None
100    properties_set: Optional[int] = None
101    error_message: Optional[str] = None

Result object for uploading nodes to a Neo4j database.

Arguments:
  • was_successful (bool): True if upload was successful.
  • seconds_to_complete (float): Time taken to upload nodes in seconds.
  • nodes_created (int): Number of nodes created.
  • relationships_created (int): Number of relationships created.
  • properties_set (int): Number of properties set.
  • error_message (str): Error message if upload failed.
was_successful: bool
seconds_to_complete: Optional[float]
nodes_created: Optional[int]
relationships_created: Optional[int]
properties_set: Optional[int]
error_message: Optional[str]
model_config = {}
model_fields = {'was_successful': FieldInfo(annotation=bool, required=True), 'seconds_to_complete': FieldInfo(annotation=Union[float, NoneType], required=False), 'nodes_created': FieldInfo(annotation=Union[int, NoneType], required=False), 'relationships_created': FieldInfo(annotation=Union[int, NoneType], required=False), 'properties_set': FieldInfo(annotation=Union[int, NoneType], required=False), 'error_message': FieldInfo(annotation=Union[str, NoneType], required=False)}
Inherited Members
pydantic.main.BaseModel
BaseModel
model_computed_fields
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs