Skip to content

Commit

Permalink
* small simple decorator for CLI methods to have consistent BETA mess…
Browse files Browse the repository at this point in the history
…aging.

* Made all docstrings consistent
  • Loading branch information
Aylr committed Apr 22, 2020
1 parent db16900 commit af0330d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
8 changes: 5 additions & 3 deletions great_expectations/cli/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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("<yellow>Warning - this is a BETA feature.</yellow>")
try:
context = DataContext(directory)
except ge_exceptions.ConfigNotFoundError as err:
Expand Down
14 changes: 10 additions & 4 deletions great_expectations/cli/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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("<yellow>This is a BETA feature which may change. If you have ideas please file a GitHub issue!</yellow>")
"""Create a new tap file for easy deployments."""
context = _get_context(directory)
try:
_validate_tap_filename(tap_filename)
Expand Down
14 changes: 14 additions & 0 deletions great_expectations/cli/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import sys
from functools import wraps

import six

Expand Down Expand Up @@ -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(
"<yellow>Heads up! This feature is in BETA. It may change. "
"Please give us your feedback!</yellow>"
)
func(*args, **kwargs)

return wrapper
1 change: 0 additions & 1 deletion tests/cli/test_datasource_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/cli/test_datasource_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 1 addition & 8 deletions tests/cli/test_taps_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit af0330d

Please sign in to comment.