Skip to content

Commit

Permalink
Make argument epoch Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
himkt committed Aug 18, 2019
1 parent 4867ead commit ab6d893
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyner/named_entity/inference.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import pathlib
from typing import Optional

import chainer
import click
Expand All @@ -15,10 +16,10 @@

@click.command()
@click.argument("model")
@click.option("--epoch", type=int, required=True)
@click.option("--epoch", type=int)
@click.option("--device", type=int, default=-1)
@click.option("--metric", type=str, default="validation/main/fscore")
def run_inference(model: str, epoch: int, device: str, metric: str):
def run_inference(model: str, epoch: Optional[int], device: str, metric: str):
chainer.config.train = False

if device >= 0:
Expand All @@ -29,7 +30,6 @@ def run_inference(model: str, epoch: int, device: str, metric: str):
model_dir = pathlib.Path(model)
configs = json.load(open(model_dir / "args"))

metric = metric.replace("/", ".")
snapshot_file, prediction_path = select_snapshot(
epoch, metric, model, model_dir)
logger.debug(f"creat prediction into {prediction_path}")
Expand Down

0 comments on commit ab6d893

Please sign in to comment.