Skip to content

Commit

Permalink
Raise if user attempts to run example with AllenNLP<2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Makoto Hiramatsu committed Mar 3, 2021
1 parent d37728c commit 53e5c33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions examples/allennlp/allennlp_jsonnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ def objective(trial):


if __name__ == "__main__":
if version.parse(allennlp.__version__) < version.parse("1.0.0"):
raise RuntimeError("AllenNLP>=1.0.0 is required for this example.")
if version.parse(allennlp.__version__) < version.parse("2.0.0"):
raise RuntimeError(
"If you want to use `allennlp<2.0.0`, please install `optuna==2.5.0`"
" and refer to the following example:"
" https://github.com/optuna/optuna/blob/v2.5.0/examples/allennlp/allennlp_jsonnet.py"
)

study = optuna.create_study(
direction="maximize",
Expand Down
6 changes: 5 additions & 1 deletion examples/allennlp/allennlp_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ def objective(trial):

if __name__ == "__main__":
if version.parse(allennlp.__version__) < version.parse("2.0.0"):
raise RuntimeError("AllenNLP>=2.0.0 is required for this example.")
raise RuntimeError(
"If you want to use `allennlp<2.0.0`, please install `optuna==2.5.0`"
" and refer to the following example:"
" https://github.com/optuna/optuna/blob/v2.5.0/examples/allennlp/allennlp_simple.py"
)

random.seed(41)
torch.manual_seed(41)
Expand Down

0 comments on commit 53e5c33

Please sign in to comment.