Exemplo n.º 1
0
def checkpoint(ctx: click.Context) -> None:
    """
    Checkpoint operations

    A Checkpoint is a bundle of one or more batches of data with one or more
    Expectation Suites.

    A Checkpoint can be as simple as one batch of data paired with one
    Expectation Suite.

    A Checkpoint can be as complex as many batches of data across different
    datasources paired with one or more Expectation Suites each.
    """
    ctx.obj.data_context = ctx.obj.get_data_context_from_config_file()

    cli_event_noun: str = "checkpoint"
    (
        begin_event_name,
        end_event_name,
    ) = UsageStatsEvents.get_cli_begin_and_end_event_names(
        noun=cli_event_noun,
        verb=ctx.invoked_subcommand,
    )
    send_usage_message(
        data_context=ctx.obj.data_context,
        event=begin_event_name,
        success=True,
    )
    ctx.obj.usage_event_end = end_event_name
Exemplo n.º 2
0
def test_comprehensive_list_of_messages():
    """Ensure that we have a comprehensive set of tests for known messages, by
    forcing a manual update to this list when a message is added or removed, and
    reminding the developer to add or remove the associate test."""
    valid_message_list = list(valid_usage_statistics_messages.keys())
    # NOTE: If you are changing the expected valid message list below, you need
    # to also update one or more tests below!

    assert set(valid_message_list) == {
        "cli.checkpoint.delete",
        "cli.checkpoint.list",
        "cli.checkpoint.new",
        "cli.checkpoint.run",
        "cli.checkpoint.script",
        "cli.datasource.delete",
        "cli.datasource.list",
        "cli.datasource.new",
        "cli.datasource.profile",
        "cli.docs.build",
        "cli.docs.clean",
        "cli.docs.list",
        "cli.init.create",
        "cli.new_ds_choice",
        "cli.project.check_config",
        "cli.project.upgrade",
        "cli.store.list",
        "cli.suite.delete",
        "cli.suite.demo",
        "cli.suite.edit",
        "cli.suite.list",
        "cli.suite.new",
        "cli.suite.scaffold",
        "cli.validation_operator.list",
        "cli.validation_operator.run",
        "data_asset.validate",
        "data_context.__init__",
        "data_context.add_datasource",
        "data_context.get_batch_list",
        "data_context.build_data_docs",
        "data_context.open_data_docs",
        "data_context.run_checkpoint",
        "data_context.save_expectation_suite",
        "data_context.test_yaml_config",
        "data_context.run_validation_operator",
        "datasource.sqlalchemy.connect",
        "execution_engine.sqlalchemy.connect",
        "checkpoint.run",
        "expectation_suite.add_expectation",
        "legacy_profiler.build_suite",
        "profiler.run",
        "data_context.run_profiler_on_data",
        "data_context.run_profiler_with_dynamic_arguments",
        "profiler.result.get_expectation_suite",
        "data_assistant.result.get_expectation_suite",
    }
    # Note: "cli.project.upgrade" has no base event, only .begin and .end events
    assert set(valid_message_list) == set(
        UsageStatsEvents.get_all_event_names_no_begin_end_events() +
        ["cli.project.upgrade"])
Exemplo n.º 3
0
def test_all_events_are_in_event_validation_schema(
    all_events_from_anonymized_usage_statistics_record_schema,
):
    """What does this test and why?

    This test ensures that all of the usage stats events that we are sending are accounted for in our
    event validation schema.
    """
    events_in_schema: List[
        str
    ] = all_events_from_anonymized_usage_statistics_record_schema

    assert set(events_in_schema) == set(UsageStatsEvents.get_all_event_names())
Exemplo n.º 4
0
def datasource(ctx: click.Context) -> None:
    """Datasource operations"""
    ctx.obj.data_context = ctx.obj.get_data_context_from_config_file()

    cli_event_noun: str = "datasource"
    (
        begin_event_name,
        end_event_name,
    ) = UsageStatsEvents.get_cli_begin_and_end_event_names(
        noun=cli_event_noun,
        verb=ctx.invoked_subcommand,
    )
    send_usage_message(
        data_context=ctx.obj.data_context,
        event=begin_event_name,
        success=True,
    )
    ctx.obj.usage_event_end = end_event_name
Exemplo n.º 5
0
def test_get_cli_begin_and_end_event_names():
    assert UsageStatsEvents.get_cli_begin_and_end_event_names(
        "datasource", "new") == [
            "cli.datasource.new.begin",
            "cli.datasource.new.end",
        ]
Exemplo n.º 6
0
def test_get_cli_event_name():
    assert (UsageStatsEvents.get_cli_event_name(
        "checkpoint", "delete", ["begin"]) == "cli.checkpoint.delete.begin")