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
b6948a7b
Commit
b6948a7b
authored
Aug 31, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Similarity calculation per use case layers
parent
34d17494
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
34 deletions
+48
-34
swagger.yml
...role-stage-discovery-microservice/app/configs/swagger.yml
+1
-11
swagger_local.yml
...tage-discovery-microservice/app/configs/swagger_local.yml
+1
-11
layer.py
...ole-stage-discovery-microservice/app/db/entities/layer.py
+3
-1
similarityMain.py
...oservice/app/processing/similarityFiles/similarityMain.py
+17
-9
layers.py
...ub/role-stage-discovery-microservice/app/routes/layers.py
+2
-2
run_similarity_calc.py
...e-stage-discovery-microservice/app/run_similarity_calc.py
+24
-0
No files found.
src/data-hub/role-stage-discovery-microservice/app/configs/swagger.yml
View file @
b6948a7b
...
@@ -48,7 +48,7 @@ paths:
...
@@ -48,7 +48,7 @@ paths:
description
:
"
The
layer
data
to
be
added"
description
:
"
The
layer
data
to
be
added"
required
:
true
required
:
true
schema
:
schema
:
$ref
:
"
#/definitions/Layer
-UpperCase
"
$ref
:
"
#/definitions/Layer"
responses
:
responses
:
'
201'
:
'
201'
:
description
:
"
Successful
operation"
description
:
"
Successful
operation"
...
@@ -274,16 +274,6 @@ definitions:
...
@@ -274,16 +274,6 @@ definitions:
type
:
array
type
:
array
items
:
items
:
$ref
:
"
#/definitions/Cluster"
$ref
:
"
#/definitions/Cluster"
Layer-UpperCase
:
type
:
object
properties
:
LayerName
:
type
:
string
Properties
:
type
:
array
items
:
type
:
string
Layer
:
Layer
:
type
:
object
type
:
object
...
...
src/data-hub/role-stage-discovery-microservice/app/configs/swagger_local.yml
View file @
b6948a7b
...
@@ -45,7 +45,7 @@ paths:
...
@@ -45,7 +45,7 @@ paths:
description
:
"
The
layer
data
to
be
added"
description
:
"
The
layer
data
to
be
added"
required
:
true
required
:
true
schema
:
schema
:
$ref
:
"
#/definitions/Layer
-UpperCase
"
$ref
:
"
#/definitions/Layer"
responses
:
responses
:
'
201'
:
'
201'
:
description
:
"
Successful
operation"
description
:
"
Successful
operation"
...
@@ -251,16 +251,6 @@ definitions:
...
@@ -251,16 +251,6 @@ definitions:
type
:
array
type
:
array
items
:
items
:
$ref
:
"
#/definitions/Cluster"
$ref
:
"
#/definitions/Cluster"
Layer-UpperCase
:
type
:
object
properties
:
LayerName
:
type
:
string
Properties
:
type
:
array
items
:
type
:
string
Layer
:
Layer
:
type
:
object
type
:
object
...
...
src/data-hub/role-stage-discovery-microservice/app/db/entities/layer.py
View file @
b6948a7b
...
@@ -17,12 +17,14 @@ class Layer:
...
@@ -17,12 +17,14 @@ class Layer:
def
to_serializable_dict
(
self
,
for_db
=
False
)
->
Dict
:
def
to_serializable_dict
(
self
,
for_db
=
False
)
->
Dict
:
return
{
return
{
"layer_name"
:
self
.
layer_name
,
"layer_name"
:
self
.
layer_name
,
"properties"
:
self
.
properties
"properties"
:
self
.
properties
,
"use_case"
:
self
.
use_case
}
}
def
from_serializable_dict
(
self
,
layer_info
:
Dict
,
from_db
=
False
):
def
from_serializable_dict
(
self
,
layer_info
:
Dict
,
from_db
=
False
):
self
.
layer_name
=
layer_info
[
'layer_name'
]
self
.
layer_name
=
layer_info
[
'layer_name'
]
self
.
properties
=
layer_info
[
'properties'
]
self
.
properties
=
layer_info
[
'properties'
]
self
.
use_case
=
layer_info
[
'use_case'
]
def
__repr__
(
self
):
def
__repr__
(
self
):
return
json
.
dumps
(
self
.
to_serializable_dict
())
return
json
.
dumps
(
self
.
to_serializable_dict
())
...
...
src/data-hub/role-stage-discovery-microservice/app/similarityMain.py
→
src/data-hub/role-stage-discovery-microservice/app/
processing/similarityFiles/
similarityMain.py
View file @
b6948a7b
...
@@ -12,7 +12,7 @@ import os
...
@@ -12,7 +12,7 @@ import os
import
sys
import
sys
import
math
import
math
import
datetime
import
datetime
from
typing
import
Dict
from
typing
import
Dict
,
List
### init logging ###
### init logging ###
import
logging
import
logging
...
@@ -22,9 +22,9 @@ LOGGER = logging.getLogger(__name__)
...
@@ -22,9 +22,9 @@ LOGGER = logging.getLogger(__name__)
##################AUX
##################AUX
modules_path
=
'../../../modules/'
for
modules_path
in
[
'../../../modules/'
,
'./'
]:
if
os
.
path
.
exists
(
modules_path
):
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
sys
.
path
.
insert
(
1
,
modules_path
)
#### TO BE DELETED #### ^
#### TO BE DELETED #### ^
...
@@ -38,8 +38,15 @@ from processing.similarityFiles.miscFunctions import *
...
@@ -38,8 +38,15 @@ from processing.similarityFiles.miscFunctions import *
from
processing.similarityFiles.dataOutput
import
*
from
processing.similarityFiles.dataOutput
import
*
def
main
():
def
main
(
layerNameList
:
List
[
str
]
=
[
"Price_Layer"
,
"FinishedTime_Layer"
,
"Destination_Layer"
]):
print
(
"
\n
Entered Main"
)
'''
Executes the similarity calculation by calculating weights between clusters in different layers.
Then calculating the Euclidean distance between nodes in the same layer based on one other layer each.
Everything is loaded from and stored to the database.
:param layerNameList: The list of layer names as strings
'''
print
(
"Entered Similarity Main"
)
outputToFileFLAG
=
False
outputToFileFLAG
=
False
...
@@ -56,14 +63,14 @@ def main():
...
@@ -56,14 +63,14 @@ def main():
StartingTime_Layer
StartingTime_Layer
User_Layer
User_Layer
"""
"""
layerNameList
=
[
"Price_Layer"
,
"FinishedTime_Layer"
,
"Destination_Layer"
]
#Get it from somewhere else?
limitNrCluster
=
-
1
#per Layer # 0< equals noLimit
limitNrCluster
=
-
1
#per Layer # 0< equals noLimit
limitNrNodes
=
-
1
#per Layer
limitNrNodes
=
-
1
#per Layer
layerDict
=
getClusterDataFromMongo
(
layerNameList
,
limitNrCluster
,
limitNrNodes
)
layerDict
=
getClusterDataFromMongo
(
layerNameList
,
limitNrCluster
,
limitNrNodes
)
if
layerDict
is
None
or
len
(
layerDict
)
==
0
:
if
layerDict
is
None
or
len
(
layerDict
)
==
0
:
LOGGER
.
error
(
f
"No
ne
of the following layers existed: {str(layerNameList)}. Similarity calculation was not performed."
)
LOGGER
.
error
(
f
"No
data for any
of the following layers existed: {str(layerNameList)}. Similarity calculation was not performed."
)
return
return
#URLlist = None
#URLlist = None
...
@@ -116,5 +123,6 @@ def main():
...
@@ -116,5 +123,6 @@ def main():
return
return
##########START##########
##########START##########
main
()
if
__name__
is
'__main__'
:
main
()
#########FINISH##########
#########FINISH##########
src/data-hub/role-stage-discovery-microservice/app/routes/layers.py
View file @
b6948a7b
...
@@ -14,8 +14,8 @@ def post():
...
@@ -14,8 +14,8 @@ def post():
def
_insert_layer
(
layer_data
:
dict
):
def
_insert_layer
(
layer_data
:
dict
):
'''Converts object keys from external source and inserts into database.'''
'''Converts object keys from external source and inserts into database.'''
layer_data
[
'layer_name'
]
=
layer_data
.
pop
(
'LayerName'
)
#
layer_data['layer_name'] = layer_data.pop('LayerName')
layer_data
[
'properties'
]
=
layer_data
.
pop
(
'Properties'
)
#
layer_data['properties'] = layer_data.pop('Properties')
repo
.
add_layer
(
Layer
(
layer_data
))
repo
.
add_layer
(
Layer
(
layer_data
))
...
...
src/data-hub/role-stage-discovery-microservice/app/run_similarity_calc.py
0 → 100644
View file @
b6948a7b
import
processing.similarityFiles.similarityMain
as
SimilarityCalc
from
db.repository
import
Repository
repo
=
Repository
()
def
run_similarity_calc_per_use_case
():
layers
=
repo
.
get_layers
()
uc_layers
=
{}
for
layer
in
layers
:
uc
=
layer
.
use_case
if
uc
not
in
uc_layers
:
uc_layers
[
uc
]
=
[]
uc_layers
[
uc
]
.
append
(
layer
.
layer_name
)
for
key
in
uc_layers
:
layers
=
uc_layers
[
key
]
print
(
f
"Running for use case {key} with layers {str(layers)}."
)
SimilarityCalc
.
main
(
layerNameList
=
layers
)
if
__name__
==
'__main__'
:
run_similarity_calc_per_use_case
()
\ 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