From af0330def57bb06ce7f3dbaeacc135b0cde25b11 Mon Sep 17 00:00:00 2001 From: Aylr Date: Wed, 22 Apr 2020 10:30:31 -0600 Subject: [PATCH] * small simple decorator for CLI methods to have consistent BETA messaging. * Made all docstrings consistent --- great_expectations/cli/datasource.py | 8 +++++--- great_expectations/cli/tap.py | 14 ++++++++++---- great_expectations/cli/util.py | 14 ++++++++++++++ tests/cli/test_datasource_pandas.py | 1 - tests/cli/test_datasource_sqlite.py | 1 - tests/cli/test_taps_pandas.py | 9 +-------- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/great_expectations/cli/datasource.py b/great_expectations/cli/datasource.py index 45888a7eb7fd..9c86c141711f 100644 --- a/great_expectations/cli/datasource.py +++ b/great_expectations/cli/datasource.py @@ -18,7 +18,9 @@ from great_expectations.cli.util import ( cli_message, cli_message_list, - cli_message_dict) + cli_message_dict, + mark_cli_as_beta, + ) from great_expectations.core import ExpectationSuite from great_expectations.core.usage_statistics.usage_statistics import send_usage_message from great_expectations.data_context.types.resource_identifiers import ( @@ -189,16 +191,16 @@ def datasource_list(directory): ) @click.option('--additional-batch-kwargs', default=None, help='Additional keyword arguments to be provided to get_batch when loading the data asset. Must be a valid JSON dictionary') +@mark_cli_as_beta def datasource_profile(datasource, batch_kwargs_generator_name, data_assets, profile_all_data_assets, directory, view, additional_batch_kwargs): """ - Profile a datasource (Beta) + Profile a datasource (BETA) If the optional data_assets and profile_all_data_assets arguments are not specified, the profiler will check if the number of data assets in the datasource exceeds the internally defined limit. If it does, it will prompt the user to either specify the list of data assets to profile or to profile all. If the limit is not exceeded, the profiler will profile all data assets in the datasource. """ - cli_message("Warning - this is a BETA feature.") try: context = DataContext(directory) except ge_exceptions.ConfigNotFoundError as err: diff --git a/great_expectations/cli/tap.py b/great_expectations/cli/tap.py index c7cd93ee0eb5..b075ee76710f 100644 --- a/great_expectations/cli/tap.py +++ b/great_expectations/cli/tap.py @@ -9,8 +9,14 @@ get_batch_kwargs, select_datasource, ) -from great_expectations.cli.util import cli_message, load_expectation_suite -from great_expectations.core.usage_statistics.usage_statistics import send_usage_message +from great_expectations.cli.util import ( + cli_message, + load_expectation_suite, + mark_cli_as_beta, +) +from great_expectations.core.usage_statistics.usage_statistics import ( + send_usage_message, +) from great_expectations.data_context.util import file_relative_path from great_expectations.util import lint_code @@ -31,9 +37,9 @@ def tap(): default=None, help="The project's great_expectations directory.", ) +@mark_cli_as_beta def tap_new(suite, tap_filename, directory, datasource=None): - """BETA! Create a new tap file for easy deployments.""" - cli_message("This is a BETA feature which may change. If you have ideas please file a GitHub issue!") + """Create a new tap file for easy deployments.""" context = _get_context(directory) try: _validate_tap_filename(tap_filename) diff --git a/great_expectations/cli/util.py b/great_expectations/cli/util.py index df0d8330f303..64b68be56ac7 100644 --- a/great_expectations/cli/util.py +++ b/great_expectations/cli/util.py @@ -1,5 +1,6 @@ import re import sys +from functools import wraps import six @@ -121,3 +122,16 @@ def load_expectation_suite(context, suite_name): ) logger.info(e) sys.exit(1) + + +def mark_cli_as_beta(func): + """Apply as a decorator to CLI commands that are in BETA.""" + @wraps(func) + def wrapper(*args, **kwargs): + cli_message( + "Heads up! This feature is in BETA. It may change. " + "Please give us your feedback!" + ) + func(*args, **kwargs) + + return wrapper diff --git a/tests/cli/test_datasource_pandas.py b/tests/cli/test_datasource_pandas.py index 1825af7b11ff..a17fad9028a0 100644 --- a/tests/cli/test_datasource_pandas.py +++ b/tests/cli/test_datasource_pandas.py @@ -145,7 +145,6 @@ def test_cli_datasource_profile_answering_no( stdout = result.stdout print(stdout) assert result.exit_code == 0 - assert "Warning - this is a BETA feature." in stdout assert "Profiling 'my_datasource'" in stdout assert "Skipping profiling for now." in stdout assert_no_logging_messages_or_tracebacks(caplog, result) diff --git a/tests/cli/test_datasource_sqlite.py b/tests/cli/test_datasource_sqlite.py index 0b77a8e5fc5e..453fe3b585d4 100644 --- a/tests/cli/test_datasource_sqlite.py +++ b/tests/cli/test_datasource_sqlite.py @@ -208,7 +208,6 @@ def test_cli_datasource_profile_answering_no( stdout = result.output assert result.exit_code == 0 - assert "Warning - this is a BETA feature." in stdout assert "Profiling 'wow_a_datasource'" in stdout assert "Skipping profiling for now." in stdout diff --git a/tests/cli/test_taps_pandas.py b/tests/cli/test_taps_pandas.py index c268a9a56ccc..6fb30e106bdb 100644 --- a/tests/cli/test_taps_pandas.py +++ b/tests/cli/test_taps_pandas.py @@ -16,7 +16,7 @@ def test_tap_help_output(caplog,): assert result.exit_code == 0 assert ( """Commands: - new BETA! Create a new tap file for easy deployments""" + new Create a new tap file for easy deployments.""" in result.stdout ) assert_no_logging_messages_or_tracebacks(caplog, result) @@ -40,7 +40,6 @@ def test_tap_new_with_filename_not_ending_in_py_raises_helpful_error( stdout = result.stdout assert result.exit_code == 1 - assert "This is a BETA feature which may change" in stdout assert "Tap filename must end in .py. Please correct and re-run" in stdout assert_no_logging_messages_or_tracebacks(caplog, result) @@ -62,7 +61,6 @@ def test_tap_new_on_context_with_no_datasources(caplog, empty_data_context): stdout = result.stdout assert result.exit_code == 1 - assert "This is a BETA feature which may change" in stdout assert "No datasources found in the context" in stdout assert_no_logging_messages_or_tracebacks(caplog, result) @@ -89,7 +87,6 @@ def test_tap_new_with_non_existant_suite(caplog, empty_data_context): stdout = result.stdout assert result.exit_code == 1 - assert "This is a BETA feature which may change" in stdout assert "Could not find a suite named `not_a_suite`" in stdout assert_no_logging_messages_or_tracebacks(caplog, result) @@ -125,7 +122,6 @@ def test_tap_new_on_context_with_2_datasources_with_no_datasource_option_prompts ) stdout = result.stdout - assert "This is a BETA feature which may change" in stdout assert "Select a datasource" in stdout assert result.exit_code == 1 @@ -166,7 +162,6 @@ def test_tap_new_on_context_builds_runnable_tap_file( ) stdout = result.stdout - assert "This is a BETA feature which may change" in stdout assert "Enter the path (relative or absolute) of a data file" in stdout assert "A new tap has been generated" in stdout assert result.exit_code == 0 @@ -229,7 +224,6 @@ def test_tap_new_on_context_builds_runnable_tap_file_that_fails_validation( ) stdout = result.stdout - assert "This is a BETA feature which may change" in stdout assert "Enter the path (relative or absolute) of a data file" in stdout assert "A new tap has been generated" in stdout assert result.exit_code == 0 @@ -281,7 +275,6 @@ def test_tap_new_on_context_with_1_datasources_with_no_datasource_option_prompts ) stdout = result.stdout - assert "This is a BETA feature which may change" in stdout assert "Select a datasource" not in stdout assert "A new tap has been generated" in stdout assert result.exit_code == 0