Skip to main content

ScientIO is a Knowledge Graph Engine to organise and query complex data.

Project description

Roboy ScientIO

About

Roboy ScientIO (from Lat. scientia - knowledge and Input/Output) - a Knowledge Graph Engine to organise and query complex data.

Dependencies

To use ScientIO, you will need to have one of it's supported back-ends installed. Currently, the only supported back-end is Neo4j, which may be run in a number of ways (if you don't have a remote instance available). We recommend simply running it through docker - like this:

docker run \
    --publish=7474:7474 --publish=7687:7687 \
    --volume=$HOME/neo4j/data:/data \
    --volume=$HOME/neo4j/logs:/logs \
    neo4j:3.0

Installation

Via PIP

The easiest way to install ScientIO is through pip:

pip install scientio

For developers

First, install dependencies:

pip install -r requirements.txt

Then, you may open the repository in any IDE, and mark the src folder as a sources root.

Basic ScientIO use-cases

Supplying an ontology description

The ontology description is a collection of named entity types, where each type may declare a specific set of properties and relationships like this:

# my_ontology.yml

!OType
entity: Alien    # The name of the ontology type
---
!OType
entity: Vulcan   # Declare a more specific Alien type
meta: [Alien]
properties:      # Allowed properties for every Vulcan
 - name
 - homeworld
 - ear_pointiness
---
!OType
entity: Human    # Declare a more specific Alien type
meta: [Alien]
properties:      # Allowed properties for every Human
 - name
 - homeworld
relationships: [captain_of]  # Allowed relationships for every Human

Creating some nodes

from scientio.ontology.ontology import Ontology
from scientio.session import Session
from scientio.ontology.node import Node

# Load the ontology from a yaml file
onto = Ontology(path_to_yaml="my_ontology.yml")

# Create a session (with default Neo4j backend)
sess = Session(
    ontology=onto,
    neo4j_address="bolt://localhost:7687",
    neo4j_username="neo4j",
    neo4j_password="test")

# Get human/vulcan types from ontology
human_type = onto.get_type("Human")
vulcan_type = onto.get_type("Vulcan")

# Create a transient human named "Kirk"
kirk = Node(metatype=human_type)
kirk.set_name("Kirk")

# Create a transient vulcan named "Spock"
spock = Node(metatype=vulcan_type)
spock.set_name("Spock")

# Persist kirk and spock
sess.create(kirk)
sess.create(spock)

Add a relationship between your nodes

from scientio.ontology.ontology import Ontology
from scientio.session import Session
from scientio.ontology.node import Node

# Load the ontology from a yaml file
onto = Ontology(path_to_yaml="my_ontology.yml")

# Create a session (with default Neo4j backend)
sess = Session(
    ontology=onto,
    neo4j_address="bolt://localhost:7687",
    neo4j_username="neo4j",
    neo4j_password="test")

# Get human/vulcan types from ontology
human_type = onto.get_type("Human")
vulcan_type = onto.get_type("Vulcan")

# Create query templates to get the actual kirk/spock
kirk = Node(metatype=human_type)
spock = Node(metatype=vulcan_type)

# Query Kirk and Spock from the database, using
# the query nodes we created previously. We're just
# gonna assume that the first human is Kirk, and the first
# vulcan is Spock.
kirk = sess.retrieve(request=kirk)[0]
spock = sess.retrieve(request=spock)[0]

# Add a relationship between Kirk and Spock
kirk.add_relationships({"captain_of": {spock.get_id()}})

# Make sure that the new relationship is persisted
sess.update(kirk)

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

scientio-0.9.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

scientio-0.9.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file scientio-0.9.0.tar.gz.

File metadata

  • Download URL: scientio-0.9.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for scientio-0.9.0.tar.gz
Algorithm Hash digest
SHA256 bbded3d7e452cc5edeff32c59fa546a9c1546acc177224dcea70791045083397
MD5 b8d02be391cd5b7e4f613641a1f55151
BLAKE2b-256 d9745c7fcb62c20ce72f4484843d238d0ffde8552e3e6bb22f19ade3ccab6c33

See more details on using hashes here.

File details

Details for the file scientio-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: scientio-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for scientio-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3957fb2189a65ac5c221a60f99c060a54398447502b40f0c4c255e512d3b959c
MD5 161b609755a70fd3e811561cb5605aa4
BLAKE2b-256 576be55ce1569ddba3a1246a2f284b0a364369a88f8fab5a384c8c41a2879773

See more details on using hashes here.

Supported by

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