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:
...
@@ -29,7 +29,7 @@ paths:
200
:
200
:
description
:
"
Successful
echo
of
request
data"
description
:
"
Successful
echo
of
request
data"
/location
:
/location
s
:
post
:
post
:
operationId
:
"
rest.location.post"
operationId
:
"
rest.location.post"
tags
:
tags
:
...
@@ -59,25 +59,25 @@ paths:
...
@@ -59,25 +59,25 @@ paths:
schema
:
schema
:
$ref
:
"
#/definitions/Location"
$ref
:
"
#/definitions/Location"
/cluster
:
/cluster
s
:
get
:
get
:
operationId
:
"
rest.cluster.get"
operationId
:
"
rest.cluster.get"
tags
:
tags
:
-
"
Clusters"
-
"
Clusters"
summary
:
"
Get
clustered
data
"
summary
:
"
Get
user
communities
per
date
per
hour
"
parameters
:
[]
parameters
:
[]
responses
:
responses
:
200
:
200
:
description
:
"
Successful
operation"
description
:
"
Successful
operation"
schema
:
schema
:
$ref
:
"
#/definitions/
ClusterValue
"
$ref
:
"
#/definitions/
UserCluster
"
/cluster/cluster.png
:
/cluster
s
/cluster.png
:
get
:
get
:
operationId
:
"
rest.cluster.get_image"
operationId
:
"
rest.cluster.get_image"
tags
:
tags
:
-
"
Clusters"
-
"
Clusters"
summary
:
"
Get
clustered
data
as
image"
summary
:
"
Get
user
communities
per
date
per
hour
as
image"
parameters
:
[]
parameters
:
[]
produces
:
produces
:
-
"
image/png"
-
"
image/png"
...
@@ -85,26 +85,25 @@ paths:
...
@@ -85,26 +85,25 @@ paths:
200
:
200
:
description
:
"
Successful
operation"
description
:
"
Successful
operation"
/agi/clusters
:
/agi/cluster
:
get
:
get
:
operationId
:
"
rest.agi_cluster.get"
operationId
:
"
rest.agi_cluster.get"
tags
:
tags
:
-
"
Clusters"
-
"
Clusters"
summary
:
"
Get
clustered
data"
summary
:
"
Get
user
communities
per
date
per
hour
from
agi
data"
parameters
:
[]
parameters
:
[]
responses
:
responses
:
200
:
200
:
description
:
"
Successful
operation"
description
:
"
Successful
operation"
schema
:
schema
:
$ref
:
"
#/definitions/
ClusterValue
"
$ref
:
"
#/definitions/
UserCluster
"
/agi/cluster/cluster.png
:
/agi/cluster
s
/cluster.png
:
get
:
get
:
operationId
:
"
rest.agi_cluster.get_image"
operationId
:
"
rest.agi_cluster.get_image"
tags
:
tags
:
-
"
Clusters"
-
"
Clusters"
summary
:
"
Get
clustered
data
as
image"
summary
:
"
Get
user
communities
per
date
per
hour
from
agi
data
as
image"
parameters
:
[]
parameters
:
[]
produces
:
produces
:
-
"
image/png"
-
"
image/png"
...
@@ -118,29 +117,32 @@ definitions:
...
@@ -118,29 +117,32 @@ definitions:
properties
:
properties
:
id
:
id
:
type
:
string
type
:
string
format
:
uuid
username
:
user
:
type
:
"
string"
type
:
"
string"
latitude
:
latitude
:
type
:
"
number"
type
:
"
number"
format
:
float
longitude
:
longitude
:
type
:
"
number"
type
:
"
number"
format
:
float
timestamp
:
timestamp
:
type
:
"
number"
type
:
"
number"
ClusterValue
:
UserCluster
:
type
:
"
object"
type
:
"
object"
properties
:
properties
:
id
:
id
:
type
:
string
type
:
string
format
:
uuid
date
:
cluster_label
:
type
:
number
latitude
:
type
:
number
longitude
:
type
:
number
timestamp
:
type
:
number
user
:
type
:
string
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
...
@@ -3,7 +3,7 @@ from typing import List, Dict
import
hashlib
import
hashlib
class
AgiRepository
:
class
AgiRepository
:
def
getLocations
(
self
)
->
List
:
def
getLocations
(
self
)
->
List
[
Dict
]
:
locations
=
[]
locations
=
[]
travels
=
self
.
readDataFromFile
()
travels
=
self
.
readDataFromFile
()
...
...
src/data-hub/community-detection-microservice/app/db/repository.py
View file @
62768e5d
...
@@ -11,12 +11,12 @@ from typing import List
...
@@ -11,12 +11,12 @@ from typing import List
class
Repository
(
MongoRepositoryBase
):
class
Repository
(
MongoRepositoryBase
):
def
__init__
(
self
):
def
__init__
(
self
,
agi_data
=
False
):
super
()
.
__init__
(
netconst
.
COMMUNITY_DETECTION_DB_HOSTNAME
,
super
()
.
__init__
(
netconst
.
COMMUNITY_DETECTION_DB_HOSTNAME
,
netconst
.
COMMUNITY_DETECTION_DB_PORT
,
'communityDetectionDb'
)
netconst
.
COMMUNITY_DETECTION_DB_PORT
,
'communityDetectionDb'
)
self
.
_location_collection
=
'location'
self
.
_location_collection
=
'location
_agi'
if
agi_data
else
'location
'
self
.
_cluster_collection
=
'cluster'
self
.
_cluster_collection
=
'cluster
_agi'
if
agi_data
else
'cluster
'
self
.
agi_repo
=
AgiRepository
()
self
.
agi_repo
=
AgiRepository
()
...
...
src/data-hub/community-detection-microservice/app/rest/agi_cluster.py
View file @
62768e5d
import
io
import
io
from
flask
import
request
,
Response
from
flask
import
request
,
Response
from
db.
agi.agi_repository
import
Agi
Repository
from
db.
repository
import
Repository
from
processing.clusterer
import
Clusterer
from
processing.clusterer
import
Clusterer
from
matplotlib.backends.backend_agg
import
FigureCanvasAgg
as
FigureCanvas
from
matplotlib.backends.backend_agg
import
FigureCanvasAgg
as
FigureCanvas
repo
=
AgiRepository
(
)
repo
=
Repository
(
agi_data
=
True
)
clusterer
=
Clusterer
()
clusterer
=
Clusterer
()
def
get
():
def
get
():
locations
=
repo
.
getLocations
()
clusters
=
repo
.
get_user_clusters
()
return
[
c
.
to_serializable_dict
()
for
c
in
clusters
]
clusters
=
clusterer
.
run
(
locations
)
return
clusters
def
get_image
():
def
get_image
():
return
Response
(
status
=
501
)
# todo
locations
=
repo
.
getLocations
()
locations
=
repo
.
getLocations
()
fig
=
clusterer
.
draw_locations
(
locations
)
fig
=
clusterer
.
draw_locations
(
locations
)
...
...
src/data-hub/community-detection-microservice/app/rest/cluster.py
View file @
62768e5d
...
@@ -13,6 +13,7 @@ def get():
...
@@ -13,6 +13,7 @@ def get():
def
get_image
():
def
get_image
():
return
Response
(
status
=
501
)
return
Response
(
status
=
501
)
# todo
locations
=
repo
.
getLocations
()
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
processing.clusterer
import
Clusterer
from
db.repository
import
Repository
from
db.repository
import
Repository
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
...
@@ -17,10 +23,10 @@ user_clusterer = Clusterer()
...
@@ -17,10 +23,10 @@ user_clusterer = Clusterer()
time_slices
=
list
(
range
(
24
))
time_slices
=
list
(
range
(
24
))
repo
=
Repository
()
repo
=
Repository
(
agi_data
=
True
)
def
run_clustering
():
def
run_
location_
clustering
():
user_clusters
:
List
[
UserCluster
]
=
[]
user_clusters
:
List
[
UserCluster
]
=
[]
popular_locations
:
List
[
PopularLocation
]
=
[]
popular_locations
:
List
[
PopularLocation
]
=
[]
...
@@ -135,4 +141,4 @@ def store_popular_locations(popular_locations: List[PopularLocation]):
...
@@ -135,4 +141,4 @@ def store_popular_locations(popular_locations: List[PopularLocation]):
if
__name__
==
"__main__"
:
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_HOSTNAME
=
'rabbit-mq'
RABBIT_MQ_PORT
=
5672
RABBIT_MQ_PORT
=
5672
# RABBIT_MQ_HOSTNAME = 'articonf1.itec.aau.at'
# RABBIT_MQ_PORT = 30302
MONGO_DB_HOSTNAME
=
'trace-retrieval-db'
## Trace Retrieval
MONGO_DB_PORT
=
27017
TRACE_RETRIEVAL_HOSTNAME
=
'trace-retrieval'
TRACE_RETRIEVAL_HOSTNAME
=
'trace-retrieval'
TRACE_RETRIEVAL_REST_PORT
=
80
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
## Community Detection
# HOST_IP = '143.205.173.102'
COMMUNITY_DETECTION_HOSTNAME
=
'community-detection'
COMMUNITY_DETECTION_REST_PORT
=
80
# RABBIT_MQ_HOSTNAME = HOST_IP
COMMUNITY_DETECTION_DB_HOSTNAME
=
'community-detection-db'
# RABBIT_MQ_PORT = 30302
COMMUNITY_DETECTION_DB_PORT
=
27017
# COMMUNITY_DETECTION_DB_HOSTNAME = 'localhost'
# MONGO_DB_HOSTNAME = HOST_IP
# COMMUNITY_DETECTION_DB_PORT = 30110
# MONGO_DB_PORT = 30003
\ No newline at end of file
# TRACE_RETRIEVAL_HOSTNAME = HOST_IP
# TRACE_RETRIEVAL_REST_PORT = 30001
\ 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