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
bf2c831c
Commit
bf2c831c
authored
Aug 20, 2019
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workaround for trace access
parent
ee789e29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
MongoRepository.py
...b/semantic-linking-microservice/app/db/MongoRepository.py
+26
-0
MessageHandler.py
...ntic-linking-microservice/app/messaging/MessageHandler.py
+9
-0
No files found.
data-hub/semantic-linking-microservice/app/db/MongoRepository.py
0 → 100644
View file @
bf2c831c
import
pymongo
import
network_constants
as
netconst
class
MongoRepository
:
# TODO extract to docker env var
_username
=
'root'
_password
=
'root'
_collection
:
pymongo
.
collection
.
Collection
=
None
_mongo_client
:
pymongo
.
MongoClient
=
None
def
__init__
(
self
,
username
=
_username
,
password
=
_password
):
self
.
_mongo_client
=
pymongo
.
MongoClient
(
f
"mongodb://{username}:{password}@{netconst.MONGO_DB_HOSTNAME}:{netconst.MONGO_DB_PORT}/"
)
database
=
self
.
_mongo_client
[
'traceRetrievalDB'
]
self
.
_collection
=
database
[
'traces'
]
def
insert_trace
(
self
,
content
:
dict
):
self
.
_collection
.
insert_one
(
content
)
def
get_traces
(
self
,
selection
:
dict
=
{},
projection
:
dict
=
{
'_'
:
0
})
->
pymongo
.
cursor
.
Cursor
:
return
self
.
_collection
.
find
(
selection
,
projection
)
def
close_connection
(
self
):
self
.
_mongo_client
.
close
()
self
.
_collection
=
None
self
.
_mongo_client
=
None
data-hub/semantic-linking-microservice/app/messaging/MessageHandler.py
View file @
bf2c831c
import
json
import
json
import
requests
import
requests
import
network_constants
as
netconst
import
network_constants
as
netconst
from
db.MongoRepository
import
MongoRepository
from
intelligence_zahra.Processor
import
Processor
from
intelligence_zahra.Processor
import
Processor
import
logging
import
logging
...
@@ -32,6 +33,14 @@ class MessageHandler:
...
@@ -32,6 +33,14 @@ class MessageHandler:
LOGGER
.
info
(
"Message Type could not be processed"
)
LOGGER
.
info
(
"Message Type could not be processed"
)
def
handle_new_traces_available
(
self
):
def
handle_new_traces_available
(
self
):
# TODO remove workaround
repo
=
MongoRepository
()
traces
=
list
(
repo
.
get_traces
(
projection
=
{
'_id'
:
0
}))
self
.
_processor
.
process
(
traces
)
repo
.
close_connection
()
return
# get traces
# get traces
url
=
f
'http://{netconst.TRACE_RETRIEVAL_HOSTNAME}:{netconst.TRACE_RETRIEVAL_REST_PORT}/api/trace'
url
=
f
'http://{netconst.TRACE_RETRIEVAL_HOSTNAME}:{netconst.TRACE_RETRIEVAL_REST_PORT}/api/trace'
response
=
requests
.
get
(
url
)
response
=
requests
.
get
(
url
)
...
...
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