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

Commit

Permalink
Switch click CLI to use underscores instead of dashes for consistency…
Browse files Browse the repository at this point in the history
… with JSON arg parse (#652)

* Switch commands to use underscore instead of dash

* Switch to underscore
  • Loading branch information
ethanwharris authored Aug 12, 2021
1 parent c147910 commit ddd942d
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 41 deletions.
4 changes: 2 additions & 2 deletions docs/source/reference/audio_classification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ You can run the above example with:

.. code-block:: bash
flash audio-classification
flash audio_classification
To view configuration options and options for running the audio classifier with your own data, use:

.. code-block:: bash
flash audio-classification --help
flash audio_classification --help
4 changes: 2 additions & 2 deletions docs/source/reference/graph_classification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ You can run the above example with:

.. code-block:: bash
flash graph-classifier
flash graph_classification
To view configuration options and options for running the graph classifier with your own data, use:

.. code-block:: bash
flash graph-classifier --help
flash graph_classification --help
4 changes: 2 additions & 2 deletions docs/source/reference/image_classification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ You can run the hymenoptera example with:

.. code-block:: bash
flash image-classification
flash image_classification
To view configuration options and options for running the image classifier with your own data, use:

.. code-block:: bash
flash image-classification --help
flash image_classification --help
------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/reference/image_classification_multi_label.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ You can run the movie posters example with:

.. code-block:: bash
flash image-classification from_movie_posters
flash image_classification from_movie_posters
To view configuration options and options for running the image classifier with your own data, use:

.. code-block:: bash
flash image-classification --help
flash image_classification --help
------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/reference/object_detection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ You can run the above example with:

.. code-block:: bash
flash object-detection
flash object_detection
To view configuration options and options for running the object detector with your own data, use:

.. code-block:: bash
flash object-detection --help
flash object_detection --help
4 changes: 2 additions & 2 deletions docs/source/reference/pointcloud_object_detection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ You can run the above example with:

.. code-block:: bash
flash pointcloud-detection
flash pointcloud_detection
To view configuration options and options for running the point cloud object detector with your own data, use:

.. code-block:: bash
flash pointcloud-detection --help
flash pointcloud_detection --help
4 changes: 2 additions & 2 deletions docs/source/reference/pointcloud_segmentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ You can run the above example with:

.. code-block:: bash
flash pointcloud-segmentation
flash pointcloud_segmentation
To view configuration options and options for running the point cloud segmentation task with your own data, use:

.. code-block:: bash
flash pointcloud-segmentation --help
flash pointcloud_segmentation --help
4 changes: 2 additions & 2 deletions docs/source/reference/semantic_segmentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ You can run the above example with:

.. code-block:: bash
flash semantic-segmentation
flash semantic_segmentation
To view configuration options and options for running the semantic segmentation task with your own data, use:

.. code-block:: bash
flash semantic-segmentation --help
flash semantic_segmentation --help
------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/reference/speech_recognition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ You can run the above example with:

.. code-block:: bash
flash speech-recognition
flash speech_recognition
To view configuration options and options for running the speech recognition task with your own data, use:

.. code-block:: bash
flash speech-recognition --help
flash speech_recognition --help
------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/reference/style_transfer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ You can run the above example with:

.. code-block:: bash
flash style-transfer
flash style_transfer
To view configuration options and options for running the style transfer task with your own data, use:

.. code-block:: bash
flash style-transfer --help
flash style_transfer --help
4 changes: 2 additions & 2 deletions docs/source/reference/tabular_classification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ You can run the above example with:

.. code-block:: bash
flash tabular-classifier
flash tabular_classifier
To view configuration options and options for running the tabular classifier with your own data, use:

.. code-block:: bash
flash tabular-classifier --help
flash tabular_classifier --help
------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/reference/text_classification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ You can run the above example with:

.. code-block:: bash
flash text-classifier
flash text_classification
To view configuration options and options for running the text classifier with your own data, use:

.. code-block:: bash
flash text-classifier --help
flash text_classification --help
------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/reference/text_classification_multi_label.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ You can run the above example with:

.. code-block:: bash
flash text-classifier from_toxic
flash text_classification from_toxic
To view configuration options and options for running the text classifier with your own data, use:

.. code-block:: bash
flash text-classifier --help
flash text_classification --help
------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/reference/video_classification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ You can run the above example with:

.. code-block:: bash
flash video-classifier
flash video_classification
To view configuration options and options for running the video classifier with your own data, use:

.. code-block:: bash
flash video-classifier --help
flash video_classification --help
3 changes: 2 additions & 1 deletion flash/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ def main():

def register_command(command):
@main.command(
command.__name__,
context_settings=dict(
help_option_names=[],
ignore_unknown_options=True,
)
),
)
@click.argument("cli_args", nargs=-1, type=click.UNPROCESSED)
@functools.wraps(command)
Expand Down
4 changes: 2 additions & 2 deletions flash/graph/classification/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from torch.nn import Linear

from flash.core.classification import ClassificationTask
from flash.core.utilities.imports import _TORCH_GEOMETRIC_AVAILABLE
from flash.core.utilities.imports import _GRAPH_AVAILABLE

if _TORCH_GEOMETRIC_AVAILABLE:
if _GRAPH_AVAILABLE:
from torch_geometric.nn import BatchNorm, GCNConv, global_mean_pool, MessagePassing
else:
MessagePassing = None
Expand Down
2 changes: 1 addition & 1 deletion tests/audio/classification/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@pytest.mark.skipif(not _IMAGE_AVAILABLE, reason="image libraries aren't installed.")
@pytest.mark.skipif(not _AUDIO_TESTING, reason="audio libraries aren't installed.")
def test_cli():
cli_args = ["flash", "audio-classification", "--trainer.fast_dev_run", "True"]
cli_args = ["flash", "audio_classification", "--trainer.fast_dev_run", "True"]
with mock.patch("sys.argv", cli_args):
try:
main()
Expand Down
2 changes: 1 addition & 1 deletion tests/audio/speech_recognition/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_load_from_checkpoint_dependency_error():

@pytest.mark.skipif(not _AUDIO_TESTING, reason="audio libraries aren't installed.")
def test_cli():
cli_args = ["flash", "speech-recognition", "--trainer.fast_dev_run", "True"]
cli_args = ["flash", "speech_recognition", "--trainer.fast_dev_run", "True"]
with mock.patch("sys.argv", cli_args):
try:
main()
Expand Down
2 changes: 1 addition & 1 deletion tests/graph/classification/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_predict_dataset(tmpdir):

@pytest.mark.skipif(not _GRAPH_TESTING, reason="pytorch geometric isn't installed")
def test_cli():
cli_args = ["flash", "graph-classification", "--trainer.fast_dev_run", "True"]
cli_args = ["flash", "graph_classification", "--trainer.fast_dev_run", "True"]
with mock.patch("sys.argv", cli_args):
try:
main()
Expand Down
2 changes: 1 addition & 1 deletion tests/image/classification/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_load_from_checkpoint_dependency_error():

@pytest.mark.skipif(not _IMAGE_TESTING, reason="image libraries aren't installed.")
def test_cli():
cli_args = ["flash", "image-classification", "--trainer.fast_dev_run", "True"]
cli_args = ["flash", "image_classification", "--trainer.fast_dev_run", "True"]
with mock.patch("sys.argv", cli_args):
try:
main()
Expand Down
2 changes: 1 addition & 1 deletion tests/image/detection/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_load_from_checkpoint_dependency_error():
@pytest.mark.skipif(not _IMAGE_AVAILABLE, reason="image libraries aren't installed.")
@pytest.mark.skipif(not _COCO_AVAILABLE, reason="pycocotools is not installed for testing.")
def test_cli():
cli_args = ["flash", "object-detection", "--trainer.fast_dev_run", "True"]
cli_args = ["flash", "object_detection", "--trainer.fast_dev_run", "True"]
with mock.patch("sys.argv", cli_args):
try:
main()
Expand Down
2 changes: 1 addition & 1 deletion tests/image/segmentation/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_available_pretrained_weights():

@pytest.mark.skipif(not _IMAGE_TESTING, reason="image libraries aren't installed.")
def test_cli():
cli_args = ["flash", "semantic-segmentation", "--trainer.fast_dev_run", "True"]
cli_args = ["flash", "semantic_segmentation", "--trainer.fast_dev_run", "True"]
with mock.patch("sys.argv", cli_args):
try:
main()
Expand Down
2 changes: 1 addition & 1 deletion tests/image/style_transfer/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_load_from_checkpoint_dependency_error():

@pytest.mark.skipif(not _IMAGE_TESTING, reason="image libraries aren't installed.")
def test_cli():
cli_args = ["flash", "style-transfer", "--trainer.fast_dev_run", "True"]
cli_args = ["flash", "style_transfer", "--trainer.fast_dev_run", "True"]
with mock.patch("sys.argv", cli_args):
try:
main()
Expand Down
4 changes: 2 additions & 2 deletions tests/text/classification/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def test_load_from_checkpoint_dependency_error():
@pytest.mark.parametrize(
"cli_args",
(
["flash", "text-classification", "--trainer.fast_dev_run", "True"],
["flash", "text-classification", "--trainer.fast_dev_run", "True", "from_toxic"],
["flash", "text_classification", "--trainer.fast_dev_run", "True"],
["flash", "text_classification", "--trainer.fast_dev_run", "True", "from_toxic"],
),
)
def test_cli(cli_args):
Expand Down
2 changes: 1 addition & 1 deletion tests/video/classification/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def test_load_from_checkpoint_dependency_error():

@pytest.mark.skipif(not _VIDEO_TESTING, reason="PyTorchVideo isn't installed.")
def test_cli():
cli_args = ["flash", "video-classification", "--trainer.fast_dev_run", "True", "num_workers", "0"]
cli_args = ["flash", "video_classification", "--trainer.fast_dev_run", "True", "num_workers", "0"]
with mock.patch("sys.argv", cli_args):
try:
main()
Expand Down

0 comments on commit ddd942d

Please sign in to comment.