Skip to content

Commit

Permalink
Add allennlp version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
himkt committed Jul 15, 2020
1 parent 79aa235 commit 40357bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions allennlp/allennlp_jsonnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
"""

import os.path
import pkg_resources
import shutil

import allennlp

import optuna
from optuna.integration.allennlp import dump_best_config
from optuna.integration import AllenNLPExecutor
Expand Down Expand Up @@ -50,6 +53,9 @@ def objective(trial):


if __name__ == "__main__":
if pkg_resources.parse_version(allennlp.__version__) < pkg_resources.parse_version("1.0.0"):
raise RuntimeError("AllenNLP>=1.0.0 is required for this example.")

study = optuna.create_study(direction="maximize")
study.optimize(objective, n_trials=50, timeout=600)

Expand Down
4 changes: 4 additions & 0 deletions allennlp/allennlp_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""

import os
import pkg_resources
import random
import shutil

Expand Down Expand Up @@ -132,6 +133,9 @@ def objective(trial):


if __name__ == "__main__":
if pkg_resources.parse_version(allennlp.__version__) < pkg_resources.parse_version("1.0.0"):
raise RuntimeError("AllenNLP>=1.0.0 is required for this example.")

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

0 comments on commit 40357bd

Please sign in to comment.