예제 #1
0
import sys

import pytest

from dagster.core.execution.compute_logs import (
    mirror_stream_to_file,
    should_disable_io_stream_redirect,
)
from dagster.utils.test import get_temp_file_name


@pytest.mark.skipif(should_disable_io_stream_redirect(),
                    reason="compute logs disabled for win / py3.6+")
def test_capture():
    with get_temp_file_name() as capture_filepath:
        with mirror_stream_to_file(sys.stdout, capture_filepath):
            print("HELLO")

        with open(capture_filepath, "r") as capture_stream:
            assert "HELLO" in capture_stream.read()
예제 #2
0

def define_pipeline():
    @pipeline(mode_defs=[ModeDefinition(resource_defs={'a': resource_a})])
    def spew_pipeline():
        spew(spew(spawn()))

    return spew_pipeline


def normalize_file_content(s):
    return '\n'.join([line for line in s.replace(os.linesep, '\n').split('\n') if line])


@pytest.mark.skipif(
    should_disable_io_stream_redirect(), reason="compute logs disabled for win / py3.6+"
)
def test_compute_log_to_disk():
    spew_pipeline = define_pipeline()
    instance = DagsterInstance.local_temp()
    manager = instance.compute_log_manager
    result = execute_pipeline(spew_pipeline, instance=instance)
    assert result.success

    compute_steps = [
        event.step_key
        for event in result.step_event_list
        if event.event_type == DagsterEventType.STEP_START
    ]
    for step_key in compute_steps:
        if step_key.startswith('spawn'):