Skip to content

Commit

Permalink
Adding typer annotations to validate function
Browse files Browse the repository at this point in the history
  • Loading branch information
IFenton committed Sep 18, 2024
1 parent 3521984 commit e543ace
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/cloudcasting/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import typer

from cloudcasting.download import download_satellite_data
from cloudcasting.validation import validate

# typer app code
app = typer.Typer()
app.command("download")(download_satellite_data)
app.command("validate")(lambda x: x) # placeholder
app.command("validate")(validate)
27 changes: 19 additions & 8 deletions src/cloudcasting/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@


from collections.abc import Callable
from typing import Annotated

import numpy as np
import typer
import wandb # type: ignore[import-not-found]
from torch.utils.data import DataLoader
from tqdm import tqdm
Expand Down Expand Up @@ -262,14 +264,23 @@ def calc_mean_metrics_per_channel(metrics_dict: dict[str, MetricArray]) -> dict[


def validate(
model: AbstractModel,
data_path: list[str] | str,
wandb_project_name: str,
wandb_run_name: str,
nan_to_num: bool = False,
batch_size: int = 1,
num_workers: int = 0,
batch_limit: int | None = None,
model: Annotated[AbstractModel, typer.Argument(help="Model class object to validate.")],
data_path: Annotated[list[str] | str, typer.Argument(help="Path to the validation data.")],
wandb_project_name: Annotated[
str,
typer.Argument(
help="The folder to store results on wandb - 'cloudcasting' is the main one."
),
],
wandb_run_name: Annotated[str, typer.Argument(help="Unique name for logging your run")],
nan_to_num: Annotated[
bool, typer.Option(help="Whether to convert NaNs to -1. Defaults to False.")
] = False,
batch_size: Annotated[int, typer.Option(help="Defaults to 1.")] = 1,
num_workers: Annotated[int, typer.Option(help="Defaults to 0.")] = 0,
batch_limit: Annotated[
int | None, typer.Option(help="Defaults to None. For testing purposes only.")
] = None,
) -> None:
"""Run the full validation procedure on the model and log the results to wandb.
Expand Down

0 comments on commit e543ace

Please sign in to comment.