Skip to content

Commit 2d68f94

Browse files
Merge pull request #11 from Roboy/devel
Devel to Master
2 parents ff2e9c3 + 5fa0c16 commit 2d68f94

19 files changed

+1185
-0
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.idea
2+
venv
3+
*.key
4+
*.default
5+
.coverage
6+
.pytest_cache
7+
__pycache__
8+
dist/*
9+
build/*
10+
*.egg-info
11+
*.log

README.md

+139
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,141 @@
11
# Roboy ScientIO
2+
3+
## About
4+
25
Roboy ScientIO (from Lat. scientia - knowledge and Input/Output) - a Knowledge Graph Engine to organise and query complex data.
6+
7+
## Dependencies
8+
9+
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
10+
(if you don't have a remote instance available). We recommend simply running it through docker - like this:
11+
12+
```bash
13+
docker run \
14+
--publish=7474:7474 --publish=7687:7687 \
15+
--volume=$HOME/neo4j/data:/data \
16+
--volume=$HOME/neo4j/logs:/logs \
17+
neo4j:3.0
18+
```
19+
20+
## Installation
21+
22+
### Via PIP
23+
24+
The easiest way to install ScientIO is through pip:
25+
26+
``
27+
pip install scientio
28+
``
29+
30+
### For developers
31+
32+
First, install dependencies:
33+
34+
```bash
35+
pip install -r requirements.txt
36+
```
37+
38+
Then, you may open the repository in any IDE, and mark the
39+
`src` folder as a sources root.
40+
41+
## Basic ScientIO use-cases
42+
43+
### Supplying an ontology description
44+
45+
The ontology description is a collection of named entity types, where each type may declare a specific set of properties and relationships like this:
46+
47+
```yaml
48+
# my_ontology.yml
49+
50+
!OType
51+
entity: Alien # The name of the ontology type
52+
---
53+
!OType
54+
entity: Vulcan # Declare a more specific Alien type
55+
meta: [Alien]
56+
properties: # Allowed properties for every Vulcan
57+
- name
58+
- homeworld
59+
- ear_pointiness
60+
---
61+
!OType
62+
entity: Human # Declare a more specific Alien type
63+
meta: [Alien]
64+
properties: # Allowed properties for every Human
65+
- name
66+
- homeworld
67+
relationships: [captain_of] # Allowed relationships for every Human
68+
```
69+
70+
### Creating some nodes
71+
72+
```python
73+
from scientio.ontology.ontology import Ontology
74+
from scientio.session import Session
75+
from scientio.ontology.node import Node
76+
77+
# Load the ontology from a yaml file
78+
onto = Ontology(path_to_yaml="my_ontology.yml")
79+
80+
# Create a session (with default Neo4j backend)
81+
sess = Session(
82+
ontology=onto,
83+
neo4j_address="bolt://localhost:7687",
84+
neo4j_username="neo4j",
85+
neo4j_password="test")
86+
87+
# Get human/vulcan types from ontology
88+
human_type = onto.get_type("Human")
89+
vulcan_type = onto.get_type("Vulcan")
90+
91+
# Create a transient human named "Kirk"
92+
kirk = Node(metatype=human_type)
93+
kirk.set_name("Kirk")
94+
95+
# Create a transient vulcan named "Spock"
96+
spock = Node(metatype=vulcan_type)
97+
spock.set_name("Spock")
98+
99+
# Persist kirk and spock
100+
sess.create(kirk)
101+
sess.create(spock)
102+
```
103+
104+
### Add a relationship between your nodes
105+
106+
```python
107+
from scientio.ontology.ontology import Ontology
108+
from scientio.session import Session
109+
from scientio.ontology.node import Node
110+
111+
# Load the ontology from a yaml file
112+
onto = Ontology(path_to_yaml="my_ontology.yml")
113+
114+
# Create a session (with default Neo4j backend)
115+
sess = Session(
116+
ontology=onto,
117+
neo4j_address="bolt://localhost:7687",
118+
neo4j_username="neo4j",
119+
neo4j_password="test")
120+
121+
# Get human/vulcan types from ontology
122+
human_type = onto.get_type("Human")
123+
vulcan_type = onto.get_type("Vulcan")
124+
125+
# Create query templates to get the actual kirk/spock
126+
kirk = Node(metatype=human_type)
127+
spock = Node(metatype=vulcan_type)
128+
129+
# Query Kirk and Spock from the database, using
130+
# the query nodes we created previously. We're just
131+
# gonna assume that the first human is Kirk, and the first
132+
# vulcan is Spock.
133+
kirk = sess.retrieve(request=kirk)[0]
134+
spock = sess.retrieve(request=spock)[0]
135+
136+
# Add a relationship between Kirk and Spock
137+
kirk.add_relationships({"captain_of": {spock.get_id()}})
138+
139+
# Make sure that the new relationship is persisted
140+
sess.update(kirk)
141+
```

deploy.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
export setupfile=${1}
4+
5+
if [[ ! $setupfile ]]; then
6+
export setupfile=setup.py
7+
fi
8+
9+
rm -rf dist
10+
python3 $setupfile sdist bdist_wheel
11+
twine upload dist/*

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pytz
2+
neo4j
3+
pyyaml
4+
reggol

setup.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import setuptools
2+
3+
with open("README.md", "r") as fh:
4+
long_description = fh.read()
5+
6+
required_url = []
7+
required = []
8+
with open("requirements.txt", "r") as freq:
9+
for line in freq.read().split():
10+
if "://" in line:
11+
required_url.append(line)
12+
else:
13+
required.append(line)
14+
15+
packages = setuptools.find_packages("src")
16+
17+
setuptools.setup(
18+
name="scientio",
19+
version="0.9.0",
20+
url="https://github.com/roboy/scientio",
21+
author="Roboy",
22+
author_email="[email protected]",
23+
24+
description="ScientIO is a Knowledge Graph Engine to organise and query complex data.",
25+
long_description=long_description,
26+
long_description_content_type="text/markdown",
27+
28+
package_dir={'': 'src'},
29+
packages=packages,
30+
31+
install_requires=required,
32+
dependency_links=required_url,
33+
python_requires='>=3.7',
34+
35+
classifiers=[
36+
"Programming Language :: Python :: 3",
37+
"Operating System :: OS Independent",
38+
],
39+
)

src/scientio/__init__.py

Whitespace-only changes.

src/scientio/drivers/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)