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
b1b2337a
Commit
b1b2337a
authored
Nov 27, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added schema information for Porto taxi data
parent
bd115b86
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
194 additions
and
3 deletions
+194
-3
env_info.py
src/modules/env_info.py
+3
-3
add_schema.py
..._use_case_scripts/community-prediction/taxi/add_schema.py
+40
-0
add_table.py
...ase_scripts/community-prediction/taxi/tables/add_table.py
+151
-0
No files found.
src/modules/env_info.py
View file @
b1b2337a
...
@@ -7,9 +7,9 @@ def get_resources_path():
...
@@ -7,9 +7,9 @@ def get_resources_path():
try
:
try
:
return
os
.
environ
[
'ARTICONF_RESOURCES_PATH'
]
return
os
.
environ
[
'ARTICONF_RESOURCES_PATH'
]
except
:
except
:
return
'/srv/articonf'
pass
else
:
return
'/srv/articonf'
return
'/srv/articonf'
def
is_running_locally
():
def
is_running_locally
():
'''Set env var ARTICONF_LOCAL=1 to run locally.'''
'''Set env var ARTICONF_LOCAL=1 to run locally.'''
...
...
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/community-prediction/taxi/add_schema.py
0 → 100644
View file @
b1b2337a
import
sys
import
os
from
pathlib
import
Path
from
typing
import
Dict
,
Any
import
requests
modules_path
=
'../../../modules/'
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
tables.add_table
as
add_table
def
add_use_case
(
use_case
:
str
):
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases"
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
{
"name"
:
use_case
}
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
if
__name__
==
"__main__"
:
# TODO strategy pattern for all the use cases where add_use_case() etc. is clear duplicate code
# The same for add table, where almost everything is the same (UniqueId, Timestamp for every Layer)
# Only need to get jwt token once in the strategy impl
use_case
=
"community-prediction-taxi"
# disable ssl warnings :)
requests
.
packages
.
urllib3
.
disable_warnings
()
add_use_case
(
use_case
)
add_table
.
main
(
use_case
=
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/community-prediction/taxi/tables/add_table.py
0 → 100644
View file @
b1b2337a
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
requests
def
add_table
(
use_case
:
str
,
table_name
:
str
):
''' Adds the use-case table with all the mappings as dict Internal -> External. '''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
mapping
=
{
c
:
c
for
c
in
[
# mapping does not change any of the names for these properties
'call_type'
,
'origin_call'
,
'origin_stand'
,
'taxi_id'
,
'timestamp'
,
'day_type'
,
'missing_data'
,
]
}
mapping
[
'start_location_lat'
]
=
'ployline[0][0]'
mapping
[
'start_location_long'
]
=
'ployline[0][1]'
mapping
[
'end_location_lat'
]
=
'ployline[-1][0]'
mapping
[
'end_location_long'
]
=
'ployline[-1][1]'
mapping
[
"UniqueID"
]
=
"trip_id"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table
=
{
"name"
:
table_name
,
"mappings"
:
mapping
}
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
table
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
def
add_layers
(
use_case
:
str
,
table_name
:
str
):
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
layers
=
[
{
"name"
:
"CallTypeLayer"
,
"properties"
:
[
"UniqueID"
,
"call_type"
,
],
"cluster_properties"
:
[
"call_type"
]
},
{
"name"
:
"DayTypeLayer"
,
"properties"
:
[
"UniqueID"
,
"day_type"
,
],
"cluster_properties"
:
[
"day_type"
]
},
{
"name"
:
"OriginCallLayer"
,
"properties"
:
[
"UniqueID"
,
"call_type"
,
"origin_call"
,
],
"cluster_properties"
:
[
"call_type"
,
"origin_call"
,
]
},
{
"name"
:
"OriginStandLayer"
,
"properties"
:
[
"UniqueID"
,
"call_type"
,
"origin_stand"
,
],
"cluster_properties"
:
[
"call_type"
,
"origin_stand"
,
]
},
{
"name"
:
"TaxiIdLayer"
,
"properties"
:
[
"UniqueID"
,
"taxi_id"
,
],
"cluster_properties"
:
[
"taxi_id"
,
]
},
{
"name"
:
"StartLocationLayer"
,
"properties"
:
[
"UniqueID"
,
"start_location_lat"
,
"start_location_long"
,
],
"cluster_properties"
:
[
"start_location_lat"
,
"start_location_long"
,
]
},
{
"name"
:
"EndLocationLayer"
,
"properties"
:
[
"UniqueID"
,
"end_location_lat"
,
"end_location_long"
,
],
"cluster_properties"
:
[
"end_location_lat"
,
"end_location_long"
,
]
},
]
for
layer
in
layers
:
# add basic info to each layer
layer
[
"use_case"
]
=
use_case
layer
[
"table"
]
=
table_name
layer
[
"properties"
]
.
append
(
"timestamp"
)
url
=
f
"https://articonf1.itec.aau.at:30420/api/layers"
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
layer
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
def
main
(
use_case
:
str
,
table_name
:
str
=
"community-prediction-taxi"
):
add_table
(
use_case
,
table_name
)
add_layers
(
use_case
,
table_name
)
\ 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