bugfixes
This commit is contained in:
@@ -47,6 +47,19 @@ def parse_args() -> argparse.Namespace:
|
||||
default="ecmwf",
|
||||
help="Forecast model name when inference features require forecast columns.",
|
||||
)
|
||||
parser.set_defaults(allow_empty=True)
|
||||
parser.add_argument(
|
||||
"--allow-empty",
|
||||
dest="allow_empty",
|
||||
action="store_true",
|
||||
help="Exit successfully when required source rows are temporarily unavailable (default: enabled).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--strict-source-data",
|
||||
dest="allow_empty",
|
||||
action="store_false",
|
||||
help="Fail when required source rows are unavailable.",
|
||||
)
|
||||
parser.add_argument("--dry-run", action="store_true", help="Do not write prediction to DB.")
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -96,11 +109,28 @@ def main() -> int:
|
||||
if needs_forecast:
|
||||
forecast = fetch_forecast(conn, args.site, fetch_start, fetch_end, model=forecast_model)
|
||||
|
||||
if ws90.empty:
|
||||
message = "no ws90 observations found in source window"
|
||||
if args.allow_empty:
|
||||
print(f"Rain inference skipped: {message}.")
|
||||
return 0
|
||||
raise RuntimeError(message)
|
||||
if baro.empty:
|
||||
message = "no barometer observations found in source window"
|
||||
if args.allow_empty:
|
||||
print(f"Rain inference skipped: {message}.")
|
||||
return 0
|
||||
raise RuntimeError(message)
|
||||
|
||||
full_df = build_dataset(ws90, baro, forecast=forecast)
|
||||
feature_df = model_frame(full_df, feature_cols=features, require_target=False)
|
||||
candidates = feature_df.loc[feature_df.index <= at]
|
||||
if candidates.empty:
|
||||
raise RuntimeError("no feature-complete row available at or before requested timestamp")
|
||||
message = "no feature-complete row available at or before requested timestamp"
|
||||
if args.allow_empty:
|
||||
print(f"Rain inference skipped: {message}.")
|
||||
return 0
|
||||
raise RuntimeError(message)
|
||||
|
||||
row = candidates.tail(1)
|
||||
pred_ts = row.index[0].to_pydatetime()
|
||||
|
||||
Reference in New Issue
Block a user