-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
9,703 additions
and
96,636 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |
Oops, something went wrong.