Skip to content

Commit

Permalink
improve predict command error for missing input
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed Jul 25, 2024
1 parent b3402f7 commit 21e24cb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bioimageio/core/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
save_bioimageio_package_as_folder,
)
from bioimageio.spec.dataset import DatasetDescr
from bioimageio.spec.model import ModelDescr
from bioimageio.spec.model import ModelDescr, v0_4
from bioimageio.spec.model.v0_5 import WeightsFormat
from bioimageio.spec.notebook import NotebookDescr

Expand Down Expand Up @@ -114,11 +114,19 @@ def predict(
# precomputed_stats: Path, # TODO: add arg to read precomputed stats as yaml or json
**inputs: str,
):
if "{member_id}" not in output_pattern:
raise ValueError("'{member_id}' must be included in output_pattern")

if not inputs:
model_descr = load_model_description(model, perform_io_checks=False)
input_ids = [
ipt.name if isinstance(model_descr, v0_4.ModelDescr) else ipt.id
for ipt in model_descr.inputs
]
input_flags = [f"--{ipt} <input path (pattern)>" for ipt in input_ids]
raise ValueError(
f"expected inputs {input_flags} for model {model_descr.id or model_descr.name}"
)

if "{member_id}" not in output_pattern:
raise ValueError("'{member_id}' must be included in output_pattern")

glob_matched_inputs: Dict[MemberId, List[Path]] = {}
n_glob_matches: Dict[int, List[str]] = {}
Expand Down

0 comments on commit 21e24cb

Please sign in to comment.