diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.env b/.env index 385757b64d0670a9dfd972d2b75ff272f417e95d..ba385c5c7943ff2d3f3e4a3746c0b31f57201976 100644 --- a/.env +++ b/.env @@ -5,14 +5,15 @@ PG_PORT=5432 PG_USER="urbanite" PG_PASSWORD="password" PG_DB="urbanite" -PG_HOST="0.0.0.0" +PG_HOST="db" FLASK_SECRET_KEY="secret" # URLS of other components with ports -DATA_DIR = "/storage/app/data" -HOST_DATA_DIR = "../storage_data" -TS_URL = "http://ts:8082" -DSS_URL = "http://dss:5003" -DEXI_DIR = "/storage/app/dexi" +DATA_DIR="/storage/app/data" +ASSETS_DIR="/storage/app/app/assets" +HOST_DATA_DIR="../storage_data" +TS_URL="http://ts:8082" +DSS_URL="http://dss:5003" +DEXI_DIR="/storage/app/dexi" # city - one of "bilbao", "amsterdam", "messina", "helsinki" -URBANITE_CITY="amsterdam" -DEVELOPMENT=True \ No newline at end of file +URBANITE_CITY="bilbao" +DEVELOPMENT=True diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0c1b528c3f952f827ee2d05e64bb240b3844f99a --- /dev/null +++ b/.gitignore @@ -0,0 +1,97 @@ +.env +# Created by http://www.gitignore.io + +postgres-data/* +storage_data.zip +pg_data +storage_data + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm + +## Directory-based project format +.idea/ +# if you remove the above rule, at least ignore user-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# and these sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml + +## File-based project format +*.ipr +*.iml +*.iws + +## Additional for IntelliJ +out/ + +# generated by mpeltonen/sbt-idea +.idea_modules/ + +# generated by JIRA plugin +atlassian-ide-plugin.xml + +# generated by Crashlytics plugin (for Android Studio and Intellij) +com_crashlytics_export_strings.xml + + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +gaenv_lib/ +appengine_config.py diff --git a/app/__init__.py b/app/__init__.py index 44664399843f6f1c40dbb53a3f6c5181cd736f31..17d13bc99a87909cba8266c3b87acbfd3621be7c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -12,8 +12,6 @@ from pony.orm.dbapiprovider import OperationalError # load environment variables, add interal load_dotenv() -os.environ["DATA_DIR"] = "/storage/app/data" -os.environ["ASSETS_DIR"] = "/storage/app/assets" logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) diff --git a/app/api.py b/app/api.py index 2d8c47dfa437f5925f133a20ac50cf50a76eb770..024313e25ebbb4a73ba22c017ed24dad2aa040f0 100644 --- a/app/api.py +++ b/app/api.py @@ -13,6 +13,7 @@ from app.entities import City, Simulation, Network, Plan api_bp = Blueprint("api", __name__) data_dir = f"{app.dotenv['DATA_DIR']}/{app.dotenv['URBANITE_CITY']}" +assets_dir = f"{app.dotenv['ASSETS_DIR']}" city = app.dotenv["URBANITE_CITY"] # Endpoints for EDA @@ -50,7 +51,12 @@ def evaluated_kpis_many(): ) as file: json_obj = json.loads(file.read()) jsons[sim_id] = json_obj - return jsons + + meta_path = f"{assets_dir}/kpi_hierarchy.json" + app.logger.debug("meta path %s", meta_path) + with open(meta_path) as f: + metadata = json.load(f) + return {"data": jsons, "metadata": metadata[city]} @app.route("/storage/dss/kpis", methods=["POST"]) diff --git a/app/assets/kpi_hierarchy.json b/app/assets/kpi_hierarchy.json new file mode 100644 index 0000000000000000000000000000000000000000..daca4ed75082eddf334615fff64a70d33d8405f3 --- /dev/null +++ b/app/assets/kpi_hierarchy.json @@ -0,0 +1,35 @@ +{ + "bilbao": { + "Mobility Policy Quality": "0", + "Local": "1", + "City-wide": "1", + "Entry capacity to center": "1", + "Local Pollution": "2", + "Local Traffic": "2", + "City-wide Pollution": "2", + "City-wide Traffic": "2", + "City-wide Emissions": "3", + "City-wide Acoustic pollution": "3", + "City-wide Pedestrian travel time": "3", + "City-wide Daily internal bike travels": "3", + "Local Emissions": "3", + "Local Acoustic pollution": "3", + "Local Pedestrian travel time": "3", + "Local Daily internal bike travels": "3", + "Local NOx": "4", + "Local PM10": "4", + "Local CO2": "4", + "City-wide NOx": "4", + "City-wide PM10": "4", + "City-wide CO2": "4" + }, + "amsterdam": { + + }, + "helsinki": { + + }, + "messina": { + + } +} \ No newline at end of file