Skip to main content

A framework for transforming tabular (CSV, SQL) and hierarchical data (JSON, XML) into property graphs and ingesting them into graph databases (ArangoDB, Neo4j)

Project description

GraphCast graphcast logo

A framework for transforming tabular (CSV, SQL) and hierarchical data (JSON, XML) into property graphs and ingesting them into graph databases (ArangoDB, Neo4j).

Python PyPI version PyPI Downloads License: BSL pre-commit DOI

Core Concepts

Property Graphs

GraphCast works with property graphs, which consist of:

  • Vertices: Nodes with properties and optional unique identifiers
  • Edges: Relationships between vertices with their own properties
  • Properties: Both vertices and edges may have properties

Schema

The Schema defines how your data should be transformed into a graph and contains:

  • Vertex Definitions: Specify vertex types, their properties, and unique identifiers
  • Edge Definitions: Define relationships between vertices and their properties
  • Resource Mapping: describe how data sources map to vertices and edges
  • Transforms: Modify data during the casting process

Resources

Resources are your data sources that can be:

  • Table-like: CSV files, database tables
  • JSON-like: JSON files, nested data structures

Features

  • Graph Transformation Meta-language: A powerful declarative language to describe how your data becomes a property graph:
    • Define vertex and edge structures
    • Set compound indexes for vertices and edges
    • Use blank vertices for complex relationships
    • Specify edge constraints and properties
    • Apply advanced filtering and transformations
  • Parallel processing: Use as many cores as you have
  • Database support: Ingest into ArangoDB and Neo4j using the same API (database agnostic)

Documentation

Full documentation is available at: growgraph.github.io/graphcast

Installation

pip install graphcast

Usage Examples

Simple ingest

from suthing import ConfigFactory, FileHandle

from graphcast import Schema, Caster, Patterns


schema = Schema.from_dict(FileHandle.load("schema.yaml"))

conn_conf = ConfigFactory.create_config({
        "protocol": "http",
        "hostname": "localhost",
        "port": 8535,
        "username": "root",
        "password": "123",
        "database": "_system",
}
)

patterns = Patterns.from_dict(
    {
        "patterns": {
            "work": {"regex": "\Sjson$"},
        }
    }
)

schema.fetch_resource()

caster = Caster(
    schema,
)

caster.ingest_files(
    path="./data",
    conn_conf=conn_conf,
    patterns=patterns,
)

Development

To install requirements

git clone git@github.com:growgraph/graphcast.git && cd graphcast
uv sync --dev

Tests

Test databases

Spin up Arango from arango docker folder by

docker-compose --env-file .env up arango

and Neo4j from neo4j docker folder by

docker-compose --env-file .env up neo4j

To run unit tests

pytest test

Requirements

  • Python 3.11+
  • python-arango

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphcast-1.0.0.tar.gz (67.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphcast-1.0.0-py3-none-any.whl (87.5 kB view details)

Uploaded Python 3

File details

Details for the file graphcast-1.0.0.tar.gz.

File metadata

  • Download URL: graphcast-1.0.0.tar.gz
  • Upload date:
  • Size: 67.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.11

File hashes

Hashes for graphcast-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c8e3eb184cb5825e74b0361ff4477ae04df51c6db227041bb9df7aefafc90ffb
MD5 505b425829921d50befc803d320cd39a
BLAKE2b-256 f745044eef7598335876c950063519ce3e2c860e26e8e20cc115089347d3ffa6

See more details on using hashes here.

File details

Details for the file graphcast-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: graphcast-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 87.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.11

File hashes

Hashes for graphcast-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b74f3014e10c6819528020033b5cb146bd61999bb3a193f3dc0c96416bb44419
MD5 3f4ac3bc0dfacfd5d5af1201b0c57907
BLAKE2b-256 6eff3ca6e55fd3e483a481438690b577ef03fe4396bc15e4724e81c26026dfa9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page