Skip to content

Include exception in "Sling command failed" exceptions for easier debugging #35

@axellpadilla

Description

@axellpadilla

This function, sometimes doesn't return the error info, for example on "fatal" results.

def _exec_cmd(cmd, stdin=None, stdout=PIPE, stderr=STDOUT, env:dict=None):
lines = []
env = env or {}
for k,v in os.environ.items():
env[k] = env.get(k, v)
env['SLING_PACKAGE'] = 'python'
for pkg in ['dagster', 'airflow', 'temporal', 'orkes']:
if is_package(pkg):
env['SLING_PACKAGE'] = pkg
with Popen(cmd, shell=True, env=env, stdin=stdin, stdout=stdout, stderr=stderr) as proc:
if stdout and stdout != STDOUT and proc.stdout:
for line in proc.stdout:
line = str(line.strip(), 'utf-8', errors='replace')
yield line
proc.wait()
if stderr and stderr != STDOUT and proc.stderr:
lines = '\n'.join(list(proc.stderr))
if proc.returncode != 0:
if len(lines) > 0:
raise Exception(f'Sling command failed:\n{lines}')
raise Exception(f'Sling command failed')

To reproduce use an invalid stream, it will just said Sling command failed, this is probably because the error is on STDOUT instead and lines aren't being added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions