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
34d17494
Commit
34d17494
authored
Aug 31, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added config to run role-stage-discovery locally
parent
4caa4224
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
453 additions
and
2 deletions
+453
-2
swagger_local.yml
...tage-discovery-microservice/app/configs/swagger_local.yml
+442
-0
main.py
src/data-hub/role-stage-discovery-microservice/app/main.py
+11
-2
No files found.
src/data-hub/role-stage-discovery-microservice/app/configs/swagger_local.yml
0 → 100644
View file @
34d17494
swagger
:
"
2.0"
info
:
title
:
Role Stage Discovery microservice
description
:
This is the documentation for the role stage discovery microservice.
version
:
"
1.0.0"
# Import security definitions from global security definition
consumes
:
-
"
application/json"
produces
:
-
"
application/json"
basePath
:
"
/api"
paths
:
/debug
:
post
:
operationId
:
"
routes.debug.echo"
tags
:
-
"
Echo"
summary
:
"
Echo
function
for
debugging
purposes"
description
:
"
Echoes
the
input
back
to
the
caller."
parameters
:
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
responses
:
'
200'
:
description
:
"
Successful
echo
of
request
data"
#region Layers
/layers
:
post
:
operationId
:
"
routes.layers.post"
tags
:
-
"
Layers"
summary
:
"
Add
a
new
layer
[TODO:
or
overwrite
an
existing
one]"
parameters
:
-
in
:
body
name
:
"
layer"
description
:
"
The
layer
data
to
be
added"
required
:
true
schema
:
$ref
:
"
#/definitions/Layer-UpperCase"
responses
:
'
201'
:
description
:
"
Successful
operation"
'
400'
:
description
:
"
Invalid
input"
get
:
operationId
:
"
routes.layers.get"
tags
:
-
"
Layers"
summary
:
"
Get
all
layer
data"
parameters
:
[]
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/LayerCollection"
/layers/{name}
:
get
:
operationId
:
"
routes.layers.get_by_name"
tags
:
-
"
Layers"
summary
:
"
Get
single
layer
data"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
requested
layer"
required
:
true
type
:
"
string"
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/Layer"
'
404'
:
description
:
"
Layer
not
found"
/layers/{name}/nodes
:
get
:
operationId
:
"
routes.layers.get_nodes"
tags
:
-
"
Layers"
summary
:
"
Get
all
individual
nodes
for
the
layer"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
layer"
required
:
true
type
:
"
string"
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/NodeCollection"
'
404'
:
description
:
"
Layer
not
found"
post
:
operationId
:
"
routes.layers.post_nodes"
tags
:
-
"
Layers"
summary
:
"
Adds
a
single
or
multiple
nodes
to
the
layer"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
layer"
required
:
true
type
:
"
string"
-
name
:
"
node"
in
:
body
description
:
"
The
node(s)
to
be
added"
required
:
true
schema
:
$ref
:
"
#/definitions/NodeCollection"
responses
:
'
201'
:
description
:
"
Successful
operation"
'
400'
:
description
:
"
Invalid
input"
/layers/{name}/clusters
:
get
:
operationId
:
"
routes.clustersets.get_by_name"
tags
:
-
"
Layers"
summary
:
"
Get
all
clusters
for
the
layer"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
layer"
required
:
true
type
:
"
string"
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/ClusterCollection"
'
404'
:
description
:
"
Layer
not
found"
/layers/{name}/timeslices
:
get
:
operationId
:
"
routes.timeslices.get_by_name"
tags
:
-
"
Layers"
summary
:
"
Get
all
timeslices
for
the
layer"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
layer"
required
:
true
type
:
"
string"
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/TimeSliceCollection"
'
404'
:
description
:
"
Layer
not
found"
#endregion
#region Function Calls
/rfc/run
:
post
:
operationId
:
"
routes.functions.run_agi_clustering_and_graph_creation"
tags
:
-
"
Remote
function
calls"
summary
:
"
Insert
locations
from
AGI,
create
clusters
for
starting
time
and
location
layers,
create
graphs
for
the
location
clusters"
parameters
:
[]
responses
:
'
204'
:
description
:
"
Successful
operation"
#endregion
################################################################################
/connectedClusters
:
get
:
operationId
:
"
routes.connClusters.get_conn_clusters"
tags
:
-
"
Connected"
summary
:
"
Get
connected
Clusters
data"
description
:
"
Returns
a
dictionary
of
cluster.
The
clusters
contain
the
associated
connected
clusters
and
connected
nodes
data."
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/ConnectedDict"
/clusterSimilarity
:
get
:
operationId
:
"
routes.similarity.get_similarity"
tags
:
-
"
Similarity"
summary
:
"
Get
data
of
the
similarity
between
clusters."
parameters
:
-
name
:
"
layer_name"
in
:
"
query"
description
:
"
Name
of
the
layer"
required
:
true
type
:
"
string"
-
name
:
"
batchNr"
in
:
"
query"
description
:
"
Batch
number
(starting
from
0)"
required
:
true
type
:
"
integer"
description
:
"
Data
is
returned
in
batches
of
size
1000.
Returns
a
dictionary
where
the
key
is
a
tuple
of
cluster_labels
(i.e.
[0,319])
and
the
value
is
the
computed
similarity
between
2
clusters
in
the
tuple,
in
regard
to
each
layer
in
the
input.
\n
Note:
the
tuple
clusters
have
the
same
layer
and
the
computed
similarity
is
in
regard
to
clusters
from
OTHER
layers."
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/ClusterSimilarityArray"
/clusterRunArray
:
get
:
operationId
:
"
routes.connRun.get_connected_run"
tags
:
-
"
RunId"
summary
:
"
Get
RunId"
description
:
"
Returns
the
RunId
and
the
associated
datetime
when
a
connection
of
clusters/simillarity
of
clusters
was
computed."
responses
:
'
200'
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/ClusterRunArray"
definitions
:
Cluster
:
type
:
object
properties
:
layer_name
:
type
:
string
cluster_label
:
type
:
number
nodes
:
type
:
array
items
:
$ref
:
"
#/definitions/Node"
ClusterCollection
:
type
:
array
items
:
$ref
:
"
#/definitions/Cluster"
Layer-UpperCase
:
type
:
object
properties
:
LayerName
:
type
:
string
Properties
:
type
:
array
items
:
type
:
string
Layer
:
type
:
object
properties
:
layer_name
:
type
:
string
properties
:
type
:
array
items
:
type
:
string
LayerCollection
:
type
:
array
items
:
$ref
:
"
#/definitions/Layer"
Node
:
type
:
object
example
:
"
Finished_time"
:
1576631193265951
"
Latitude_Destination"
:
-5.973257
"
Longitude_Destination"
:
37.416316
"
TravelID"
:
"
5e57ec9159bc0668543f156a"
"
TravelPrice"
:
15
"
UniqueID"
:
"
a95075f5042b1b27060080156d87fe34ec7e712c5e57ec9159bc0668543f156a"
"
UserID"
:
"
a95075f5042b1b27060080156d87fe34ec7e712c"
NodeCollection
:
type
:
array
items
:
$ref
:
"
#/definitions/Node"
TimeSlice
:
type
:
object
properties
:
time
:
type
:
object
example
:
"
(2020,
52)"
layer_name
:
type
:
string
clusters
:
type
:
object
additionalProperties
:
type
:
array
items
:
type
:
object
properties
:
UniqueID
:
type
:
string
example
:
"
0"
:
-
UniqueID
:
abc
-
UniqueID
:
def
TimeSliceCollection
:
type
:
array
items
:
$ref
:
"
#/definitions/TimeSlice"
##################################################################
ConnectedDict
:
type
:
array
items
:
$ref
:
"
#/definitions/ConnectedCluster"
ConnectedCluster
:
type
:
object
properties
:
cluster_label
:
type
:
string
example
:
"
6"
cluster_layer
:
type
:
string
example
:
"
Price_Layer"
cluster_runId
:
type
:
string
example
:
"
5efdc04ac43add0aba567d76"
cluster_containedNodesDict
:
type
:
array
items
:
type
:
string
example
:
"
2696718d7a33ab3dbf28e9c88411afcfe9a933a45e57ec9159bc0668543f1568"
cluster_connNodesDict
:
type
:
array
items
:
$ref
:
"
#/definitions/ConnectedNode"
cluster_connClustDict
:
type
:
array
items
:
$ref
:
"
#/definitions/ConnectedClusterAux"
ConnectedClusterAux
:
type
:
object
properties
:
cluster_label
:
type
:
string
example
:
"
-1"
cluster_layer
:
type
:
string
example
:
"
FinishedTime_Layer"
connectionWeight
:
type
:
number
example
:
42
ConnectedNode
:
type
:
object
properties
:
node_id
:
type
:
string
node_cluster
:
type
:
string
node_layer
:
type
:
string
example
:
"
node_id"
:
"
27a08ed0facc7d68a0818c7695dad391cf48d6095e57ec9159bc0668543f159b"
"
node_cluster"
:
"
2230"
"
node_layer"
:
"
Destination_Layer"
#not used, should be removed?
#finished_time
#latitude_Destination
#longitude_Destination
#travelID
#travelPrice
#userID
ClusterSimilarityArray
:
type
:
array
items
:
$ref
:
"
#/definitions/ClusterSimilarityDictionary"
ClusterSimilarityDictionary
:
properties
:
cluster1_label
:
type
:
string
example
:
"
0"
cluster2_label
:
type
:
string
example
:
"
1"
cluster_layer
:
type
:
string
example
:
"
Price_Layer"
similarityValues
:
type
:
object
additionalProperties
:
type
:
number
example
:
"
layer_name"
:
similarityValue
"
StartingPoint_Layer"
:
39.0,
"
StartingTime_Layer"
:
99.0101004948485
runId
:
type
:
string
example
:
"
5efdc04ac43add0aba567d76"
ClusterRunArray
:
type
:
array
items
:
$ref
:
"
#/definitions/ClusterRun"
ClusterRun
:
type
:
object
properties
:
_id
:
type
:
string
example
:
"
5efdc04ac43add0aba567d76"
Datetime
:
type
:
string
example
:
"
2020-07-02
14:19:51.651764"
\ No newline at end of file
src/data-hub/role-stage-discovery-microservice/app/main.py
View file @
34d17494
...
@@ -15,11 +15,10 @@ LOGGER = logging.getLogger(__name__)
...
@@ -15,11 +15,10 @@ LOGGER = logging.getLogger(__name__)
import
connexion
import
connexion
from
security
import
swagger_util
from
security
import
swagger_util
from
pathlib
import
Path
from
pathlib
import
Path
from
env_info
import
is_running_locally
# load swagger config
# load swagger config
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'configs/'
)
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'configs/'
)
app
.
add_api
(
swagger_util
.
get_bundled_specs
(
Path
(
"configs/swagger.yml"
)),
resolver
=
connexion
.
RestyResolver
(
"cms_rest_api"
))
@
app
.
route
(
'/'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/'
,
methods
=
[
'GET'
])
def
api_root
():
def
api_root
():
...
@@ -33,6 +32,16 @@ except KeyError:
...
@@ -33,6 +32,16 @@ except KeyError:
certificate_path
=
'/srv/articonf/'
certificate_path
=
'/srv/articonf/'
context
=
(
os
.
path
.
normpath
(
f
'{certificate_path}/articonf1.crt'
),
os
.
path
.
normpath
(
f
'{certificate_path}/articonf1.key'
))
# certificate and key files
context
=
(
os
.
path
.
normpath
(
f
'{certificate_path}/articonf1.crt'
),
os
.
path
.
normpath
(
f
'{certificate_path}/articonf1.key'
))
# certificate and key files
if
is_running_locally
():
# Local Mode
print
(
"Running with local settings..."
)
app
.
add_api
(
swagger_util
.
get_bundled_specs
(
Path
(
"configs/swagger_local.yml"
)),
resolver
=
connexion
.
RestyResolver
(
"cms_rest_api"
))
context
=
'adhoc'
else
:
app
.
add_api
(
swagger_util
.
get_bundled_specs
(
Path
(
"configs/swagger.yml"
)),
resolver
=
connexion
.
RestyResolver
(
"cms_rest_api"
))
# start app
# start app
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
ssl_context
=
context
)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
ssl_context
=
context
)
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