Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Add to CLI and test
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwharris committed Aug 31, 2021
1 parent 37c1030 commit 28f282e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,4 @@ flash_examples/checkpoints
timit/
urban8k_images/
__MACOSX
*-v2.0.json
1 change: 1 addition & 0 deletions flash/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def wrapper(cli_args):
"flash.pointcloud.segmentation",
"flash.tabular.classification",
"flash.text.classification",
"flash.text.question_answering",
"flash.text.seq2seq.summarization",
"flash.text.seq2seq.translation",
"flash.video.classification",
Expand Down
12 changes: 12 additions & 0 deletions tests/text/question_answering/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
# limitations under the License.
import os
import re
from unittest import mock

import pytest
import torch

from flash import Trainer
from flash.__main__ import main
from flash.core.utilities.imports import _TEXT_AVAILABLE
from flash.text import QuestionAnsweringTask
from tests.helpers.utils import _TEXT_TESTING
Expand Down Expand Up @@ -58,3 +60,13 @@ def test_init_train(tmpdir):
def test_load_from_checkpoint_dependency_error():
with pytest.raises(ModuleNotFoundError, match=re.escape("'lightning-flash[text]'")):
QuestionAnsweringTask.load_from_checkpoint("not_a_real_checkpoint.pt")


@pytest.mark.skipif(not _TEXT_TESTING, reason="text libraries aren't installed.")
def test_cli():
cli_args = ["flash", "question_answering", "--trainer.fast_dev_run", "True"]
with mock.patch("sys.argv", cli_args):
try:
main()
except SystemExit:
pass

0 comments on commit 28f282e

Please sign in to comment.