-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
115 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM alpine:latest | ||
RUN apk add --update \ | ||
py3-pip \ | ||
graphviz-dev \ | ||
alpine-sdk | ||
ADD . /processing/ | ||
WORKDIR /processing | ||
RUN pip3 install -r ./requirements.txt | ||
ENTRYPOINT [ "python3", "/processing/processing.py" ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
IMAGE_REPO := {{ processing_name }} | ||
IMAGE_TAG := latest | ||
IMAGE_NAME := $(IMAGE_REPO):$(IMAGE_TAG) | ||
|
||
build: | ||
docker build -t $(IMAGE_NAME) . | ||
run: build | ||
$(eval NEO4J_PORT := $(shell kubectl get svc neo4j-admin -n neo4j -o jsonpath='{.spec.ports[?(@.name=="tcp-bolt")].nodePort}')) | ||
$(eval NEO4J_HOST := $(shell minikube ip)) | ||
$(eval NEO4J_URL := bolt://$(NEO4J_HOST):$(NEO4J_PORT)) | ||
docker run --rm -it --network=host \ | ||
-e NEO4J_URL="$(NEO4J_URL)" \ | ||
$(IMAGE_NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% set p = inventory.parameters %} | ||
{% for class_name, class_data in p.knowledge_graph.items() %} | ||
# {{ class_name }} | ||
class {{ class_name }}(StructuredNode): | ||
{% for property_name, property in class_data.items() %} | ||
{{ property_name -}} = | ||
{%- if "type" in property and property.type|lower == "string" %}StringProperty() | ||
{% elif "rel_to" in property %} | ||
RelationshipTo('{{ property.rel_to.class }}', '{{ property.rel_to.type }}') | ||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% set p = inventory.parameters %} | ||
import pika | ||
import pprint | ||
import json | ||
import os | ||
from neomodel import config | ||
from neo4j import GraphDatabase | ||
|
||
from neomodel import (config, StructuredNode, StringProperty, IntegerProperty, | ||
UniqueIdProperty, RelationshipTo, One) | ||
|
||
rabbitmq_url = os.getenv("RABBITMQ_URL") | ||
neo4j_url = os.getenv("NEO4J_URL") | ||
neo4j_username = os.getenv("NEO4J_USERNAME") | ||
neo4j_password = os.getenv("NEO4J_PASSWORD") | ||
|
||
config.DRIVER = GraphDatabase().driver(neo4j_url, auth=(neo4j_username, neo4j_password)) | ||
|
||
connection = pika.BlockingConnection(pika.URLParameters(rabbitmq_url)) | ||
rabbitmq_channel = connection.channel() | ||
|
||
exchange_name = "io-context" | ||
result = rabbitmq_channel.queue_declare(queue="", exclusive=True) | ||
queue_name = result.method.queue | ||
|
||
rabbitmq_channel.queue_bind(exchange=exchange_name, queue=queue_name) | ||
|
||
{% for class_name, class_data in p.knowledge_graph.items() %} | ||
# {{ class_name }} | ||
class {{ class_name }}(StructuredNode): | ||
{% for property_name, property in class_data.items() %} | ||
{{ property_name -}} = | ||
{%- if "type" in property and property.type|lower == "string" %}StringProperty() | ||
{% elif "rel_to" in property %} | ||
RelationshipTo('{{ property.rel_to.class }}', '{{ property.rel_to.type }}') | ||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
|
||
def callback(ch, method, properties, body): | ||
{{ processing.code | indent(4) }} | ||
|
||
rabbitmq_channel.basic_consume(queue=queue_name, on_message_callback=callback, auto_ack=True) | ||
print("Waiting for messages. To exit, press Ctrl+C") | ||
rabbitmq_channel.start_consuming() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% for requirement in processing.requirements %} | ||
{{ requirement }} | ||
{% endfor %} | ||
|