diff --git a/.gitignore b/.gitignore index a1ee16f..83461d6 100644 --- a/.gitignore +++ b/.gitignore @@ -141,4 +141,5 @@ data/enhanced/ data/failed/ data/trash/ data/gtfs/ +data/tmp diff --git a/Dockerfile b/Dockerfile index 2a5dc2a..9fccc95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ EXPOSE 80 COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt -COPY ./app /app/app +COPY ./amarillo /app/amarillo COPY enhancer.py /app COPY prestart.sh /app COPY ./static /app/static @@ -33,4 +33,4 @@ COPY logging.conf /app COPY ./conf /app/conf # This image inherits uvicorn-gunicorn's CMD. If you'd like to start uvicorn, use this instead -# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] +# CMD ["uvicorn", "amarillo.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/README.md b/README.md index 5fd8b52..ee57299 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Create a virtual environment `python3 -m venv venv`. Activate the environment and install the dependencies `pip install -r requirements.txt`. -Run `uvicorn app.main:app`. +Run `uvicorn amarillo.main:app`. In development, you can use `--reload`. @@ -44,23 +44,23 @@ Permissions work this way ### GTFS-RT python bindings -In case you modify or update the proto-files in app/proto, you'll need to regenerate the python bindings. First, create the python files: +In case you modify or update the proto-files in amarillo/proto, you'll need to regenerate the python bindings. First, create the python files: ```sh -$ cd app/proto +$ cd amarillo/proto $ protoc --version libprotoc 3.21.6 $ protoc --proto_path=. --python_out=../services/gtfsrt gtfs-realtime.proto realtime_extension.proto -$ sed 's/import gtfs_realtime_pb2/import app.services.gtfsrt.gtfs_realtime_pb2/g' ../services/gtfsrt/realtime_extension_pb2.py | sponge ../services/gtfsrt/realtime_extension_pb2.py +$ sed 's/import gtfs_realtime_pb2/import amarillo.services.gtfsrt.gtfs_realtime_pb2/g' ../services/gtfsrt/realtime_extension_pb2.py | sponge ../services/gtfsrt/realtime_extension_pb2.py ``` ## Testing -In the top directory, run `pytest app/tests`. +In the top directory, run `pytest amarillo/tests`. ## Docker Based on [tiangolo/uvicorn-gunicorn:python3.9-slim](https://github.com/tiangolo/uvicorn-gunicorn-docker) - build `docker build -t amarillo .` -- run `docker run --rm --name amarillo -p 8000:80 -e ADMIN_TOKEN=$ADMIN_TOKEN -e RIDE2GO_TOKEN=$RIDE2GO_TOKEN -e TZ=Europe/Berlin -v $(pwd)/data:/app/data amarillo` +- run `docker run --rm --name amarillo -p 8000:80 -e MODULE_NAME=amarillo.main -e MAX_WORKERS="1" -e ADMIN_TOKEN=$ADMIN_TOKEN -e RIDE2GO_TOKEN=$RIDE2GO_TOKEN -e TZ=Europe/Berlin -v $(pwd)/data:/app/data amarillo` diff --git a/amarillo/__init__.py b/amarillo/__init__.py new file mode 100644 index 0000000..0260537 --- /dev/null +++ b/amarillo/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/app/configuration.py b/amarillo/configuration.py similarity index 84% rename from app/configuration.py rename to amarillo/configuration.py index 973cf4d..669c988 100644 --- a/app/configuration.py +++ b/amarillo/configuration.py @@ -1,21 +1,21 @@ # separate file so that it can be imported without initializing FastAPI -from app.utils.container import container +from amarillo.utils.container import container import json import logging from glob import glob -from app.models.Carpool import Agency, Carpool, Region -from app.services import stops -from app.services import trips -from app.services.agencyconf import AgencyConfService, agency_conf_directory -from app.services.carpools import CarpoolService -from app.services.agencies import AgencyService -from app.services.regions import RegionService +from amarillo.models.Carpool import Agency, Carpool, Region +from amarillo.services import stops +from amarillo.services import trips +from amarillo.services.agencyconf import AgencyConfService, agency_conf_directory +from amarillo.services.carpools import CarpoolService +from amarillo.services.agencies import AgencyService +from amarillo.services.regions import RegionService -from app.services.config import config +from amarillo.services.config import config -from app.utils.utils import assert_folder_exists -import app.services.gtfs_generator as gtfs_generator +from amarillo.utils.utils import assert_folder_exists +import amarillo.services.gtfs_generator as gtfs_generator logger = logging.getLogger(__name__) diff --git a/app/main.py b/amarillo/main.py similarity index 94% rename from app/main.py rename to amarillo/main.py index 9ff9cce..52dc303 100644 --- a/app/main.py +++ b/amarillo/main.py @@ -1,6 +1,6 @@ import logging.config -from app.configuration import configure_services, configure_admin_token +from amarillo.configuration import configure_services, configure_admin_token logging.config.fileConfig('logging.conf', disable_existing_loggers=False) logger = logging.getLogger("main") @@ -9,11 +9,11 @@ import mimetypes from starlette.staticfiles import StaticFiles -from app.routers import carpool, agency, agencyconf, region +from amarillo.routers import carpool, agency, agencyconf, region from fastapi import FastAPI # https://pydantic-docs.helpmanual.io/usage/settings/ -from app.views import home +from amarillo.views import home logger.info("Hello Amarillo!") diff --git a/app/models/AgencyConf.py b/amarillo/models/AgencyConf.py similarity index 100% rename from app/models/AgencyConf.py rename to amarillo/models/AgencyConf.py diff --git a/app/models/Carpool.py b/amarillo/models/Carpool.py similarity index 100% rename from app/models/Carpool.py rename to amarillo/models/Carpool.py diff --git a/app/__init__.py b/amarillo/models/__init__.py similarity index 100% rename from app/__init__.py rename to amarillo/models/__init__.py diff --git a/app/models/gtfs.py b/amarillo/models/gtfs.py similarity index 100% rename from app/models/gtfs.py rename to amarillo/models/gtfs.py diff --git a/app/proto/gtfs-realtime.proto b/amarillo/proto/gtfs-realtime.proto similarity index 100% rename from app/proto/gtfs-realtime.proto rename to amarillo/proto/gtfs-realtime.proto diff --git a/app/proto/realtime_extension.proto b/amarillo/proto/realtime_extension.proto similarity index 100% rename from app/proto/realtime_extension.proto rename to amarillo/proto/realtime_extension.proto diff --git a/app/models/__init__.py b/amarillo/routers/__init__.py similarity index 100% rename from app/models/__init__.py rename to amarillo/routers/__init__.py diff --git a/app/routers/agency.py b/amarillo/routers/agency.py similarity index 87% rename from app/routers/agency.py rename to amarillo/routers/agency.py index 4627f9a..08ab131 100644 --- a/app/routers/agency.py +++ b/amarillo/routers/agency.py @@ -4,13 +4,13 @@ from fastapi import APIRouter, HTTPException, status, Depends -from app.models.Carpool import Carpool, Agency -from app.routers.agencyconf import verify_api_key, verify_admin_api_key, verify_permission_for_same_agency_or_admin +from amarillo.models.Carpool import Carpool, Agency +from amarillo.routers.agencyconf import verify_api_key, verify_admin_api_key, verify_permission_for_same_agency_or_admin # TODO should move this to service -from app.routers.carpool import store_carpool, delete_agency_carpools_older_than -from app.services.agencies import AgencyService -from app.services.importing.ride2go import import_ride2go -from app.utils.container import container +from amarillo.routers.carpool import store_carpool, delete_agency_carpools_older_than +from amarillo.services.agencies import AgencyService +from amarillo.services.importing.ride2go import import_ride2go +from amarillo.utils.container import container from fastapi.responses import FileResponse logger = logging.getLogger(__name__) diff --git a/app/routers/agencyconf.py b/amarillo/routers/agencyconf.py similarity index 95% rename from app/routers/agencyconf.py rename to amarillo/routers/agencyconf.py index 56eac15..036cd95 100644 --- a/app/routers/agencyconf.py +++ b/amarillo/routers/agencyconf.py @@ -3,10 +3,10 @@ from fastapi import APIRouter, HTTPException, status, Header, Depends -from app.models.AgencyConf import AgencyConf -from app.services.agencyconf import AgencyConfService -from app.services.config import config -from app.utils.container import container +from amarillo.models.AgencyConf import AgencyConf +from amarillo.services.agencyconf import AgencyConfService +from amarillo.services.config import config +from amarillo.utils.container import container logger = logging.getLogger(__name__) diff --git a/app/routers/carpool.py b/amarillo/routers/carpool.py similarity index 96% rename from app/routers/carpool.py rename to amarillo/routers/carpool.py index ebd5749..1eeb96a 100644 --- a/app/routers/carpool.py +++ b/amarillo/routers/carpool.py @@ -8,9 +8,9 @@ from fastapi import APIRouter, Body, Header, HTTPException, status, Depends from datetime import datetime -from app.models.Carpool import Carpool -from app.routers.agencyconf import verify_api_key, verify_permission_for_same_agency_or_admin -from app.tests.sampledata import examples +from amarillo.models.Carpool import Carpool +from amarillo.routers.agencyconf import verify_api_key, verify_permission_for_same_agency_or_admin +from amarillo.tests.sampledata import examples logger = logging.getLogger(__name__) diff --git a/app/routers/region.py b/amarillo/routers/region.py similarity index 93% rename from app/routers/region.py rename to amarillo/routers/region.py index 156ab13..50da511 100644 --- a/app/routers/region.py +++ b/amarillo/routers/region.py @@ -4,10 +4,10 @@ from fastapi import APIRouter, HTTPException, status, Depends -from app.models.Carpool import Region -from app.routers.agencyconf import verify_admin_api_key -from app.services.regions import RegionService -from app.utils.container import container +from amarillo.models.Carpool import Region +from amarillo.routers.agencyconf import verify_admin_api_key +from amarillo.services.regions import RegionService +from amarillo.utils.container import container from fastapi.responses import FileResponse logger = logging.getLogger(__name__) diff --git a/app/routers/__init__.py b/amarillo/services/__init__.py similarity index 100% rename from app/routers/__init__.py rename to amarillo/services/__init__.py diff --git a/app/services/agencies.py b/amarillo/services/agencies.py similarity index 94% rename from app/services/agencies.py rename to amarillo/services/agencies.py index 0f3afae..47baa5a 100644 --- a/app/services/agencies.py +++ b/amarillo/services/agencies.py @@ -2,7 +2,7 @@ from glob import glob from typing import Dict -from app.models.Carpool import Agency +from amarillo.models.Carpool import Agency # TODO FG HB this service should also listen to pyinotify # because the (updated) agencies are needed in the enhancer diff --git a/app/services/agencyconf.py b/amarillo/services/agencyconf.py similarity index 97% rename from app/services/agencyconf.py rename to amarillo/services/agencyconf.py index 7d90a40..30431dc 100644 --- a/app/services/agencyconf.py +++ b/amarillo/services/agencyconf.py @@ -6,8 +6,8 @@ from fastapi import HTTPException, status -from app.models.AgencyConf import AgencyConf -from app.services.config import config +from amarillo.models.AgencyConf import AgencyConf +from amarillo.services.config import config logger = logging.getLogger(__name__) diff --git a/app/services/carpools.py b/amarillo/services/carpools.py similarity index 93% rename from app/services/carpools.py rename to amarillo/services/carpools.py index 2f173eb..7790cbc 100644 --- a/app/services/carpools.py +++ b/amarillo/services/carpools.py @@ -2,9 +2,9 @@ import logging from datetime import datetime from typing import Dict -from app.models.Carpool import Carpool -from app.services.trips import TripStore -from app.utils.utils import yesterday, is_older_than_days +from amarillo.models.Carpool import Carpool +from amarillo.services.trips import TripStore +from amarillo.utils.utils import yesterday, is_older_than_days logger = logging.getLogger(__name__) diff --git a/app/services/config.py b/amarillo/services/config.py similarity index 100% rename from app/services/config.py rename to amarillo/services/config.py diff --git a/app/services/gtfs.py b/amarillo/services/gtfs.py similarity index 95% rename from app/services/gtfs.py rename to amarillo/services/gtfs.py index ca265c3..c45a626 100644 --- a/app/services/gtfs.py +++ b/amarillo/services/gtfs.py @@ -1,6 +1,6 @@ -import app.services.gtfsrt.gtfs_realtime_pb2 as gtfs_realtime_pb2 -import app.services.gtfsrt.realtime_extension_pb2 as mfdzrte -from app.services.gtfs_constants import * +import amarillo.services.gtfsrt.gtfs_realtime_pb2 as gtfs_realtime_pb2 +import amarillo.services.gtfsrt.realtime_extension_pb2 as mfdzrte +from amarillo.services.gtfs_constants import * from google.protobuf.json_format import MessageToDict from google.protobuf.json_format import ParseDict from datetime import datetime, timedelta diff --git a/app/services/gtfs_constants.py b/amarillo/services/gtfs_constants.py similarity index 100% rename from app/services/gtfs_constants.py rename to amarillo/services/gtfs_constants.py diff --git a/app/services/gtfs_export.py b/amarillo/services/gtfs_export.py similarity index 96% rename from app/services/gtfs_export.py rename to amarillo/services/gtfs_export.py index b60af4e..fb39425 100644 --- a/app/services/gtfs_export.py +++ b/amarillo/services/gtfs_export.py @@ -7,10 +7,10 @@ import logging import re -from app.utils.utils import assert_folder_exists -from app.models.gtfs import GtfsTimeDelta, GtfsFeedInfo, GtfsAgency, GtfsRoute, GtfsStop, GtfsStopTime, GtfsTrip, GtfsCalendar, GtfsCalendarDate, GtfsShape -from app.services.stops import is_carpooling_stop -from app.services.gtfs_constants import * +from amarillo.utils.utils import assert_folder_exists +from amarillo.models.gtfs import GtfsTimeDelta, GtfsFeedInfo, GtfsAgency, GtfsRoute, GtfsStop, GtfsStopTime, GtfsTrip, GtfsCalendar, GtfsCalendarDate, GtfsShape +from amarillo.services.stops import is_carpooling_stop +from amarillo.services.gtfs_constants import * logger = logging.getLogger(__name__) diff --git a/app/services/gtfs_generator.py b/amarillo/services/gtfs_generator.py similarity index 90% rename from app/services/gtfs_generator.py rename to amarillo/services/gtfs_generator.py index 2698494..113d5db 100644 --- a/app/services/gtfs_generator.py +++ b/amarillo/services/gtfs_generator.py @@ -1,7 +1,7 @@ -from app.models.Carpool import Region -from app.services.gtfs_export import GtfsExport, GtfsFeedInfo, GtfsAgency -from app.services.gtfs import GtfsRtProducer -from app.utils.container import container +from amarillo.models.Carpool import Region +from amarillo.services.gtfs_export import GtfsExport, GtfsFeedInfo, GtfsAgency +from amarillo.services.gtfs import GtfsRtProducer +from amarillo.utils.container import container from glob import glob import json import schedule diff --git a/app/services/__init__.py b/amarillo/services/gtfsrt/__init__.py similarity index 100% rename from app/services/__init__.py rename to amarillo/services/gtfsrt/__init__.py diff --git a/app/services/gtfsrt/gtfs_realtime_pb2.py b/amarillo/services/gtfsrt/gtfs_realtime_pb2.py similarity index 100% rename from app/services/gtfsrt/gtfs_realtime_pb2.py rename to amarillo/services/gtfsrt/gtfs_realtime_pb2.py diff --git a/app/services/gtfsrt/realtime_extension_pb2.py b/amarillo/services/gtfsrt/realtime_extension_pb2.py similarity index 97% rename from app/services/gtfsrt/realtime_extension_pb2.py rename to amarillo/services/gtfsrt/realtime_extension_pb2.py index d6f5f7e..5db1fda 100644 --- a/app/services/gtfsrt/realtime_extension_pb2.py +++ b/amarillo/services/gtfsrt/realtime_extension_pb2.py @@ -11,7 +11,7 @@ _sym_db = _symbol_database.Default() -import app.services.gtfsrt.gtfs_realtime_pb2 as gtfs__realtime__pb2 +import amarillo.services.gtfsrt.gtfs_realtime_pb2 as gtfs__realtime__pb2 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x18realtime_extension.proto\x12\x10transit_realtime\x1a\x13gtfs-realtime.proto\"p\n\x1bMfdzTripDescriptorExtension\x12\x11\n\troute_url\x18\x01 \x01(\t\x12\x11\n\tagency_id\x18\x02 \x01(\t\x12\x17\n\x0froute_long_name\x18\x03 \x01(\t\x12\x12\n\nroute_type\x18\x04 \x01(\r\"\xb0\x02\n\x1fMfdzStopTimePropertiesExtension\x12X\n\x0bpickup_type\x18\x01 \x01(\x0e\x32\x43.transit_realtime.MfdzStopTimePropertiesExtension.DropOffPickupType\x12Y\n\x0c\x64ropoff_type\x18\x02 \x01(\x0e\x32\x43.transit_realtime.MfdzStopTimePropertiesExtension.DropOffPickupType\"X\n\x11\x44ropOffPickupType\x12\x0b\n\x07REGULAR\x10\x00\x12\x08\n\x04NONE\x10\x01\x12\x10\n\x0cPHONE_AGENCY\x10\x02\x12\x1a\n\x16\x43OORDINATE_WITH_DRIVER\x10\x03:i\n\x0ftrip_descriptor\x12 .transit_realtime.TripDescriptor\x18\xf5\x07 \x01(\x0b\x32-.transit_realtime.MfdzTripDescriptorExtension:\x90\x01\n\x14stop_time_properties\x12>.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties\x18\xf5\x07 \x01(\x0b\x32\x31.transit_realtime.MfdzStopTimePropertiesExtensionB\t\n\x07\x64\x65.mfdz') diff --git a/app/services/gtfsrt/__init__.py b/amarillo/services/importing/__init__.py similarity index 100% rename from app/services/gtfsrt/__init__.py rename to amarillo/services/importing/__init__.py diff --git a/app/services/importing/ride2go.py b/amarillo/services/importing/ride2go.py similarity index 93% rename from app/services/importing/ride2go.py rename to amarillo/services/importing/ride2go.py index 1578e8b..73ab5a8 100644 --- a/app/services/importing/ride2go.py +++ b/amarillo/services/importing/ride2go.py @@ -2,10 +2,10 @@ from typing import List import requests -from app.models.Carpool import Carpool, StopTime -from app.services.config import config +from amarillo.models.Carpool import Carpool, StopTime +from amarillo.services.config import config -from app.services.secrets import secrets +from amarillo.services.secrets import secrets import re logger = logging.getLogger(__name__) diff --git a/app/services/mocks.py b/amarillo/services/mocks.py similarity index 100% rename from app/services/mocks.py rename to amarillo/services/mocks.py diff --git a/app/services/regions.py b/amarillo/services/regions.py similarity index 92% rename from app/services/regions.py rename to amarillo/services/regions.py index dfb9c2c..8be79e0 100644 --- a/app/services/regions.py +++ b/amarillo/services/regions.py @@ -2,7 +2,7 @@ from glob import glob from typing import Dict -from app.models.Carpool import Region +from amarillo.models.Carpool import Region class RegionService: diff --git a/app/services/routing.py b/amarillo/services/routing.py similarity index 100% rename from app/services/routing.py rename to amarillo/services/routing.py diff --git a/app/services/secrets.py b/amarillo/services/secrets.py similarity index 100% rename from app/services/secrets.py rename to amarillo/services/secrets.py diff --git a/app/services/stops.py b/amarillo/services/stops.py similarity index 99% rename from app/services/stops.py rename to amarillo/services/stops.py index 948e489..1d3a1bd 100644 --- a/app/services/stops.py +++ b/amarillo/services/stops.py @@ -1,7 +1,7 @@ import csv import geopandas as gpd import pandas as pd -from app.models.Carpool import StopTime +from amarillo.models.Carpool import StopTime from contextlib import closing from shapely.geometry import Point, LineString from shapely.ops import transform diff --git a/app/services/trips.py b/amarillo/services/trips.py similarity index 97% rename from app/services/trips.py rename to amarillo/services/trips.py index 568c62d..fcbc21b 100644 --- a/app/services/trips.py +++ b/amarillo/services/trips.py @@ -1,10 +1,10 @@ -from app.models.gtfs import GtfsTimeDelta, GtfsStopTime -from app.models.Carpool import MAX_STOPS_PER_TRIP, Carpool, Weekday, StopTime, PickupDropoffType -from app.services.config import config -from app.services.gtfs_constants import * -from app.services.routing import RoutingService, RoutingException -from app.services.stops import is_carpooling_stop -from app.utils.utils import assert_folder_exists, is_older_than_days, yesterday, geodesic_distance_in_m +from amarillo.services.config import config +from amarillo.models.gtfs import GtfsTimeDelta, GtfsStopTime +from amarillo.models.Carpool import MAX_STOPS_PER_TRIP, Carpool, Weekday, StopTime, PickupDropoffType +from amarillo.services.gtfs_constants import * +from amarillo.services.routing import RoutingService, RoutingException +from amarillo.services.stops import is_carpooling_stop +from amarillo.utils.utils import assert_folder_exists, is_older_than_days, yesterday, geodesic_distance_in_m from shapely.geometry import Point, LineString, box from geojson_pydantic.geometries import LineString as GeoJSONLineString from datetime import datetime, timedelta diff --git a/app/services/importing/__init__.py b/amarillo/tests/__init__.py similarity index 100% rename from app/services/importing/__init__.py rename to amarillo/tests/__init__.py diff --git a/app/tests/no_test_carpool.py b/amarillo/tests/no_test_carpool.py similarity index 93% rename from app/tests/no_test_carpool.py rename to amarillo/tests/no_test_carpool.py index 6fefdc6..3db52de 100644 --- a/app/tests/no_test_carpool.py +++ b/amarillo/tests/no_test_carpool.py @@ -1,6 +1,6 @@ from fastapi.testclient import TestClient -from app.main import app -from app.tests.sampledata import carpool_1234, data1 +from amarillo.main import app +from amarillo.tests.sampledata import carpool_1234, data1 client = TestClient(app) diff --git a/app/tests/sampledata.py b/amarillo/tests/sampledata.py similarity index 97% rename from app/tests/sampledata.py rename to amarillo/tests/sampledata.py index e0d2680..60c15bf 100644 --- a/app/tests/sampledata.py +++ b/amarillo/tests/sampledata.py @@ -1,4 +1,4 @@ -from app.models.Carpool import Carpool, StopTime, Weekday +from amarillo.models.Carpool import Carpool, StopTime, Weekday # TODO use meanigful values for id and lat, lon stops_1234 = [ diff --git a/app/tests/stops.csv b/amarillo/tests/stops.csv similarity index 100% rename from app/tests/stops.csv rename to amarillo/tests/stops.csv diff --git a/app/tests/stops.json b/amarillo/tests/stops.json similarity index 100% rename from app/tests/stops.json rename to amarillo/tests/stops.json diff --git a/app/tests/test_gtfs.py b/amarillo/tests/test_gtfs.py similarity index 93% rename from app/tests/test_gtfs.py rename to amarillo/tests/test_gtfs.py index bbe6e44..61a8e5a 100644 --- a/app/tests/test_gtfs.py +++ b/amarillo/tests/test_gtfs.py @@ -1,9 +1,9 @@ -from app.tests.sampledata import carpool_1234, data1, carpool_repeating_json, stop_issue -from app.services.gtfs_export import GtfsExport -from app.services.gtfs import GtfsRtProducer -from app.services.stops import StopsStore -from app.services.trips import TripStore -from app.models.Carpool import Carpool +from amarillo.tests.sampledata import carpool_1234, data1, carpool_repeating_json, stop_issue +from amarillo.services.gtfs_export import GtfsExport +from amarillo.services.gtfs import GtfsRtProducer +from amarillo.services.stops import StopsStore +from amarillo.services.trips import TripStore +from amarillo.models.Carpool import Carpool from datetime import datetime import time import pytest diff --git a/app/tests/test_stops_store.py b/amarillo/tests/test_stops_store.py similarity index 76% rename from app/tests/test_stops_store.py rename to amarillo/tests/test_stops_store.py index fd3f8de..0dd2363 100644 --- a/app/tests/test_stops_store.py +++ b/amarillo/tests/test_stops_store.py @@ -1,8 +1,8 @@ -from app.services import stops -from app.models.Carpool import StopTime +from amarillo.services import stops +from amarillo.models.Carpool import StopTime def test_load_stops_from_file(): - store = stops.StopsStore([{"url": "app/tests/stops.csv", "vicinity": 50}]) + store = stops.StopsStore([{"url": "amarillo/tests/stops.csv", "vicinity": 50}]) store.load_stop_sources() assert len(store.stopsDataFrames[0]['stops']) > 0 @@ -17,7 +17,7 @@ def test_load_geojson_stops_from_web_(): assert len(store.stopsDataFrames[0]['stops']) > 0 def test_find_closest_stop(): - store = stops.StopsStore([{"url": "app/tests/stops.csv", "vicinity": 50}]) + store = stops.StopsStore([{"url": "amarillo/tests/stops.csv", "vicinity": 50}]) store.load_stop_sources() carpool_stop = StopTime(name="start", lat=53.1191, lon=14.01577) stop = store.find_closest_stop(carpool_stop, 1000) diff --git a/app/tests/test_trip_store.py b/amarillo/tests/test_trip_store.py similarity index 77% rename from app/tests/test_trip_store.py rename to amarillo/tests/test_trip_store.py index 438727d..96c9616 100644 --- a/app/tests/test_trip_store.py +++ b/amarillo/tests/test_trip_store.py @@ -1,6 +1,6 @@ -from app.tests.sampledata import cp1, carpool_repeating -from app.services.trips import TripStore -from app.services.stops import StopsStore +from amarillo.tests.sampledata import cp1, carpool_repeating +from amarillo.services.trips import TripStore +from amarillo.services.stops import StopsStore import logging diff --git a/app/tests/__init__.py b/amarillo/utils/__init__.py similarity index 100% rename from app/tests/__init__.py rename to amarillo/utils/__init__.py diff --git a/app/utils/container.py b/amarillo/utils/container.py similarity index 100% rename from app/utils/container.py rename to amarillo/utils/container.py diff --git a/app/utils/utils.py b/amarillo/utils/utils.py similarity index 100% rename from app/utils/utils.py rename to amarillo/utils/utils.py diff --git a/app/views/home.py b/amarillo/views/home.py similarity index 100% rename from app/views/home.py rename to amarillo/views/home.py diff --git a/app/utils/__init__.py b/app/utils/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/continuous-pull.ipy b/continuous-pull.ipy index 3654676..690ed60 100755 --- a/continuous-pull.ipy +++ b/continuous-pull.ipy @@ -11,6 +11,6 @@ while True: !git pull time.sleep(60) -# Note: when Amarillo runs with `uvicorn main:app --reload` and not with +# Note: when Amarillo runs with `uvicorn amarillo.main:app --reload` and not with # `python main.py` then there is nothing else to do. The reload happens # automatically. \ No newline at end of file diff --git a/enhancer.py b/enhancer.py index f6b87e2..1bdbb87 100644 --- a/enhancer.py +++ b/enhancer.py @@ -5,10 +5,10 @@ from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler -from app.configuration import configure_enhancer_services -from app.utils.container import container -from app.models.Carpool import Carpool -from app.utils.utils import agency_carpool_ids_from_filename +from amarillo.configuration import configure_enhancer_services +from amarillo.utils.container import container +from amarillo.models.Carpool import Carpool +from amarillo.utils.utils import agency_carpool_ids_from_filename logging.config.fileConfig('logging.conf', disable_existing_loggers=False) logger = logging.getLogger("enhancer")