Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
8ddff38f
Commit
8ddff38f
authored
Aug 31, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
semanticLinking: SSL + message format
parent
b734c8c5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
286 additions
and
7 deletions
+286
-7
swagger_local.yml
...mantic-linking-microservice/app/configs/swagger_local.yml
+242
-0
main.py
src/data-hub/semantic-linking-microservice/app/main.py
+22
-2
MessageHandler.py
...ntic-linking-microservice/app/messaging/MessageHandler.py
+8
-2
requirements.txt
...ta-hub/semantic-linking-microservice/app/requirements.txt
+5
-0
MessageHandler.py
...ce-retrieval-microservice/app/messaging/MessageHandler.py
+9
-3
No files found.
src/data-hub/semantic-linking-microservice/app/configs/swagger_local.yml
0 → 100644
View file @
8ddff38f
swagger
:
"
2.0"
info
:
title
:
Semantic Linking microservice
description
:
This is the documentation for the semantic linking microservice.
version
:
"
1.0.0"
consumes
:
-
"
application/json"
produces
:
-
"
application/json"
basePath
:
"
/api"
paths
:
/debug
:
post
:
operationId
:
"
routes.debug.echo"
tags
:
-
"
Echo"
summary
:
"
Echo
function
for
debugging
purposes"
description
:
"
Echoes
the
input
back
to
the
caller."
parameters
:
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
responses
:
'
200'
:
description
:
"
Successful
echo
of
request
data"
#Raw_dataset region
/raw_dataset
:
post
:
operationId
:
"
routes.raw-dataset.post"
tags
:
-
"
Raw_Dataset"
summary
:
"
Add
a
new
dataset
[TODO:
or
overwrite
an
existing
one]"
parameters
:
-
in
:
body
name
:
"
raw_dataset"
description
:
"
The
raw
dataset
to
be
added"
required
:
true
schema
:
$ref
:
"
#/definitions/Dataset"
responses
:
'
201'
:
description
:
"
Successful
operation"
'
400'
:
description
:
"
Invalid
input"
get
:
operationId
:
"
routes.raw-dataset.get"
tags
:
-
"
raw_dataset"
summary
:
"
Get
all
datasets"
parameters
:
[]
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/DatasetCollection"
/raw_dataset/{name}
:
get
:
operationId
:
"
routes.raw-dataset.get_by_usecase"
tags
:
-
"
raw_dataset"
summary
:
"
Get
single
usecase
dataset"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
requested
usecase
dataset"
required
:
true
type
:
"
string"
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/Dataset"
'
404'
:
description
:
"
dataset
not
found"
#end region
#region Layers
/layers
:
get
:
operationId
:
"
routes.layers.get"
tags
:
-
"
Layers"
summary
:
"
Get
all
layer
data"
parameters
:
[]
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/LayerCollection"
/layers/{name}
:
get
:
operationId
:
"
routes.layers.get_by_name"
tags
:
-
"
Layers"
summary
:
"
Get
single
layer
data"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
requested
layer"
required
:
true
type
:
"
string"
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/Layer"
'
404'
:
description
:
"
Layer
not
found"
/layers/{name}/nodes
:
get
:
operationId
:
"
routes.layers.get_nodes"
tags
:
-
"
Layers"
summary
:
"
Get
all
individual
nodes
for
the
layer"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
layer"
required
:
true
type
:
"
string"
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/NodeCollection"
'
404'
:
description
:
"
Layer
not
found"
/multilayer
:
get
:
operationId
:
"
routes.multilayer.test_multilayer_get_function"
tags
:
-
"
Multilayer"
summary
:
"
some
demo
testing"
parameters
:
[]
responses
:
'
200'
:
description
:
"
Successful
echo
of
request
data"
/agi/multilayer/multilayer.png
:
get
:
operationId
:
"
routes.multilayer.get_image"
tags
:
-
"
Multilayer"
summary
:
"
Returning
the
multilayer
created
from
AGI
data"
parameters
:
[]
produces
:
-
"
image/png"
responses
:
'
200'
:
description
:
"
Successful
echo
of
request
data"
/graphinfo
:
get
:
operationId
:
"
routes.graphinfo.get"
tags
:
-
"
GraphInfo"
summary
:
"
Get
info
about
clustered
nodes"
description
:
"
Returns
multiple
metrics
for
all
nodes
created
by
analyzing
and
clustering
the
blockchain
traces"
parameters
:
[]
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/NodeInfo"
definitions
:
NodeInfo
:
type
:
"
object"
properties
:
label
:
type
:
string
centrality
:
type
:
number
adjacencies
:
type
:
integer
degree
:
type
:
number
betweenness
:
type
:
object
properties
:
to_node
:
type
:
integer
value
:
type
:
number
betweenness_centrality
:
type
:
number
Layer
:
type
:
object
properties
:
layer_name
:
type
:
string
properties
:
type
:
array
items
:
type
:
string
LayerCollection
:
type
:
array
items
:
$ref
:
"
#/definitions/Layer"
Dataset
:
type
:
object
properties
:
usecase_name
:
type
:
string
properties
:
type
:
array
items
:
type
:
string
DatasetCollection
:
type
:
array
items
:
$ref
:
"
#/definitions/Dataset"
Node
:
type
:
object
example
:
"
Finished_time"
:
1576631193265951
"
Latitude_Destination"
:
-5.973257
"
Longitude_Destination"
:
37.416316
"
TravelID"
:
"
5e57ec9159bc0668543f156a"
"
TravelPrice"
:
15
"
UniqueID"
:
"
a95075f5042b1b27060080156d87fe34ec7e712c5e57ec9159bc0668543f156a"
"
UserID"
:
"
a95075f5042b1b27060080156d87fe34ec7e712c"
NodeCollection
:
type
:
array
items
:
$ref
:
"
#/definitions/Node"
src/data-hub/semantic-linking-microservice/app/main.py
View file @
8ddff38f
# add modules folder to interpreter path
import
sys
import
os
import
prance
from
pathlib
import
Path
modules_path
=
'../../../modules/'
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
...
...
@@ -13,6 +15,8 @@ LOGGER = logging.getLogger(__name__)
#################################
import
connexion
from
security
import
swagger_util
from
env_info
import
is_running_locally
from
messaging.ReconnectingMessageManager
import
ReconnectingMessageManager
from
messaging.MessageHandler
import
MessageHandler
...
...
@@ -23,15 +27,31 @@ def message_received_callback(channel, method, properties, body):
# load swagger config
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'configs/'
)
app
.
add_api
(
'swagger.yml'
)
@
app
.
route
(
'/'
,
methods
=
[
'GET'
])
def
api_root
():
return
'Endpoint of semantic-linking-microservice!'
# SSL configuration
try
:
certificate_path
=
os
.
environ
[
'ARTICONF_CERTIFICATE_PATH'
]
except
KeyError
:
certificate_path
=
'/srv/articonf/'
context
=
(
os
.
path
.
normpath
(
f
'{certificate_path}/articonf1.crt'
),
os
.
path
.
normpath
(
f
'{certificate_path}/articonf1.key'
))
# certificate and key files
if
is_running_locally
():
# Local Mode
print
(
"Running with local settings..."
)
app
.
add_api
(
swagger_util
.
get_bundled_specs
(
Path
(
"configs/swagger_local.yml"
)),
resolver
=
connexion
.
RestyResolver
(
"cms_rest_api"
))
context
=
'adhoc'
else
:
app
.
add_api
(
swagger_util
.
get_bundled_specs
(
Path
(
"configs/swagger.yml"
)),
resolver
=
connexion
.
RestyResolver
(
"cms_rest_api"
))
# start app
if
__name__
==
'__main__'
:
message_manager
=
ReconnectingMessageManager
.
getInstance
()
message_manager
.
start_consuming
(
'datahub'
,
'direct'
,
'semantic-linking'
,
True
,
message_received_callback
)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
debug
=
True
,
use_reloader
=
False
)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
debug
=
True
,
use_reloader
=
False
,
ssl_context
=
context
)
src/data-hub/semantic-linking-microservice/app/messaging/MessageHandler.py
View file @
8ddff38f
import
json
import
requests
from
typing
import
Dict
from
threading
import
Thread
import
network_constants
as
netconst
...
...
@@ -24,11 +25,16 @@ class MessageHandler:
LOGGER
.
warning
(
"Message has no type field and is ignored"
)
return
if
message
[
'type'
]
==
'new-traces-available'
:
if
message
[
'type'
]
==
'new-trace'
:
self
.
handle_new_trace
(
message
[
'content'
])
elif
message
[
'type'
]
==
'new-traces-available'
:
self
.
handle_new_traces_available
()
else
:
LOGGER
.
info
(
"Message Type could not be processed"
)
def
handle_new_trace
(
self
,
content
:
Dict
):
pass
def
handle_new_traces_available
(
self
):
# get all traces and call the Processor
url
=
f
'http://{netconst.TRACE_RETRIEVAL_HOSTNAME}:{netconst.TRACE_RETRIEVAL_REST_PORT}/api/trace'
...
...
src/data-hub/semantic-linking-microservice/app/requirements.txt
View file @
8ddff38f
astroid==2.4.2
attrs==19.3.0
certifi==2020.4.5.2
cffi==1.14.2
chardet==3.0.4
click==7.1.2
clickclick==1.2.2
colorama==0.4.3
connexion==2.7.0
cryptography==3.1
Flask==1.1.2
idna==2.9
importlib-metadata==1.6.1
...
...
@@ -19,11 +21,14 @@ MarkupSafe==1.1.1
mccabe==0.6.1
openapi-spec-validator==0.2.8
pika==1.1.0
prance==0.19.0
pycparser==2.20
pylint==2.5.3
pymongo==3.10.1
pyrsistent==0.16.0
PyYAML==5.3.1
requests==2.23.0
semver==2.10.2
six==1.15.0
swagger-ui-bundle==0.0.6
toml==0.10.1
...
...
src/transaction-hub-in/trace-retrieval-microservice/app/messaging/MessageHandler.py
View file @
8ddff38f
...
...
@@ -111,6 +111,7 @@ class MessageHandler:
flattened
[
mapping
]
=
final_value
flattened
[
"UniqueID"
]
=
hashlib
.
sha256
(
flattened
[
"UniqueID"
]
.
encode
(
"utf-8"
))
.
hexdigest
()
return
flattened
def
handle_blockchain_transaction
(
self
,
transaction
:
Dict
):
...
...
@@ -146,9 +147,14 @@ class MessageHandler:
transaction
=
Transaction
(
use_case
,
flattened
)
MessageHandler
.
_repository
.
add_transaction
(
transaction
)
msg
=
json
.
dumps
(
transaction
.
to_serializable_dict
())
msg
=
{
"type"
:
"new-trace"
,
"content"
:
transaction
.
to_serializable_dict
(),
}
msg_string
=
json
.
dumps
(
msg
)
print
(
ms
g
)
print
(
"OUT: "
+
msg_strin
g
)
# inform semantic linking microservice
# self._message_sender.send_message('datahub', 'semantic-linking', msg)
\ No newline at end of file
self
.
_message_sender
.
send_message
(
'datahub'
,
'semantic-linking'
,
msg_string
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment