Skip to content

Commit

Permalink
Comment out Fybr realtime availability API
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoyame committed Jun 18, 2022
1 parent 45f6b72 commit 2eeb271
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,34 @@
from quart import Quart, jsonify, request

from app import keeper_of_the_state, now_adjusted, predictor
from app.fybr import zone_info
from app.fybr.availability_provider import FybrAvailabilityProvider

# from app.fybr import zone_info
# from app.fybr.availability_provider import FybrAvailabilityProvider

#logging.basicConfig(filename='app/example.log', level=logging.DEBUG)

LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.INFO)

app = Quart(__name__)

app.fybr_availability_provider = FybrAvailabilityProvider(
'wss://streams.smartcolumbusos.com/socket/websocket',
[]
)
# app.fybr_availability_provider = FybrAvailabilityProvider(
# 'wss://streams.smartcolumbusos.com/socket/websocket',
# []
# )


@app.before_serving
async def startup():
LOGGER.info('starting API')
app.fybr_availability_provider = FybrAvailabilityProvider(
'wss://streams.smartcolumbusos.com/socket/websocket',
zone_info.meter_and_zone_list()
)
# app.fybr_availability_provider = FybrAvailabilityProvider(
# 'wss://streams.smartcolumbusos.com/socket/websocket',
# zone_info.meter_and_zone_list()
# )
loop = asyncio.get_event_loop()

LOGGER.info('Scheduling availability cache to be filled from stream')
app.fybr_availability_streamer = loop.create_task(app.fybr_availability_provider.handle_websocket_messages())
# LOGGER.info('Scheduling availability cache to be filled from stream')
# app.fybr_availability_streamer = loop.create_task(app.fybr_availability_provider.handle_websocket_messages())
LOGGER.info('Scheduling model and zone caches to be re-warmed periodically')
app.model_fetcher = loop.create_task(keeper_of_the_state.fetch_state_periodically())
LOGGER.info('Finished starting API')
Expand All @@ -43,7 +46,7 @@ async def startup():

@app.after_serving
async def shutdown():
app.fybr_availability_streamer.cancel()
# app.fybr_availability_streamer.cancel()
app.model_fetcher.cancel()


Expand All @@ -60,7 +63,7 @@ async def predictions():
availability = predictor.predict(now, zone_ids)

prediction_transforms = [
_override_availability_predictions_with_known_values,
# _override_availability_predictions_with_known_values,
predictor.to_api_format,
jsonify
]
Expand Down Expand Up @@ -100,9 +103,9 @@ async def predictions_comparative():
return jsonify(results)


@app.route('/api/v1/availability')
async def availability():
return jsonify(app.fybr_availability_provider.get_all_availability())
# @app.route('/api/v1/availability')
# async def availability():
# return jsonify(app.fybr_availability_provider.get_all_availability())


if __name__ == '__main__':
Expand Down

0 comments on commit 2eeb271

Please sign in to comment.