question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

shellTask logs all stdout when `ShellTask(return_all=True)`

See original GitHub issue

Context Currently, when prefect.tasks.shell.ShellTask is invoked with return_all=True, the shell task will not log the stdout through logger.debug.

This is defined in doc https://docs.prefect.io/api/latest/tasks/shell.html#shelltask and implement in the code. https://github.com/PrefectHQ/prefect/blob/73fe1eb57945fc13bdd36b361a6a17c3f324b1ba/src/prefect/tasks/shell.py#L107-L111

Problem

Sometimes, we execute a long-running shell process, for example, we are running dbt, which might take 20 to 40 minutes to run. the task would need to return the entire stdout log as its output, for the next task to parse and interpret the result. Meanwhile, We would also like to see the shell stdout logging out in real-time, which makes it easy for us to inspect issues and monitoring / debug shell runs on-the-go, instead of waiting for 20 minutes not knowing what is going on.

proposed change

                for raw_line in iter(sub_process.stdout.readline, b""):
                    line = raw_line.decode("utf-8").rstrip()
                    if self.return_all:
                        lines.append(line)
                    # we still log every line
                    self.logger.debug(line)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
dcaldecommented, Dec 16, 2020

Hi, should the log level be configurable or set to INFO? Anyone setting stream_output=True is likely to actually want to see the shell outputs in their logs without having to configure their agent to DEBUG. I was able to show the debug logs by configuring the ShellTask logger and adding a new StreamHandler when running locally, but not when deployed and running on the agent.

0reactions
dcaldecommented, Dec 17, 2020

@madkinsz thanks for the feedback. I have created a separate issue and referenced this discussion

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found