Ejemplo n.º 1
0
def test_list_command_grpc_socket():
    with instance_for_test() as instance:
        runner = CliRunner()

        server_process = GrpcServerProcess(
            loadable_target_origin=LoadableTargetOrigin(
                executable_path=sys.executable,
                python_file=file_relative_path(__file__, "test_cli_commands.py"),
                attribute="bar",
            ),
        )

        with server_process.create_ephemeral_client() as api_client:
            execute_list_command(
                {"grpc_socket": api_client.socket}, no_print, instance,
            )
            execute_list_command(
                {"grpc_socket": api_client.socket, "grpc_host": api_client.host},
                no_print,
                instance,
            )

            result = runner.invoke(pipeline_list_command, ["--grpc-socket", api_client.socket])
            assert_correct_bar_repository_output(result)

            result = runner.invoke(
                pipeline_list_command,
                ["--grpc-socket", api_client.socket, "--grpc-host", api_client.host],
            )
            assert_correct_bar_repository_output(result)

        server_process.wait()
Ejemplo n.º 2
0
def test_list_command_grpc_socket():
    runner = CliRunner()

    with GrpcServerProcess(
        loadable_target_origin=LoadableTargetOrigin(
            python_file=file_relative_path(__file__, "test_cli_commands.py"), attribute="bar"
        ),
    ).create_ephemeral_client() as api_client:
        execute_list_command(
            {"grpc_socket": api_client.socket}, no_print, DagsterInstance.local_temp(),
        )
        execute_list_command(
            {"grpc_socket": api_client.socket, "grpc_host": api_client.host},
            no_print,
            DagsterInstance.local_temp(),
        )

        result = runner.invoke(pipeline_list_command, ["--grpc-socket", api_client.socket])
        assert_correct_bar_repository_output(result)

        result = runner.invoke(
            pipeline_list_command,
            ["--grpc-socket", api_client.socket, "--grpc-host", api_client.host],
        )
        assert_correct_bar_repository_output(result)
Ejemplo n.º 3
0
def test_list_command_deployed_grpc():
    runner = CliRunner()

    with instance_for_test() as instance:
        server_process = GrpcServerProcess(
            loadable_target_origin=LoadableTargetOrigin(
                executable_path=sys.executable,
                python_file=file_relative_path(__file__,
                                               "test_cli_commands.py"),
                attribute="bar",
            ),
            force_port=True,
        )

        with server_process.create_ephemeral_client() as api_client:
            result = runner.invoke(pipeline_list_command,
                                   ["--grpc-port", api_client.port])
            assert_correct_bar_repository_output(result)

            result = runner.invoke(
                pipeline_list_command,
                [
                    "--grpc-port", api_client.port, "--grpc-host",
                    api_client.host
                ],
            )
            assert_correct_bar_repository_output(result)

            result = runner.invoke(pipeline_list_command,
                                   ["--grpc-port", api_client.port])
            assert_correct_bar_repository_output(result)

            result = runner.invoke(
                pipeline_list_command,
                [
                    "--grpc-port", api_client.port, "--grpc-socket",
                    "foonamedsocket"
                ],
            )
            assert result.exit_code != 0

            execute_list_command(
                {"grpc_port": api_client.port},
                no_print,
                instance,
            )

            # Can't supply both port and socket
            with pytest.raises(UsageError):
                execute_list_command(
                    {
                        "grpc_port": api_client.port,
                        "grpc_socket": "foonamedsocket"
                    },
                    no_print,
                    instance,
                )

        server_process.wait()
Ejemplo n.º 4
0
def test_list_command():
    runner = CliRunner()

    execute_list_command(
        {
            'repository_yaml': script_relative_path('../repository.yaml'),
            'python_file': None,
            'module_name': None,
            'fn_name': None,
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        ['-y', script_relative_path('../repository.yaml')])
    assert result.exit_code == 0
Ejemplo n.º 5
0
def test_list_command():
    with instance_for_test() as instance:
        execute_list_command(
            {
                "repository_yaml": None,
                "python_file": file_relative_path(__file__,
                                                  "test_cli_commands.py"),
                "module_name": None,
                "fn_name": "bar",
            },
            no_print,
            instance,
        )

        execute_list_command(
            {
                "repository_yaml": None,
                "python_file": file_relative_path(__file__,
                                                  "test_cli_commands.py"),
                "module_name": None,
                "fn_name": "bar",
                "working_directory": os.path.dirname(__file__),
            },
            no_print,
            instance,
        )

        execute_list_command(
            {
                "repository_yaml": None,
                "python_file": None,
                "module_name":
                "dagster_tests.cli_tests.command_tests.test_cli_commands",
                "fn_name": "bar",
            },
            no_print,
            instance,
        )

        with pytest.raises(UsageError):
            execute_list_command(
                {
                    "repository_yaml": None,
                    "python_file": "foo.py",
                    "module_name":
                    "dagster_tests.cli_tests.command_tests.test_cli_commands",
                    "fn_name": "bar",
                },
                no_print,
                instance,
            )
Ejemplo n.º 6
0
def test_schedules_list():
    runner = CliRunner()

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': script_relative_path('test_cli_commands.py'),
            'module_name': None,
            'fn_name': 'define_bar_repo',
        },
        no_print,
    )

    result = runner.invoke(
        schedule_list_command,
        ['-y', script_relative_path('repository_file.yaml')])

    assert result.exit_code == 0
    assert result.output == ('Repository bar\n'
                             '**************\n'
                             'Schedule: foo_schedule \n'
                             'Cron Schedule: * * * * *\n')
Ejemplo n.º 7
0
def job_list_command(**kwargs):
    return execute_list_command(kwargs, click.echo, True)
Ejemplo n.º 8
0
def test_list_command():
    runner = CliRunner()

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': file_relative_path(__file__,
                                              'test_cli_commands.py'),
            'module_name': None,
            'fn_name': 'bar',
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        [
            '-f',
            file_relative_path(__file__, 'test_cli_commands.py'), '-n', 'bar'
        ],
    )

    assert result.exit_code == 0
    assert result.output == ('Repository bar\n'
                             '**************\n'
                             'Pipeline: baz\n'
                             'Description:\n'
                             'Not much tbh\n'
                             'Solids: (Execution Order)\n'
                             '    do_input\n'
                             '*************\n'
                             'Pipeline: foo\n'
                             'Solids: (Execution Order)\n'
                             '    do_something\n'
                             '    do_input\n')

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': None,
            'module_name': 'dagster_examples.intro_tutorial.repos',
            'fn_name': 'hello_cereal_repository',
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        [
            '-m', 'dagster_examples.intro_tutorial.repos', '-n',
            'hello_cereal_repository'
        ],
    )
    assert result.exit_code == 0
    assert result.output == ('Repository hello_cereal_repository\n'
                             '**********************************\n'
                             'Pipeline: complex_pipeline\n'
                             'Solids: (Execution Order)\n'
                             '    load_cereals\n'
                             '    sort_by_calories\n'
                             '    sort_by_protein\n'
                             '    display_results\n'
                             '*******************************\n'
                             'Pipeline: hello_cereal_pipeline\n'
                             'Solids: (Execution Order)\n'
                             '    hello_cereal\n')

    execute_list_command(
        {
            'repository_yaml':
            file_relative_path(__file__, 'repository_module.yaml'),
            'python_file':
            None,
            'module_name':
            None,
            'fn_name':
            None,
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        ['-y', file_relative_path(__file__, 'repository_module.yaml')])
    assert result.exit_code == 0
    assert result.output == ('Repository hello_cereal_repository\n'
                             '**********************************\n'
                             'Pipeline: complex_pipeline\n'
                             'Solids: (Execution Order)\n'
                             '    load_cereals\n'
                             '    sort_by_calories\n'
                             '    sort_by_protein\n'
                             '    display_results\n'
                             '*******************************\n'
                             'Pipeline: hello_cereal_pipeline\n'
                             'Solids: (Execution Order)\n'
                             '    hello_cereal\n')

    with pytest.raises(UsageError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': 'foo.py',
                'module_name': 'dagster_examples.intro_tutorial.repos',
                'fn_name': 'hello_cereal_repository',
            },
            no_print,
        )

    result = runner.invoke(
        pipeline_list_command,
        [
            '-f',
            'foo.py',
            '-m',
            'dagster_examples.intro_tutorial.repos',
            '-n',
            'hello_cereal_repository',
        ],
    )
    assert result.exit_code == 2

    with pytest.raises(UsageError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': None,
                'module_name': 'dagster_examples.intro_tutorial.repos',
                'fn_name': None,
            },
            no_print,
        )

    result = runner.invoke(pipeline_list_command,
                           ['-m', 'dagster_examples.intro_tutorial.repos'])
    assert result.exit_code == 2

    with pytest.raises(UsageError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': file_relative_path(__file__,
                                                  'test_cli_commands.py'),
                'module_name': None,
                'fn_name': None,
            },
            no_print,
        )

    result = runner.invoke(
        pipeline_list_command,
        ['-f', file_relative_path(__file__, 'test_cli_commands.py')])
    assert result.exit_code == 2
Ejemplo n.º 9
0
def test_list_command():
    runner = CliRunner()

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': script_relative_path('test_cli_commands.py'),
            'module_name': None,
            'fn_name': 'define_bar_repo',
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        ['-f', script_relative_path('test_cli_commands.py'), '-n', 'define_bar_repo'],
    )

    assert result.exit_code == 0
    assert result.output == (
        'Repository bar\n'
        '**************\n'
        'Pipeline: baz\n'
        'Description:\n'
        'Not much tbh\n'
        'Solids: (Execution Order)\n'
        '    do_input\n'
        '*************\n'
        'Pipeline: foo\n'
        'Solids: (Execution Order)\n'
        '    do_something\n'
    )

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': None,
            'module_name': 'dagster_examples.intro_tutorial.repos',
            'fn_name': 'define_repo',
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command, ['-m', 'dagster_examples.intro_tutorial.repos', '-n', 'define_repo']
    )
    assert result.exit_code == 0
    assert result.output == (
        'Repository demo_repository\n'
        '**************************\n'
        'Pipeline: repo_demo_pipeline\n'
        'Solids: (Execution Order)\n'
        '    hello_world\n'
    )

    execute_list_command(
        {
            'repository_yaml': script_relative_path('repository.yaml'),
            'python_file': None,
            'module_name': None,
            'fn_name': None,
        },
        no_print,
    )

    result = runner.invoke(pipeline_list_command, ['-y', script_relative_path('repository.yaml')])
    assert result.exit_code == 0
    assert result.output == (
        'Repository demo_repository\n'
        '**************************\n'
        'Pipeline: repo_demo_pipeline\n'
        'Solids: (Execution Order)\n'
        '    hello_world\n'
    )

    with pytest.raises(CliUsageError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': 'foo.py',
                'module_name': 'dagster_examples.intro_tutorial.repos',
                'fn_name': 'define_repo',
            },
            no_print,
        )

    result = runner.invoke(
        pipeline_list_command,
        ['-f', 'foo.py', '-m', 'dagster_examples.intro_tutorial.repos', '-n', 'define_repo'],
    )
    assert result.exit_code == 1
    assert isinstance(result.exception, CliUsageError)

    with pytest.raises(CliUsageError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': None,
                'module_name': 'dagster_examples.intro_tutorial.repos',
                'fn_name': None,
            },
            no_print,
        )

    result = runner.invoke(pipeline_list_command, ['-m', 'dagster_examples.intro_tutorial.repos'])
    assert result.exit_code == 1
    assert isinstance(result.exception, CliUsageError)

    with pytest.raises(CliUsageError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': script_relative_path('test_cli_commands.py'),
                'module_name': None,
                'fn_name': None,
            },
            no_print,
        )

    result = runner.invoke(
        pipeline_list_command, ['-f', script_relative_path('test_cli_commands.py')]
    )
    assert result.exit_code == 1
    assert isinstance(result.exception, CliUsageError)
Ejemplo n.º 10
0
def test_list_command():
    runner = CliRunner()

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': file_relative_path(__file__, 'test_cli_commands.py'),
            'module_name': None,
            'fn_name': 'bar',
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        ['-f', file_relative_path(__file__, 'test_cli_commands.py'), '-a', 'bar'],
    )

    assert_correct_bar_repository_output(result)

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': None,
            'module_name': 'dagster_examples.intro_tutorial.repos',
            'fn_name': 'hello_cereal_repository',
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        ['-m', 'dagster_examples.intro_tutorial.repos', '-a', 'hello_cereal_repository'],
    )
    assert_correct_hello_cereal_output(result)

    execute_list_command(
        {
            'repository_yaml': file_relative_path(__file__, 'repository_module.yaml'),
            'python_file': None,
            'module_name': None,
            'fn_name': None,
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command, ['-w', file_relative_path(__file__, 'repository_module.yaml')]
    )
    assert_correct_hello_cereal_output(result)

    with pytest.raises(UsageError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': 'foo.py',
                'module_name': 'dagster_examples.intro_tutorial.repos',
                'fn_name': 'hello_cereal_repository',
            },
            no_print,
        )

    result = runner.invoke(
        pipeline_list_command,
        [
            '-f',
            'foo.py',
            '-m',
            'dagster_examples.intro_tutorial.repos',
            '-a',
            'hello_cereal_repository',
        ],
    )
    assert result.exit_code == 2

    result = runner.invoke(pipeline_list_command, ['-m', 'dagster_examples.intro_tutorial.repos'])
    assert_correct_hello_cereal_output(result)

    result = runner.invoke(
        pipeline_list_command, ['-f', file_relative_path(__file__, 'test_cli_commands.py')]
    )
    assert_correct_bar_repository_output(result)
Ejemplo n.º 11
0
def test_list_command(gen_instance):
    with gen_instance as instance:
        execute_list_command(
            {
                "repository_yaml": None,
                "python_file": file_relative_path(__file__,
                                                  "test_cli_commands.py"),
                "module_name": None,
                "fn_name": "bar",
            },
            no_print,
            instance,
        )

        execute_list_command(
            {
                "repository_yaml": None,
                "python_file": file_relative_path(__file__,
                                                  "test_cli_commands.py"),
                "module_name": None,
                "fn_name": "bar",
                "working_directory": os.path.dirname(__file__),
            },
            no_print,
            instance,
        )

        execute_list_command(
            {
                "repository_yaml": None,
                "python_file": None,
                "module_name":
                "dagster_tests.cli_tests.command_tests.test_cli_commands",
                "fn_name": "bar",
            },
            no_print,
            instance,
        )

        with pytest.warns(
                UserWarning,
                match=re.escape(
                    "You have used -y or --repository-yaml to load a workspace. This is deprecated and "
                    "will be eliminated in 0.9.0."),
        ):
            execute_list_command(
                {
                    "repository_yaml":
                    file_relative_path(__file__, "repository_module.yaml"),
                    "python_file":
                    None,
                    "module_name":
                    None,
                    "fn_name":
                    None,
                },
                no_print,
                instance,
            )

        with pytest.raises(UsageError):
            execute_list_command(
                {
                    "repository_yaml": None,
                    "python_file": "foo.py",
                    "module_name":
                    "dagster_tests.cli_tests.command_tests.test_cli_commands",
                    "fn_name": "bar",
                },
                no_print,
                instance,
            )
Ejemplo n.º 12
0
def test_list_command():
    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': script_relative_path('test_dynamic_loader.py'),
            'module_name': None,
            'fn_name': 'define_bar_repo',
        },
        no_print,
    )

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': None,
            'module_name': 'dagster.tutorials.intro_tutorial.repos',
            'fn_name': 'define_repo',
        },
        no_print,
    )

    execute_list_command(
        {
            'repository_yaml': script_relative_path('repository.yml'),
            'python_file': None,
            'module_name': None,
            'fn_name': None,
        },
        no_print,
    )

    with pytest.raises(InvalidRepositoryLoadingComboError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': 'foo.py',
                'module_name': 'dagster.tutorials.intro_tutorial.repos',
                'fn_name': 'define_repo',
            },
            no_print,
        )

    with pytest.raises(InvalidRepositoryLoadingComboError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': None,
                'module_name': 'dagster.tutorials.intro_tutorial.repos',
                'fn_name': None,
            },
            no_print,
        )

    with pytest.raises(InvalidRepositoryLoadingComboError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': script_relative_path('test_dynamic_loader.py'),
                'module_name': None,
                'fn_name': None,
            },
            no_print,
        )
Ejemplo n.º 13
0
def test_list_command():
    runner = CliRunner()

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': file_relative_path(__file__,
                                              'test_cli_commands.py'),
            'module_name': None,
            'fn_name': 'bar',
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        [
            '-f',
            file_relative_path(__file__, 'test_cli_commands.py'), '-a', 'bar'
        ],
    )

    assert_correct_bar_repository_output(result)

    execute_list_command(
        {
            'repository_yaml': None,
            'python_file': None,
            'module_name': 'dagster_tests.cli_tests.test_cli_commands',
            'fn_name': 'bar',
        },
        no_print,
    )

    result = runner.invoke(
        pipeline_list_command,
        [
            '-m',
            'dagster_tests.cli_tests.test_cli_commands',
            '-a',
            'bar',
        ],
    )
    assert_correct_bar_repository_output(result)

    with pytest.warns(
            UserWarning,
            match=re.escape(
                'You have used -y or --repository-yaml to load a workspace. This is deprecated and '
                'will be eliminated in 0.9.0.'),
    ):
        execute_list_command(
            {
                'repository_yaml':
                file_relative_path(__file__, 'repository_module.yaml'),
                'python_file':
                None,
                'module_name':
                None,
                'fn_name':
                None,
            },
            no_print,
        )

    with pytest.warns(
            UserWarning,
            match=re.escape(
                'You are using the legacy repository yaml format. Please update your file '
            ),
    ):
        result = runner.invoke(
            pipeline_list_command,
            ['-w',
             file_relative_path(__file__, 'repository_module.yaml')])
        assert_correct_bar_repository_output(result)

    result = runner.invoke(
        pipeline_list_command,
        ['-w', file_relative_path(__file__, 'workspace.yaml')])
    assert_correct_bar_repository_output(result)

    result = runner.invoke(
        pipeline_list_command,
        [
            '-w',
            file_relative_path(__file__, 'workspace.yaml'),
            '-w',
            file_relative_path(__file__, 'override.yaml'),
        ],
    )
    assert_correct_extra_repository_output(result)

    with pytest.raises(UsageError):
        execute_list_command(
            {
                'repository_yaml': None,
                'python_file': 'foo.py',
                'module_name': 'dagster_tests.cli_tests.test_cli_commands',
                'fn_name': 'bar',
            },
            no_print,
        )

    result = runner.invoke(
        pipeline_list_command,
        [
            '-f',
            'foo.py',
            '-m',
            'dagster_tests.cli_tests.test_cli_commands',
            '-a',
            'bar',
        ],
    )
    assert result.exit_code == 2

    result = runner.invoke(
        pipeline_list_command,
        ['-m', 'dagster_tests.cli_tests.test_cli_commands'],
    )
    assert_correct_bar_repository_output(result)

    result = runner.invoke(
        pipeline_list_command,
        ['-f', file_relative_path(__file__, 'test_cli_commands.py')])
    assert_correct_bar_repository_output(result)