Skip to content

Commit

Permalink
change main application back to app.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Oct 23, 2024
1 parent 26dfc7e commit cae37cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions india_forecast_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ def save_forecast(
help="Set the python logging log level",
show_default=True,
)
def app_click(timestamp: dt.datetime | None, write_to_db: bool, log_level: str):
def app(timestamp: dt.datetime | None, write_to_db: bool, log_level: str):
"""
Main click function for running forecasts for sites in India
"""

app(timestamp=timestamp, write_to_db=write_to_db, log_level=log_level)
app_run(timestamp=timestamp, write_to_db=write_to_db, log_level=log_level)


def app(timestamp: dt.datetime | None, write_to_db: bool=False, log_level: str="info"):
def app_run(timestamp: dt.datetime | None, write_to_db: bool=False, log_level: str= "info"):
"""
Main function for running forecasts for sites in India
"""
Expand Down Expand Up @@ -383,4 +383,4 @@ def app(timestamp: dt.datetime | None, write_to_db: bool=False, log_level: str="


if __name__ == "__main__":
app_click()
app()
8 changes: 4 additions & 4 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from pvsite_datamodel.sqlmodels import ForecastSQL, ForecastValueSQL, MLModelSQL, SiteAssetType

from india_forecast_app.app import (
app_run,
app,
app_click,
get_generation_data,
get_model,
get_sites,
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_app(write_to_db, db_session, sites, nwp_data, nwp_gfs_data, generation_
if write_to_db:
args.append("--write-to-db")

result = run_click_script(app_click, args)
result = run_click_script(app, args)
assert result.exit_code == 0

if write_to_db:
Expand All @@ -176,7 +176,7 @@ def test_app_no_pv_data(db_session, sites, nwp_data, nwp_gfs_data, generation_db
args = ["--date", dt.datetime.now(tz=dt.UTC).strftime("%Y-%m-%d-%H-%M")]
args.append("--write-to-db")

result = run_click_script(app_click, args)
result = run_click_script(app, args)
assert result.exit_code == 0

assert db_session.query(ForecastSQL).count() == init_n_forecasts + 2
Expand All @@ -201,4 +201,4 @@ def test_app_client_ad(
if hf_token is None:
pytest.skip("Hugging Face token not set in environment variables, skipping test.")

app(timestamp=None)
app_run(timestamp=None)

0 comments on commit cae37cb

Please sign in to comment.