Skip to content

Commit

Permalink
Adding Dijkstra download
Browse files Browse the repository at this point in the history
  • Loading branch information
thdfw committed Dec 20, 2024
1 parent 3647f98 commit 391955e
Show file tree
Hide file tree
Showing 16 changed files with 9,703 additions and 96,636 deletions.
88,165 changes: 0 additions & 88,165 deletions WIP/plots_WIP.ipynb

This file was deleted.

Binary file not shown.
39 changes: 39 additions & 0 deletions analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from flo import DGraph
from named_types import FloParamsHouse0
import dotenv
import pendulum
from sqlalchemy import create_engine, desc
from sqlalchemy.orm import sessionmaker
from fake_config import Settings
from fake_models import MessageSql

def download_excel(house_alias, start_ms):
settings = Settings(_env_file=dotenv.find_dotenv())
engine = create_engine(settings.db_url.get_secret_value())
Session = sessionmaker(bind=engine)
session = Session()

house_alias = 'beech'
start_ms = int(pendulum.datetime(2024, 12, 19, 0, 0, tz="America/New_York").timestamp() * 1000)
end_ms = int(pendulum.datetime(2024, 12, 21, 0, 0, tz="America/New_York").timestamp() * 1000)

flo_params_msg = session.query(MessageSql).filter(
MessageSql.message_type_name == "flo.params.house0",
MessageSql.from_alias.like(f'%{house_alias}%'),
MessageSql.message_persisted_ms >= start_ms - 48*3600*1000,
MessageSql.message_persisted_ms <= start_ms,
).order_by(desc(MessageSql.message_persisted_ms)).first()

if not flo_params_msg:
print("No FLO params")
return

flo_params = FloParamsHouse0(**flo_params_msg.payload)
# for key, value in flo_params_msg.payload.items():
# print(f'{key}: {value}')

print("Running Dijkstra and saving analysis to excel...")
g = DGraph(flo_params)
g.solve_dijkstra()
g.export_to_excel()
print("Done.")
Loading

0 comments on commit 391955e

Please sign in to comment.