Getting Started¶
Installation¶
To install from PyPi:
python3 -m pip install kglab
If you work directly from this Git repo, be sure to install the dependencies:
python3 -m pip install -r requirements.txt
Alternatively, to install dependencies using conda
:
conda env create -f environment.yml
conda activate kglab
See the Dependencies section for more information about troubleshooting installation issues.
Sample Usage¶
To use kglab in its simplest form:
import kglab
kg = kglab.KnowledgeGraph()
kg.load_rdf("https://storage.googleapis.com/kglab-tutorial/foaf.rdf", format="xml")
measure = kglab.Measure()
measure.measure_graph(kg)
print("edges: {}\n".format(measure.get_edge_count()))
print("nodes: {}\n".format(measure.get_node_count()))
ttl = kg.save_rdf_text()
print(ttl)
Using Docker¶
-
For a simple approach to running our tutorials, see use of docker compose.
-
Alternatively, 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
Hands-on Coding Tutorial¶
See the Tutorial notebooks for sample code and patterns to use when integrating kglab with other related libraries in Python.
Last update:
2022-03-10