def test_bash_command_solid_overrides(): solid = bash_command_solid( 'echo "this is a test message: $MY_ENV_VAR"', name='foobar', description='a description override', ) result = execute_solid( solid, environment_dict={'solids': {'foobar': {'config': {'env': {'MY_ENV_VAR': 'foobar'}}}}}, ) assert result.output_values == {'result': 'this is a test message: foobar\n'} with pytest.raises(TypeError, match='Overriding output_defs for bash solid is not supported'): bash_command_solid( 'echo "this is a test message: $MY_ENV_VAR"', name='foobar', description='a description override', output_defs=[OutputDefinition(str, 'bad_output_def')], ) with pytest.raises(TypeError, match='Overriding config for bash solid is not supported'): bash_command_solid( 'echo "this is a test message: $MY_ENV_VAR"', name='foobar', description='a description override', config={'bad_config': Field(str)}, )
def test_bash_command_retcode(): with pytest.raises(DagsterExecutionStepExecutionError) as exc_info: execute_solid(bash_command_solid('exit 1')) assert 'step key: "bash_solid.compute"' in str(exc_info.value) assert 'solid invocation: "bash_solid"' in str(exc_info.value) assert 'solid definition: "bash_solid"' in str(exc_info.value)
def test_bash_command_solid(): solid = bash_command_solid('echo "this is a test message: $MY_ENV_VAR"', name='foobar') result = execute_solid( solid, environment_dict={'solids': {'foobar': {'config': {'env': {'MY_ENV_VAR': 'foobar'}}}}}, ) assert result.output_values == {'result': 'this is a test message: foobar'}
def test_bash_command_buffer_logs(): solid = bash_command_solid('for i in 1 2 3 4 5; do echo "hello ${i}"; done', name='foobar') result = execute_solid( solid, environment_dict={ 'solids': { 'foobar': {'config': {'output_logging': 'BUFFER', 'env': {'MY_ENV_VAR': 'foobar'}}} } }, ) assert result.output_values == {'result': 'hello 1\nhello 2\nhello 3\nhello 4\nhello 5\n'}
def test_bash_command_stream_logs(): solid = bash_command_solid( 'for i in 1 2 3 4 5; do echo "hello ${i}"; done', name='foobar') result = execute_solid( solid, environment_dict={ 'solids': { 'foobar': { 'config': { 'output_logging': 'STREAM', 'env': { 'MY_ENV_VAR': 'foobar' } } } } }, ) assert result.output_values == { 'result': 'hello 1hello 2hello 3hello 4hello 5' }
def test_bash_command_retcode(): with pytest.raises(Failure) as exc_info: execute_solid(bash_command_solid('exit 1')) assert 'Bash command failed' in str(exc_info.value)
def test_bash_command_retcode(): with pytest.raises(Failure, match='Bash command execution failed'): execute_solid(bash_command_solid('exit 1'))
def pipe(): a = bash_command_solid('echo "hello, world!"', name='a') a()