Commit b1b2337a authored by Alexander Lercher's avatar Alexander Lercher

Added schema information for Porto taxi data

parent bd115b86
......@@ -7,9 +7,9 @@ def get_resources_path():
try:
return os.environ['ARTICONF_RESOURCES_PATH']
except:
return '/srv/articonf'
else:
return '/srv/articonf'
pass
return '/srv/articonf'
def is_running_locally():
'''Set env var ARTICONF_LOCAL=1 to run locally.'''
......
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment