Skip to main content

kglab

DOI Licence Repo size GitHub commit activity Checked with mypy

Welcome to Graph Data Science: https://derwen.ai/docs/kgl/

The kglab library provides a simple abstraction layer in Python 3.11-3.13 for building knowledge graphs, leveraging Pandas, NetworkX, RAPIDS, RDFLib, Morph-KGC, and many more.

Getting Started

See the "Getting Started" section of the online documentation.

pip

python3 -m pip install kglab

poetry

poetry add kglab

conda

conda env create -n kglab
conda activate kglab
pip install kglab

Then to run some simple uses of this library:

import kglab

# create a KnowledgeGraph object
kg = kglab.KnowledgeGraph()

# load RDF from a URL
kg.load_rdf("http://bigasterisk.com/foaf.rdf", format="xml")

# measure the graph
measure = kglab.Measure()
measure.measure_graph(kg)

print("edges: {}\n".format(measure.get_edge_count()))
print("nodes: {}\n".format(measure.get_node_count()))

# serialize as a string in "Turtle" TTL format
ttl = kg.save_rdf_text()
print(ttl)

See the tutorial notebooks in the examples subdirectory for sample code and patterns to use in integrating kglab with other graph libraries in Python: https://derwen.ai/docs/kgl/tutorial/

Using Docker

For a simple approach to running the tutorials, see use of docker compose: https://derwen.ai/docs/kgl/tutorial/#use-docker-compose

Also, container images for each release are available on DockerHub: https://hub.docker.com/repository/docker/derwenai/kglab

To build a container image and run it for the tutorials:

docker build --pull --rm -f "docker/Dockerfile" -t kglab:latest .
docker run -p 8888:8888 -it kglab

To build and run a container image for testing:

docker build --pull --rm -f "docker/testsuite.Dockerfile" -t kglabtest:latest .
docker run --rm -it kglabtest
Build Instructions Note: unless you are contributing code and updates, in most use cases won't need to build this package locally.

Instead, simply install from PyPi or use Conda.

To set up the build environment locally, see the "Build Instructions" section of the online documentation.

Semantic Versioning

Before kglab reaches release v1.0.0 the types and classes may undergo substantial changes and the project is not guaranteed to have a consistent API.

Even so, we'll try to minimize breaking changes. We'll also be sure to provide careful notes.

See: changelog.txt

Contributing Code

We welcome people getting involved as contributors to this open source project!

For detailed instructions please see: CONTRIBUTING.md

License and Copyright

Source code for kglab plus its logo, documentation, and examples have an MIT license which is succinct and simplifies use in commercial applications.

All materials herein are Copyright © 2020-2025 Derwen, Inc.

Attribution Please use the following BibTeX entry for citing **kglab** if you use it in your research or software. Citations are helpful for the continued development and maintenance of this library.
@software{kglab,
  author = {Paco Nathan},
  title = {{kglab: a simple abstraction layer in Python for building knowledge graphs}},
  year = 2020,
  publisher = {Derwen},
  doi = {10.5281/zenodo.4416034},
  url = {https://github.com/DerwenAI/kglab}
}

illustration of a knowledge graph, plus laboratory glassware

Kudos

Many thanks to our open source sponsors; and to our contributors: @ceteri, @dvsrepo, @Ankush-Chander, @louisguitton, @tomaarsen, @Mec-iS, @jake-aft, @cutterkom, @RishiKumarRay, @Tpt, @ArenasGuerreroJulian, @fils, @lapkinvladimir, @akuckartz, @tommybbq, @gauravjaglan, @pebbie, @CatChenal, @dmoore247, plus general support from Derwen, Inc.; the Knowledge Graph Conference and Connected Data World; plus an even larger scope of use cases represented by their communities; and support from Kubuntu Focus, and the RAPIDS team @ NVIDIA.

kglab contributors

Star History

Star History Chart

Release files for kglab 1.0.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 kglab 1.0.1
File Size Uploaded
kglab-1.0.1.tar.gz 36.6 kB Details

Built distribution (wheel)

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

Total release size: 81.2 kB

Release files / kglab-1.0.1.tar.gz

Download URL kglab-1.0.1.tar.gz
Size 36.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9c17bafcacf48d7ce639210a10029f3fa30b4fe15fe6210f901726e21096fa3d
BLAKE2b-256 checksum
How to use checksums
a95bccb40f9cd413427ace42f2b616dda81917e26d165370520265a618af845a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.13.8 Darwin/24.6.0

Release files / kglab-1.0.1-py3-none-any.whl

Download URL kglab-1.0.1-py3-none-any.whl
Size 44.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fadf0f3592688b7c384ee75a2a40eb109565b7da6a6a181916a53aac387be5f2
BLAKE2b-256 checksum
How to use checksums
93f00888caf54a610a452376b857046b6f8caf2bfac90b2be6f4e53ea6dd5eae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.13.8 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.7.0

2 release files

0.6.6

2 release files

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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