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
62768e5d
Commit
62768e5d
authored
Feb 05, 2020
by
Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loading agi clusters from mongodb in swagger endpoint
parent
db393636
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
54 deletions
+63
-54
swagger.yml
.../community-detection-microservice/app/configs/swagger.yml
+27
-25
agi_repository.py
...unity-detection-microservice/app/db/agi/agi_repository.py
+1
-1
repository.py
...hub/community-detection-microservice/app/db/repository.py
+3
-3
agi_cluster.py
.../community-detection-microservice/app/rest/agi_cluster.py
+7
-7
cluster.py
...-hub/community-detection-microservice/app/rest/cluster.py
+1
-0
run_clustering.py
...ub/community-detection-microservice/app/run_clustering.py
+9
-3
network_constants.py
src/modules/network_constants.py
+15
-15
No files found.
src/data-hub/community-detection-microservice/app/configs/swagger.yml
View file @
62768e5d
...
...
@@ -29,7 +29,7 @@ paths:
200
:
description
:
"
Successful
echo
of
request
data"
/location
:
/location
s
:
post
:
operationId
:
"
rest.location.post"
tags
:
...
...
@@ -59,25 +59,25 @@ paths:
schema
:
$ref
:
"
#/definitions/Location"
/cluster
:
/cluster
s
:
get
:
operationId
:
"
rest.cluster.get"
tags
:
-
"
Clusters"
summary
:
"
Get
clustered
data
"
summary
:
"
Get
user
communities
per
date
per
hour
"
parameters
:
[]
responses
:
200
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/
ClusterValue
"
$ref
:
"
#/definitions/
UserCluster
"
/cluster/cluster.png
:
/cluster
s
/cluster.png
:
get
:
operationId
:
"
rest.cluster.get_image"
tags
:
-
"
Clusters"
summary
:
"
Get
clustered
data
as
image"
summary
:
"
Get
user
communities
per
date
per
hour
as
image"
parameters
:
[]
produces
:
-
"
image/png"
...
...
@@ -85,26 +85,25 @@ paths:
200
:
description
:
"
Successful
operation"
/agi/cluster
:
/agi/clusters
:
get
:
operationId
:
"
rest.agi_cluster.get"
tags
:
-
"
Clusters"
summary
:
"
Get
clustered
data"
summary
:
"
Get
user
communities
per
date
per
hour
from
agi
data"
parameters
:
[]
responses
:
200
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/
ClusterValue
"
$ref
:
"
#/definitions/
UserCluster
"
/agi/cluster/cluster.png
:
/agi/cluster
s
/cluster.png
:
get
:
operationId
:
"
rest.agi_cluster.get_image"
tags
:
-
"
Clusters"
summary
:
"
Get
clustered
data
as
image"
summary
:
"
Get
user
communities
per
date
per
hour
from
agi
data
as
image"
parameters
:
[]
produces
:
-
"
image/png"
...
...
@@ -118,29 +117,32 @@ definitions:
properties
:
id
:
type
:
string
format
:
uuid
user
:
username
:
type
:
"
string"
latitude
:
type
:
"
number"
format
:
float
longitude
:
type
:
"
number"
format
:
float
timestamp
:
type
:
"
number"
ClusterValue
:
UserCluster
:
type
:
"
object"
properties
:
id
:
type
:
string
format
:
uuid
cluster_label
:
type
:
number
latitude
:
type
:
number
longitude
:
type
:
number
timestamp
:
type
:
number
user
:
date
:
type
:
string
hour
:
type
:
number
clusters
:
type
:
object
additionalProperties
:
type
:
array
items
:
type
:
string
example
:
0
:
[
1dc61b1a0602de0eaee9dba7eece9279c2844202
,
b4b31bbe5e12f55737e3a910827c81595fbca3eb
]
\ No newline at end of file
src/data-hub/community-detection-microservice/app/db/agi/agi_repository.py
View file @
62768e5d
...
...
@@ -3,7 +3,7 @@ from typing import List, Dict
import
hashlib
class
AgiRepository
:
def
getLocations
(
self
)
->
List
:
def
getLocations
(
self
)
->
List
[
Dict
]
:
locations
=
[]
travels
=
self
.
readDataFromFile
()
...
...
src/data-hub/community-detection-microservice/app/db/repository.py
View file @
62768e5d
...
...
@@ -11,12 +11,12 @@ from typing import List
class
Repository
(
MongoRepositoryBase
):
def
__init__
(
self
):
def
__init__
(
self
,
agi_data
=
False
):
super
()
.
__init__
(
netconst
.
COMMUNITY_DETECTION_DB_HOSTNAME
,
netconst
.
COMMUNITY_DETECTION_DB_PORT
,
'communityDetectionDb'
)
self
.
_location_collection
=
'location'
self
.
_cluster_collection
=
'cluster'
self
.
_location_collection
=
'location
_agi'
if
agi_data
else
'location
'
self
.
_cluster_collection
=
'cluster
_agi'
if
agi_data
else
'cluster
'
self
.
agi_repo
=
AgiRepository
()
...
...
src/data-hub/community-detection-microservice/app/rest/agi_cluster.py
View file @
62768e5d
import
io
from
flask
import
request
,
Response
from
db.
agi.agi_repository
import
Agi
Repository
from
db.
repository
import
Repository
from
processing.clusterer
import
Clusterer
from
matplotlib.backends.backend_agg
import
FigureCanvasAgg
as
FigureCanvas
repo
=
AgiRepository
(
)
repo
=
Repository
(
agi_data
=
True
)
clusterer
=
Clusterer
()
def
get
():
locations
=
repo
.
getLocations
()
clusters
=
clusterer
.
run
(
locations
)
return
clusters
clusters
=
repo
.
get_user_clusters
()
return
[
c
.
to_serializable_dict
()
for
c
in
clusters
]
def
get_image
():
return
Response
(
status
=
501
)
# todo
locations
=
repo
.
getLocations
()
fig
=
clusterer
.
draw_locations
(
locations
)
...
...
src/data-hub/community-detection-microservice/app/rest/cluster.py
View file @
62768e5d
...
...
@@ -13,6 +13,7 @@ def get():
def
get_image
():
return
Response
(
status
=
501
)
# todo
locations
=
repo
.
getLocations
()
...
...
src/data-hub/community-detection-microservice/app/run_clustering.py
View file @
62768e5d
import
sys
import
os
modules_path
=
'../../../modules/'
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
from
processing.clusterer
import
Clusterer
from
db.repository
import
Repository
from
datetime
import
datetime
,
timedelta
...
...
@@ -17,10 +23,10 @@ user_clusterer = Clusterer()
time_slices
=
list
(
range
(
24
))
repo
=
Repository
()
repo
=
Repository
(
agi_data
=
True
)
def
run_clustering
():
def
run_
location_
clustering
():
user_clusters
:
List
[
UserCluster
]
=
[]
popular_locations
:
List
[
PopularLocation
]
=
[]
...
...
@@ -135,4 +141,4 @@ def store_popular_locations(popular_locations: List[PopularLocation]):
if
__name__
==
"__main__"
:
run_clustering
()
run_
location_
clustering
()
src/modules/network_constants.py
View file @
62768e5d
##
# inside k8s
##
Rabbit MQ
RABBIT_MQ_HOSTNAME
=
'rabbit-mq'
RABBIT_MQ_PORT
=
5672
# RABBIT_MQ_HOSTNAME = 'articonf1.itec.aau.at'
# RABBIT_MQ_PORT = 30302
MONGO_DB_HOSTNAME
=
'trace-retrieval-db'
MONGO_DB_PORT
=
27017
## Trace Retrieval
TRACE_RETRIEVAL_HOSTNAME
=
'trace-retrieval'
TRACE_RETRIEVAL_REST_PORT
=
80
TRACE_RETRIEVAL_DB_HOSTNAME
=
'trace-retrieval-db'
TRACE_RETRIEVAL_DB_PORT
=
27017
# TRACE_RETRIEVAL_DB_HOSTNAME = 'articonf1.itec.aau.at'
# TRACE_RETRIEVAL_DB_PORT = 30003
### outside k8s
# HOST_IP = '143.205.173.102'
# RABBIT_MQ_HOSTNAME = HOST_IP
# RABBIT_MQ_PORT = 30302
# MONGO_DB_HOSTNAME = HOST_IP
# MONGO_DB_PORT = 30003
# TRACE_RETRIEVAL_HOSTNAME = HOST_IP
# TRACE_RETRIEVAL_REST_PORT = 30001
\ No newline at end of file
## Community Detection
COMMUNITY_DETECTION_HOSTNAME
=
'community-detection'
COMMUNITY_DETECTION_REST_PORT
=
80
COMMUNITY_DETECTION_DB_HOSTNAME
=
'community-detection-db'
COMMUNITY_DETECTION_DB_PORT
=
27017
# COMMUNITY_DETECTION_DB_HOSTNAME = 'localhost'
# COMMUNITY_DETECTION_DB_PORT = 30110
\ 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