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
Show 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:
description
:
"
The
layer
data
to
be
added"
required
:
true
schema
:
$ref
:
"
#/definitions/Layer
-UpperCase
"
$ref
:
"
#/definitions/Layer"
responses
:
'
201'
:
description
:
"
Successful
operation"
...
...
@@ -275,16 +275,6 @@ definitions:
items
:
$ref
:
"
#/definitions/Cluster"
Layer-UpperCase
:
type
:
object
properties
:
LayerName
:
type
:
string
Properties
:
type
:
array
items
:
type
:
string
Layer
:
type
:
object
properties
:
...
...
src/data-hub/role-stage-discovery-microservice/app/configs/swagger_local.yml
View file @
b6948a7b
...
...
@@ -45,7 +45,7 @@ paths:
description
:
"
The
layer
data
to
be
added"
required
:
true
schema
:
$ref
:
"
#/definitions/Layer
-UpperCase
"
$ref
:
"
#/definitions/Layer"
responses
:
'
201'
:
description
:
"
Successful
operation"
...
...
@@ -252,16 +252,6 @@ definitions:
items
:
$ref
:
"
#/definitions/Cluster"
Layer-UpperCase
:
type
:
object
properties
:
LayerName
:
type
:
string
Properties
:
type
:
array
items
:
type
:
string
Layer
:
type
:
object
properties
:
...
...
src/data-hub/role-stage-discovery-microservice/app/db/entities/layer.py
View file @
b6948a7b
...
...
@@ -17,12 +17,14 @@ class Layer:
def
to_serializable_dict
(
self
,
for_db
=
False
)
->
Dict
:
return
{
"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
):
self
.
layer_name
=
layer_info
[
'layer_name'
]
self
.
properties
=
layer_info
[
'properties'
]
self
.
use_case
=
layer_info
[
'use_case'
]
def
__repr__
(
self
):
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
import
sys
import
math
import
datetime
from
typing
import
Dict
from
typing
import
Dict
,
List
### init logging ###
import
logging
...
...
@@ -22,8 +22,8 @@ LOGGER = logging.getLogger(__name__)
##################AUX
modules_path
=
'../../../modules/'
if
os
.
path
.
exists
(
modules_path
):
for
modules_path
in
[
'../../../modules/'
,
'./'
]:
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
#### TO BE DELETED #### ^
...
...
@@ -38,8 +38,15 @@ from processing.similarityFiles.miscFunctions import *
from
processing.similarityFiles.dataOutput
import
*
def
main
():
print
(
"
\n
Entered Main"
)
def
main
(
layerNameList
:
List
[
str
]
=
[
"Price_Layer"
,
"FinishedTime_Layer"
,
"Destination_Layer"
]):
'''
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
...
...
@@ -56,14 +63,14 @@ def main():
StartingTime_Layer
User_Layer
"""
layerNameList
=
[
"Price_Layer"
,
"FinishedTime_Layer"
,
"Destination_Layer"
]
#Get it from somewhere else?
limitNrCluster
=
-
1
#per Layer # 0< equals noLimit
limitNrNodes
=
-
1
#per Layer
layerDict
=
getClusterDataFromMongo
(
layerNameList
,
limitNrCluster
,
limitNrNodes
)
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
#URLlist = None
...
...
@@ -116,5 +123,6 @@ def main():
return
##########START##########
main
()
if
__name__
is
'__main__'
:
main
()
#########FINISH##########
src/data-hub/role-stage-discovery-microservice/app/routes/layers.py
View file @
b6948a7b
...
...
@@ -14,8 +14,8 @@ def post():
def
_insert_layer
(
layer_data
:
dict
):
'''Converts object keys from external source and inserts into database.'''
layer_data
[
'layer_name'
]
=
layer_data
.
pop
(
'LayerName'
)
layer_data
[
'properties'
]
=
layer_data
.
pop
(
'Properties'
)
#
layer_data['layer_name'] = layer_data.pop('LayerName')
#
layer_data['properties'] = layer_data.pop('Properties')
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