Skip to main content

kraph

PyPI version PyPI pyversions

The python client for kraph, the Arkitekt knowledge graph service built around Apache AGE: recording claims about entities, events, measurements and metrics, backed by the structures (images, tables, …) that are evidence for them, and drawing them into graphs.

Installation

pip install kraph

With arkitekt, pip install "arkitekt[rekuest,kraph]" brings it in.

Concepts

  • Claims — an entity exists, a structure measures it, two things are related — are recorded under a term, a word your organization owns, never under a graph. Retracting a claim records a position rather than deleting anything.
  • Graphs are views. A graph declares categories (entity, relation, measurement, event, …) that say what its words mean, and draws the claims made under those words.

Usage

Every kraph operation is a method of the Kraph client, in a blocking and an a-prefixed async flavour (kraph.create_graph(...), await kraph.acreate_graph(...)). What a call returns remembers the client, so follow-ups from a result go through the same client.

In an arkitekt app

Add the service to your app and ask for kraph: Kraph; the client is injected by annotation. Graphs, categories, structures, metrics, terms and more travel between actions by id (@kraph/graph, @kraph/entitycategory, @kraph/structure, @kraph/term, …), so an action can take and return them directly:

from arkitekt import App, run
from kraph import Kraph, kraph_service

app = App("neuron-claims", "0.1.0", services=[kraph_service])


@app.action
def claim_neuron(kraph: Kraph) -> str:
    """Claim Neuron

    Records that a neuron exists.
    """
    asserted = kraph.assert_entity_exists(
        term="Neuron", supporting_evidence=[], derived_from=[], same_as=[]
    )
    return asserted.instance.id


if __name__ == "__main__":
    run(app)

From a script

from arkitekt import easy
from kraph import kraph_service

with easy("my-script", kraph_service) as kraph:
    graph = kraph.create_graph(name="Neurons", backfill=False)
    kraph.create_entity_category(
        key="Neuron",
        ontology_references=[],
        property_definitions=[],
        graph=graph.id,
        backfill=True,
    )

    asserted = kraph.assert_entity_exists(
        term="Neuron", supporting_evidence=[], derived_from=[], same_as=[]
    )
    print(asserted.is_drawn)  # True: the graph declares "Neuron", so it draws the claim

Testing

uv run pytest -m "not integration"   # no server needed
uv run pytest -m integration          # a real kraph via dokker

See RELEASING.md for how versions are cut.

Metadata

Release files for kraph 7.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kraph 7.2.1
File Size Uploaded Provenance Actions
kraph-7.2.1.tar.gz 147.1 kB Without provenance Details for kraph-7.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kraph 7.2.1
File Interpreter ABI Platform Actions
kraph-7.2.1-py3-none-any.whl Python 3 none any Details for kraph-7.2.1-py3-none-any.whl

Total release size: 302.2 kB

Release files / kraph-7.2.1.tar.gz

Download URL kraph-7.2.1.tar.gz
Size 147.1 kB
Tags Source
SHA-256 checksum
How to use checksums
eb29676a51a0c2792aa20f95ac56d3a7156e6d87222322936cd9fec597ae1fb1
BLAKE2b-256 checksum
How to use checksums
10f854164188b3f6dfbc3189d3b4db9d61fab661bddea98af5a803a704ec2be9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kraph-7.2.1-py3-none-any.whl

Download URL kraph-7.2.1-py3-none-any.whl
Size 155.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86257eba8942214ca53c2232c1e7474a3e40d7cfbc9d271ecb79ea558a715f0a
BLAKE2b-256 checksum
How to use checksums
d5a18610a8a2cad386ba2bb13538793e7ad46e21f29fb1a2491cf5a82ac649ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for kraph 7.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

7.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page