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
b028f0df
Commit
b028f0df
authored
Nov 10, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fixes
parent
259e6339
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
convert_layers.py
...b/role-stage-discovery-microservice/app/convert_layers.py
+2
-3
fetching.py
...iscovery-microservice/app/processing/fetching/fetching.py
+5
-2
run_clustering.py
...b/role-stage-discovery-microservice/app/run_clustering.py
+4
-6
No files found.
src/data-hub/role-stage-discovery-microservice/app/convert_layers.py
View file @
b028f0df
...
...
@@ -15,8 +15,7 @@ repo = Repository()
def
get_clusters
(
layer_file
)
->
List
[
Cluster
]:
with
open
(
layer_file
,
'r'
)
as
file
:
clusters
=
json
.
loads
(
file
.
read
())
return
[
Cluster
(
cluster_dict
=
cluster
,
from_db
=
True
)
for
cluster
in
clusters
]
return
[
Cluster
(
cluster_dict
=
cluster
,
from_db
=
False
)
for
cluster
in
clusters
]
def
store_generic_clusters
(
clusters
:
List
[
Cluster
],
layer
):
...
...
@@ -38,7 +37,7 @@ def store_generic_clusters(clusters: List[Cluster], layer):
print
(
f
"failed uploading {layer}"
)
layers
=
[
'
Position_Layer.json'
,
'Solar_Production
_Layer.json'
]
layers
=
[
'
User_Demand
_Layer.json'
]
for
layer
in
layers
:
clusts
:
List
[
Cluster
]
=
get_clusters
(
layer
)
# print(len(clusts))
...
...
src/data-hub/role-stage-discovery-microservice/app/processing/fetching/fetching.py
View file @
b028f0df
...
...
@@ -89,8 +89,8 @@ def _fetch_nodes(use_case: str, table: str, layer_name: str) -> List[Dict]:
def
fetch_nodes_from_semantic_linking
():
'''Empties the db and inserts layers and nodes from BusinessLogic and SemanticLinking'''
repository
=
Repository
()
repository
.
delete_all_layers
()
repository
.
delete_all_nodes
()
#
repository.delete_all_layers()
#
repository.delete_all_nodes()
use_cases
=
_fetch_use_cases
()
for
use_case
in
use_cases
:
...
...
@@ -99,6 +99,9 @@ def fetch_nodes_from_semantic_linking():
tables
=
_fetch_tables
(
use_case
)
for
table
in
tables
:
if
table
!=
'bank-app'
:
continue
layers
=
_fetch_layers
(
use_case
,
table
)
for
layer
in
layers
:
...
...
src/data-hub/role-stage-discovery-microservice/app/run_clustering.py
View file @
b028f0df
...
...
@@ -17,12 +17,10 @@ repo = Repository()
def
run_generic_clustering
():
'''Runs the clustering for all layers found in the repository.'''
all_layers
:
List
[
Layer
]
=
repo
.
get_layers
()
# all_layers = [l for l in all_layers if l.layer_name in ['!Heating_Consumption_Layer', 'Position_Layer', '!Solar_Production_Layer']]
all_layers
=
[
l
for
l
in
all_layers
if
l
.
layer_name
in
[
'User_Demand_Layer'
]
and
l
.
use_case
==
'smart-energy'
]
for
layer
in
all_layers
:
# if layer.use_case != 'smart-energy':
# continue
for
layer
in
all_layers
:
print
(
f
"Clustering {layer.use_case}//{layer.use_case_table}//{layer.layer_name}."
)
if
layer
.
properties
is
None
or
len
(
layer
.
properties
)
==
0
:
...
...
@@ -53,7 +51,7 @@ def run_clustering_for_layer(layer: Layer) -> List[Cluster]:
def
store_generic_clusters
(
clusters
:
List
[
Cluster
],
layer
):
try
:
with
open
(
f
'{layer}.json'
,
'w'
)
as
file
:
cluster_dicts
=
[
c
.
to_serializable_dict
(
for_db
=
Tru
e
)
for
c
in
clusters
]
cluster_dicts
=
[
c
.
to_serializable_dict
(
for_db
=
Fals
e
)
for
c
in
clusters
]
file
.
write
(
json
.
dumps
(
cluster_dicts
))
except
:
pass
...
...
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