Skip to content

Commit

Permalink
Merge pull request #53 from projecthorus/model_download
Browse files Browse the repository at this point in the history
Added experimental model_download URL
  • Loading branch information
darksidelemm authored Sep 12, 2024
2 parents d4a194a + 3c162b5 commit cfd4ec1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion chasemapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

# Now using Semantic Versioning (https://semver.org/) MAJOR.MINOR.PATCH

__version__ = "1.5.3"
__version__ = "1.5.4"
5 changes: 3 additions & 2 deletions horusmapper.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ ascent_rate_averaging = 10
# GFS dataset already present and available.
# If you will be using the 'Download Model' button, then leave this at False, and Offline predictions
# will be enabled once a valid model is available.
# Downloading of a new model can also be triggered by running: curl http://localhost:5001/download_model
offline_predictions = False

# Predictory Binary Location
Expand All @@ -160,9 +161,9 @@ gfs_directory = ./gfs/

# Wind Model Download Command
# Optional command to enable downloading of wind data via a web client button.
# Example: (this will require copying the get_wind_data.py script to this dirctory)
# Example:
# model_download = python3 -m cusfpredict.gfs --lat=-33 --lon=139 --latdelta=10 --londelta=10 -f 24 -m 0p50 -o gfs
# The gfs directory (above) will be cleared of all .dat files prior to the above command being run.
# The gfs directory (above) will be cleared of all data files once the new model is downloaded.
model_download = none


Expand Down
22 changes: 20 additions & 2 deletions horusmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ def run_prediction():
current_payloads[_payload]["pred_path"] = []
current_payloads[_payload]["pred_landing"] = []
current_payloads[_payload]["burst"] = []
logging.error("Prediction Failed.")
logging.error("Prediction Failed, possible invalid or missing dataset.")
flask_emit_event("predictor_model_update", {"model": "Dataset invalid."})

# Abort predictions
if (
Expand Down Expand Up @@ -550,9 +551,10 @@ def run_prediction():
"Abort Prediction Updated, %d data points." % len(_pred_path)
)
else:
logging.error("Prediction Failed.")
current_payloads[_payload]["abort_path"] = []
current_payloads[_payload]["abort_landing"] = []
logging.error("Prediction Failed, possible invalid or missing dataset.")
flask_emit_event("predictor_model_update", {"model": "Dataset invalid."})
else:
# Zero the abort path and landing
current_payloads[_payload]["abort_path"] = []
Expand Down Expand Up @@ -678,6 +680,22 @@ def download_new_model(data):
flask_emit_event("predictor_model_update", {"model": _status})


@app.route("/download_model")
def download_new_model_2():
""" Trigger a download of a new weather model via a GET request """
global pred_settings, model_download_running

logging.info("Web Client Initiated request for new predictor data via /download_model.")

if pred_settings["pred_model_download"] == "none":
logging.info("No GFS model download command specified.")
return "No model download cmd."
else:
_model_cmd = pred_settings["pred_model_download"]
_status = predictor_spawn_download(_model_cmd, model_download_finished)
return _status


# Data Clearing Functions
@socketio.on("payload_data_clear", namespace="/chasemapper")
def clear_payload_data(data):
Expand Down

0 comments on commit cfd4ec1

Please sign in to comment.